Unrounded glyph widths in an interpolated UFO?



  • Hello! I'm trying to get an unrounded interpolation that I then want to use as a master in a subsequent interpolation. I'm currently using font.interpolate() with round=False. In the generated UFO the points are unrounded but the glyph widths are rounded. Is there a way I can also get unrounded widths? Thank you!


  • admin

    hello @grahambradley,

    interpolation with round=False will correctly produce glyph.width as a float if (and only if) your Snap points setting is zero. (in Preferences > Glyph View > Display)

    the RoboFont UI may round glyph widths to integers though – for example, if you edit a glyph width using the Space Center or the Inspector, it will become an integer. so, if you want to keep glyph widths as floats, don’t edit them in the UI.

    hope this helps!



  • Amazing! Thank you so much for the quick reply - it's working for me now. I have two quick follow up questions:

    1. Is there a way to set and unset that with a script so that I don't have to remember to manually change it?

    2. Do I need to set that when using other tools (like DesignSpaceEdit, Skateboard, Batch, etc.) so that they don't round data from an imported UFO?

    Really appreciate your help with this!


  • admin

    hello @grahambradley,

    (1)Is there a way to set and unset that with a script so that I don't have to remember to manually change it?

    yes, here’s a quick example:

    from mojo.UI import getDefault, setDefault
    
    # store current snap value
    snapValue = getDefault('glyphViewRoundValues')
    print('snap value was:', snapValue)
    
    # set snap value to zero
    print('setting snap value to 0')
    setDefault('glyphViewRoundValues', 0)
    
    # do something...
    
    # restore previous value when done
    setDefault('glyphViewRoundValues', snapValue)
    print('restoring snap value of', snapValue)
    

    (2) Do I need to set that when using other tools (like DesignSpaceEdit, Skateboard, Batch, etc.) so that they don't round data from an imported UFO?

    yes. the round value is used by the native glyph object (even without the UI), and when generating fonts.

    glyph widths are always rounded to integers when generating fonts, this is a restriction of the OpenType horizontal metrics table (htmx).

    hope this helps. good luck!



  • Nice - the code will be super helpful and that's so good to know about the settings. Thank you very much!