googlefonts / ufo2ft

A bridge from UFOs to FontTools objects (and therefore, OTFs and TTFs).
MIT License
152 stars 43 forks source link

Most OS/2 table values are zeroed #36

Closed robmck-ms closed 8 years ago

robmck-ms commented 8 years ago

Using https://github.com/googlei18n/fontmake/ to dump a Glyphs file to TTF, most OS/2 table values are zeroed. e.g. unicode ranges, ySubscript, ySuperscript, yStrikeout*, etc. Though, I notice that the UFOs don't have these either.

Filing the issue here per Behdad's suggestion.

behdad commented 8 years ago

Thanks Rob.

jamesgk commented 8 years ago

ySubscript, ySuperscript, yStrikeout* should now be set by ufo2ft. I'd recommend setting unicode ranges in Glyphs/UFO sources themselves (the AFDKO uses a rough heuristic to set them anyways: https://github.com/adobe-type-tools/afdko/blob/0dd483454f2f8cf9e03802bc1350985452071f5b/FDK/Tools/Programs/makeotf/makeotf_lib/source/hotconv/map.c#L1744)

anthrotype commented 8 years ago

@jamesgk the fonttools' OS/2 table module has a recalcUnicodeRanges function, in case you didn't know. It simply sets the ulUnicodeRange* bits if there is any intersection (at least one character) between the OS/2 block ranges and the Unicode cmap subtables in the font. It also contains the unicode ranges data from the OT spec in case one wants to use a different algorithm.

jamesgk commented 8 years ago

Oh! That sounds useful. Though, I'm not really sure how to use it in ufo2ft. We'd have to call it after the outline is compiled, but only if the existing ranges are all blank? Not sure if that's necessarily a good idea but I'm open to it.

robmck-ms commented 8 years ago

Thanks!

Usually, Glyphs figures out unicode ranges for you, so I suspect most people to leave it unset in Glyphs. Might be nice in the long term to auto-calculate it. For now, I'll manually set it.

adrientetar commented 8 years ago

We'd have to call it after the outline is compiled, but only if the existing ranges are all blank?

Can we just recalculate all the time? Arguably the data in the source shouldn't be discarded, but I can't see why one would want this data different for the actual glyph coverage in the font.

anthrotype commented 8 years ago

Because there's no unanimous agreement on how those bits should be calculated. For the fonttools subsetter (the tool for which that feature was added) we ended up only un-setting the ones for which there are no characters left after subsetting. As for when one should set them on, the spec says it is left to "designer".

anthrotype commented 8 years ago

The turn-them-on-if-at-east-one-is-present rule comes from FontLab, and it's the one I personally prefer.

adrientetar commented 8 years ago

Does any software make use of ulUnicodeRange anyway?

anthrotype commented 8 years ago

cc @twardoch

anthrotype commented 8 years ago

Usually, Glyphs figures out unicode ranges for you

@schriftgestalt I'm curious, how does Glyphs calculates OS/2 Unicode ranges?

schriftgestalt commented 8 years ago

Glyphs isn't doing it, it's makeOTF.

anthrotype commented 8 years ago

Good to know, thanks.