Exemplo n.º 1
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()
Exemplo n.º 2
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()
Exemplo n.º 3
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()
Exemplo n.º 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()
Exemplo n.º 5
0
def align_to_grid(font, xxx_todo_changeme):
    """
    Align all points of all glyphs in the font to a grid with size ``(sizeX,sizeY)``.

    """
    (sizeX, sizeY) = xxx_todo_changeme
    for glyph in font:
        round_points(glyph, (sizeX, sizeY))
        glyph.update()
    font.update()
Exemplo n.º 6
0
        glyph.correctDirection()

def add_extremes(font):
    """Add extreme points to all glyphs in the font, if they are missing."""
    for glyph in font:
        glyph.extremePoints()

def remove_overlap(font):
    """Remove overlaps in all glyphs of the font."""
    for glyph in font:
        glyph.removeOverlap()

def align_to_grid(font, (sizeX, sizeY)):
    """Align all points of all glyphs in the font to a grid with size ``(sizeX,sizeY)``."""
    for glyph in font:
        round_points(glyph, (sizeX, sizeY))
        glyph.update()
    font.update()

def scale_glyphs(f, (factor_x, factor_y)):
    """Scale all glyphs in the font by the given ``(x,y)`` factor."""
    for g in f:
        if len(g.components) == 0:
            leftMargin, rightMargin = g.leftMargin, g.rightMargin
            g.scale((factor_x, factor_y))
            g.leftMargin = leftMargin * factor_x
            g.rightMargin = rightMargin * factor_x
            g.update()
    f.update()

def move_glyphs(f, (delta_x, delta_y)):
Exemplo n.º 7
0
        glyph.extremePoints()


def remove_overlap(font):
    """Remove overlaps in all glyphs of the font."""
    for glyph in font:
        glyph.removeOverlap()


def align_to_grid(font, (sizeX, sizeY)):
    """
    Align all points of all glyphs in the font to a grid with size ``(sizeX,sizeY)``.

    """
    for glyph in font:
        round_points(glyph, (sizeX, sizeY))
        glyph.update()
    font.update()


def scale_glyphs(f, (factor_x, factor_y)):
    """
    Scale all glyphs in the font by the given ``(x,y)`` factor.

    """
    for g in f:
        if len(g.components) == 0:
            leftMargin, rightMargin = g.leftMargin, g.rightMargin
            g.scale((factor_x, factor_y))
            g.leftMargin = leftMargin * factor_x
            g.rightMargin = rightMargin * factor_x