go-text / typesetting

High quality text shaping in pure Go.
Other
101 stars 10 forks source link

Add an API to query font metadata such as family name and style #51

Closed benoitkugler closed 1 year ago

benoitkugler commented 1 year ago

This PR provides a way to query metadata about a font (see also #49)

The changes are large because some code has moved to the tables package to avoid duplication.

The various constants are taken from the CSS specifications (also used by other librairies like font-kit).

For now, the API requires a *loader.Loader, meaning the original font file is needed. This is required since the *font.Font type does not store all the metadata, it only selects the shaping/glyph related information.

benoitkugler commented 1 year ago

Only one very minor recommendation about how constants are defined. Otherwise this looks fantastic! Is there a specific reason that you marked it as a draft?

Hum no, not really, just because I was not sure about the constants or the Metadata signature.

benoitkugler commented 1 year ago

This all looks good to me. Thank you very much! Should we offer a way to expose this in typesetting/font? Maybe ParseTTFWithMetadata? We certainly don't need to, as applications can implement that themselves. It's more a question of what we want to offer out of the box.

We could maybe be a bit conservative here and wait before adding it ? We will probably have other metadata related features in the future.