googlefonts / fontc

Where in we pursue oxidizing (context: https://github.com/googlefonts/oxidize) fontmake.
Apache License 2.0
83 stars 14 forks source link

Support widely used global metrics #173

Closed rsheeter closed 1 day ago

rsheeter commented 1 year ago

https://unifiedfontobject.org/versions/ufo3/fontinfo.plist/ - annoyingly optional - has values. .glyphs presumably has fields for it.

@anthrotype says there are also exciting ways to figure them out but in most cases the source would just specify.

http://fontbakery.com/#com.daltonmaag/check/ufo-required-fields strongly suggests these values will usually be set.

dfrg commented 1 year ago

For reference, this is how we extract these values in skrifa: https://github.com/googlefonts/fontations/blob/a5dc0bcba6a6111d0b45a914028796c730785a60/skrifa/src/meta/metrics.rs#L137

anthrotype commented 1 year ago

UFO fontinfo has generic ascender/descender in https://unifiedfontobject.org/versions/ufo3/fontinfo.plist/#generic-dimension-information, plus OT table-specific fields prefixed with openType{table}* e.g. openTypeHheaAscender etc. The latter being more specific/low-level are supposed to take precedence over the generic ones. The ufo2ft.fontInfoData contains the logic for how to derive "fallback" values when some of these attributes are missing.

For {h,v}hea, this is where ufo2ft sets ascender/descender/linegap: https://github.com/googlefonts/ufo2ft/blob/fca66fe3ea1ea88ffb36f8264b21ce042d3afd05/Lib/ufo2ft/outlineCompiler.py#L750-L771

And for OS/2, the equivalent fields are set in https://github.com/googlefonts/ufo2ft/blob/fca66fe3ea1ea88ffb36f8264b21ce042d3afd05/Lib/ufo2ft/outlineCompiler.py#L661-L675

vertical font metrics are a bit of a can of worms and seems nobody agrees on what they should look like. We should consult with our font QA expert on that and settle one some good-enough defaults, leaving to the font developer the responsibility to set them explicitly if the care/wish.

anthrotype commented 1 year ago

I also think we should set the OS/2 fsSelection flag USE_TYPO_METRICS by default so the supposedly more modern "typo" metrics are preferred. Note that ufo2ft does not currently do that (it simply writes out whatever openTypeOS2Selection is in the UFO fontinfo.plist), probably to keep a pre-exisiting default behaviour.

rsheeter commented 1 year ago

https://github.com/googlefonts/fontmake-rs/pull/194 added default population of asc/desc

rsheeter commented 1 year ago

https://github.com/googlefonts/fontmake-rs/pull/206 captures maps of normalized locaation : metric value for several metrics but they do not yet flow through into the output font.

anthrotype commented 1 day ago

is there any work left for this or can it be closed?

rsheeter commented 1 day ago

I don't know of any, lets close it and fix specific issues as crater finds them