SOLVED Having trouble transforming all glyphs



  • I have a draft font with a character set that is basically A–Z, a–z, and 0–9, plus some punctuation. I’m experimenting with making a narrow version of it via the "Transform All Glyphs" option:

    c67beb4f-373d-43ed-96b6-8a884457c4d8-image.png

    However, it’s getting hung up on the space glyph:

    c6c4f6e1-4fda-47bc-8747-7b919035bf12-image.png

    Traceback (most recent call last):
      File "/Applications/RoboFontBeta.app/Contents/Resources/lib/python3.7/vanilla/vanillaBase.py", line 506, in action_
        self.callback(sender)
      File "lib/UI/inspector/transformPane.pyc", line 546, in applyTransformPopUpCallback
      File "lib/UI/inspector/transformPane.pyc", line 572, in _callculateTransformation
      File "lib/tools/transformGlyph.pyc", line 212, in transform
      File "lib/tools/transformGlyph.pyc", line 132, in _transformGlyph
      File "lib/eventTools/editingTool.pyc", line 191, in setTransformMode
      File "lib/eventTools/editingTool.pyc", line 132, in resetTransform
    AttributeError: 'EditingTool' object has no attribute 'transformationLayer'
    

    Is there anything I should do differently to get around this?

    • RoboFont Version 4.1b (build 2110061420)
    • macOS Catalina 10.15.7


  • @frederik Awesome, thanks!



  • @roberto-arista

    Ohhh thank you! This bit is golden. I’ll try to make this a habit.

    except Exception as error:
        print(error)
    

  • admin

    bug already fixed in the newer beta's!



  • πŸ‘‹

    I would avoid catching silently an error. I suggest to change your code in this way:

    • catch a wider array of exceptions
    • print the error if caught
    f = CurrentFont()
    
    for g in f:
        try:
            oldRightMargin = g.rightMargin
            oldLeftMargin = g.leftMargin
            g.scale((0.25, 1))
            g.leftMargin = oldLeftMargin * 0.25
            g.rightMargin = oldRightMargin * 0.25
        except Exception as error:
            print(error)
    


  • Update: I realized that a script could probably do this better, because I also wanted to adjust sidebearings.

    This works okay, for a quick prototype:

    f = CurrentFont()
    
    for g in f:
        try:
            oldRightMargin = g.rightMargin
            oldLeftMargin = g.leftMargin
            g.scale((0.25,1))
            g.leftMargin = oldLeftMargin * .25
            g.rightMargin = oldRightMargin * .25
        except TypeError:
            pass
    

Log in to reply