robotools / fontParts

The replacement for RoboFab
MIT License
132 stars 44 forks source link

Can we make `font.insertGlyph` return that glyph #727

Open ryanbugden opened 3 months ago

ryanbugden commented 3 months ago

It would be useful to be able to store the just-inserted glyph into a variable on the fly.

f = CurrentFont()
new_glyph = f.insertGlyph(f['a'], 'b')
new_glyph.moveBy((999,999))

Currently, these are the options:

  1. With insertGlyph

    f = CurrentFont()
    f.insertGlyph(f['a'], 'b')
    new_glyph = f['b']
    new_glyph.moveBy((999,999))
  2. With newGlyph

    f = CurrentFont()
    new_glyph = f.newGlyph('b')
    new_glyph.appendGlyph(f['a'])
    new_glyph.width = f['a'].width
    new_glyph.moveBy((999,999))
  3. The best way probably, but not really documented:

    f = CurrentFont()
    new_glyph = f['b'] = f['a']