Trouble scaling components in Glyphs

  • #this works; scales the glyph nicely (components uses glyph coordinate)
    g = CurrentGlyph()
    g.scale((0.5, 0.5))
    #this doesn’t work as expected; component use their own coordinates
    f = CurrentFont()
    for g in f:
        g.scale((0.5, 0.5))

  • admin

    yeah off course, you scale the component base glyphs to :)
    so components will be double scaled, once by their base glyphs and once by the component transformation that get scaled.

  • Haha, it drove me insane. Thanks for your enlightenment.

  • I have still not managed to transform the font successfully.
    Do I oversee something again? It looks like a bug to me:

    f = CurrentFont()
    for g in f:
    if len(g.contours) > 0:
    for c in g.contours:
    c.scale((0.5, 0.5))

    File "", line 13, in
    File "lib/fontObjects/robofabWrapper.pyc", line 1432, in scale
    File "/Applications/", line 148, in scale
    File "/Applications/", line 199, in transform
    TypeError: can only concatenate tuple (not "int") to tuple

    I can make it work via metric transformations. But it’s not as elegant :)

  • admin

    that is a really bug :)

    a workaround:
    <pre>from fontTools.misc.transform import Transform

    f = CurrentFont()

    t = Transform().scale(.5, .5)

    possible transformations:

    .translate(x, y)


    .skew(x, y)


    for g in f:
    g.transform(t, doComponents=False)

    # or for each contour
    # for c in g:
    #    c.transform(t)</pre>

    hope this helps,
    thanks for reporting and this will be solved in the next update.

  • Cool!

    Where can I see the RoboFont transform function/glyph class?

    I would like to check out if it has any other properties I am unaware off. Is there some documentation I am missing? The fontobjects source is bytecode:



  • admin

  • The object-browser is great! Thanks.