(font, glyph, scale)
return matrix
Scales the glyph, but keeps it centered around its original bounding
    box.
Scales the glyph, but keeps it centered around its original bounding
    box.
Scales the glyph but keeps it centered around its original bounding box .
def scaleGlyph(font, glyph, scale):
    """Scales the glyph, but keeps it centered around its original bounding
    box."""
    from fontTools.pens.recordingPen import RecordingPointPen
    from fontTools.pens.transformPen import TransformPointPen
    from fontTools.misc.transform import Identity

    width = glyph.width
    bbox = glyph.getBounds(font)
    x = (bbox.xMin + bbox.xMax) / 2
    y = (bbox.yMin + bbox.yMax) / 2
    matrix = Identity
    matrix = matrix.translate(-x * scale + x, -y * scale + y)
    matrix = matrix.scale(scale)

    rec = RecordingPointPen()
    glyph.drawPoints(rec)
    glyph.clearContours()
    glyph.clearComponents()

    pen = TransformPointPen(glyph.getPointPen(), matrix)
    rec.replay(pen)

    if width == 0:
        glyph.width = width

    return matrix
def scaleGlyph ( font , glyph , scale ) : from fontTools . pens . recordingPen import RecordingPointPen from fontTools . pens . transformPen import TransformPointPen from fontTools . misc . transform import Identity width = glyph . width bbox = glyph . getBounds ( font ) x = ( bbox . xMin + bbox . xMax ) / 2 y = ( bbox . yMin + bbox . yMax ) / 2 matrix = Identity matrix = matrix . translate ( - x * scale + x , - y * scale + y ) matrix = matrix . scale ( scale ) rec = RecordingPointPen ( ) glyph . drawPoints ( rec ) glyph . clearContours ( ) glyph . clearComponents ( ) pen = TransformPointPen ( glyph . getPointPen ( ) , matrix ) rec . replay ( pen ) if width == 0 : glyph . width = width return matrix