Trouble scaling components in Glyphs

RoboFont Forums Bugs Trouble scaling components in Glyphs

This topic contains 7 replies, has 2 voices, and was last updated by  Bruno 8 years, 10 months ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #2157

    Bruno
    Participant

    #this works; scales the glyph nicely (components uses glyph coordinate)
    g = CurrentGlyph()
    g.scale((0.5, 0.5))
    g.update()

    #this doesn’t work as expected; component use their own coordinates
    f = CurrentFont()
    for g in f:
    g.scale((0.5, 0.5))
    g.update()

    #2159

    frederik
    Keymaster

    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.

    #2166

    Bruno
    Participant

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

    #2177

    Bruno
    Participant

    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))
    ========================
    Traceback:
    File “2000UPM.py”, line 13, in
    File “lib/fontObjects/robofabWrapper.pyc”, line 1432, in scale
    File “/Applications/RoboFont.app/Contents/Resources/lib/python2.7/fontTools/misc/transform.py”, line 148, in scale
    File “/Applications/RoboFont.app/Contents/Resources/lib/python2.7/fontTools/misc/transform.py”, 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 :)

    #2196

    frederik
    Keymaster

    that is a really bug :)

    a workaround:

    from fontTools.misc.transform import Transform
    
    f = CurrentFont()
    
    t = Transform().scale(.5, .5)
    
    ## possible transformations:
    ## .translate(x, y)
    ## .rotate(radiansAngle)
    ## .skew(x, y)
    ## .inverse()
    
    for g in f:
        g.transform(t, doComponents=False)
        
        # or for each contour
        # for c in g:
        #    c.transform(t)

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

    #2203

    Bruno
    Participant

    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:

    robofabWrapper.pyc

    Thanks,

    #2209

    frederik
    Keymaster
    #2219

    Bruno
    Participant

    The object-browser is great! Thanks.

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.