googlefonts/fontations

Picking Family and Style names with WWS

bungeman opened this issue · 0 comments

OpenType fonts have at least three family names (1, 16, 21) and three style names (2, 17, 22). The general way to pick these is to prefer the higher numbered ones, unless OS2::fsSelection bit 8 exists and is set in which case 21 and 22 should be ignored by newer interpreters (unless of course the lower numbered ones don't exist).

These rules are non-trivial and non-obvious so it would be nice if the library handled this instead of users needing to know about these interesting rules (which may change again in the future). Since retrieving the family and style names are a common use, it may be best to provide a FontRef::family_name() -> StringId (or FontRef::family_name() -> LocalizedStrings) and a similar FontRef::style_name() which works in a similar way.

This idea was first discussed at on Skia change [fontations] Modernize family name, though note that this change does not include a fallback to the nameid 21 when it would normally be ignored but 16 and 1 aren't available.