示例#1
0
def round_to_grid(font, gridsize, glyphs=None):
    if glyphs is None:
        glyphs = font.keys()
    for glyph_name in glyphs:
        round_points(font[glyph_name], (gridsize, gridsize))
        round_width(font[glyph_name], gridsize)
    font.update()
示例#2
0
def round_to_grid(font, gridsize, glyphs=None):
    if glyphs is None:
        glyphs = list(font.keys())
    for glyph_name in glyphs:
        round_points(font[glyph_name], (gridsize, gridsize))
        round_width(font[glyph_name], gridsize)
    font.update()
示例#3
0
 def gridfit(self, g, options):
     gridsize = options['gridsize']
     # all layers
     if options['layers']:
         # align layers data
         _layers = self.font.layerOrder
         for layer_name in _layers:
             glyph = g.getLayer(layer_name)
             glyph.prepareUndo('align to grid')
             if options['bpoints']:
                 round_bpoints(glyph, (gridsize, gridsize))
             if options['points']:
                 round_points(glyph, (gridsize, gridsize))
             if options['anchors']:
                 round_anchors(glyph, (gridsize, gridsize))
             glyph.performUndo()
         # align metrics
         if options['margins']:
             round_margins(g, gridsize, left=True, right=True)
         if options['width']:
             round_width(g, gridsize)
     # active layers only
     else:
         g.prepareUndo('align to grid')
         if options['bpoints']:
             round_bpoints(g, (gridsize, gridsize))
         if options['points']:
             round_points(g, (gridsize, gridsize))
         if options['anchors']:
             round_anchors(g, (gridsize, gridsize))
         if options['margins']:
             round_margins(g, gridsize, left=True, right=True)
         if options['width']:
             round_width(g, gridsize)
         g.performUndo()
示例#4
0
 def gridfit(self, g, options):
     gridsize = options['gridsize']
     # all layers
     if options['layers']:
         # align layers data
         _layers = self.font.layerOrder
         for layer_name in _layers:
             glyph = g.getLayer(layer_name)
             glyph.prepareUndo('align to grid')
             if options['bpoints']:
                 round_bpoints(glyph, (gridsize, gridsize))
             if options['points']:
                 round_points(glyph, (gridsize, gridsize))
             if options['anchors']:
                 round_anchors(glyph, (gridsize, gridsize))
             glyph.performUndo()
         # align metrics
         if options['margins']:
             round_margins(g, gridsize, left=True, right=True)
         if options['width']:
             round_width(g, gridsize)
     # active layers only
     else:
         g.prepareUndo('align to grid')
         if options['bpoints']:
             round_bpoints(g, (gridsize, gridsize))
         if options['points']:
             round_points(g, (gridsize, gridsize))
         if options['anchors']:
             round_anchors(g, (gridsize, gridsize))
         if options['margins']:
             round_margins(g, gridsize, left=True, right=True)
         if options['width']:
             round_width(g, gridsize)
         g.performUndo()