robotools / robofab

RoboFab
http://robofab.org
Other
108 stars 31 forks source link

Glyph "width" attributes not set when converting .otf to .ufo #28

Closed jamesgk closed 9 years ago

jamesgk commented 9 years ago

@behdad

The glyph data created when converting an OpenType font to UFO doesn't seem to include advance widths.

One possible solution is to rearrange some code in writeGlyphToString in glifLib.py, moving the drawPointsFunc-related code to come before the width-setting code (since calling a glyph object's draw function sets its width attribute).

behdad commented 9 years ago

Note that in https://github.com/behdad/fonttools/blob/master/Lib/fontTools/ttLib/__init__.py there's this line:

def getGlyphSet(self, preferCFF=True):
"""Return a generic GlyphSet, which is a dict-like object
mapping glyph names to glyph objects. The returned glyph objects
have a .draw() method that supports the Pen protocol, and will
have an attribute named 'width', but only *after* the .draw() method
has been called.

suggesting that the current robofont behavior (accessing 'width' before calling draw()) is wrong.

behdad commented 9 years ago

That said, note that even if the order is fixed, then for a CFF font, this will fetch the glyph width encoded in the CFF table. I think we always want to fetch the width stored in the hmtx table. So I suggest that tools.toolsAll.fontToUFO() be changed to make a proxy glyph object around the fonttools glyphs that fetches the width from hmtx and forwards the draw() call.

behdad commented 9 years ago

I actually fixed this on the fonttools side. Feel free to close.