go-text / typesetting

High quality text shaping in pure Go.
Other
88 stars 11 forks source link

Opentype (2/2) #42

Closed benoitkugler closed 1 year ago

benoitkugler commented 1 year ago

This PR adds an higher level API to use Opentype font files. It is meant to be

The structure of the package, with api and api/font is designed to support futur extension. For instance, a package fetching font metadata (footprints) could nicely be added as api/metadata; a sub-setter could go in api/subset.

(I've no strong opinion about the package names though.)

The api/font implementation exposes two types : a read-only *Font, which support concurrent uses and a light wrapper Face, so that toolkits may re-use *Font objects across the whole application. Besides, the Face object is to be the direct replacement of the existing textlayout/fonts.Face.

Thank you for your suggestions !

benoitkugler commented 1 year ago

@sbinet Thank you for your review, all your suggestions have been applied.

andydotxyz commented 1 year ago

Thanks so much, am trying to grok it all but there is a lot here!

  • used by the GUI toolkits when rendering glyphs

Regarding this I was not sure what the main entry point is or how it would be used. Is one of the tests demoing the expected toolkit usage?

benoitkugler commented 1 year ago

Thanks so much, am trying to grok it all but there is a lot here!

  • used by the GUI toolkits when rendering glyphs

Regarding this I was not sure what the main entry point is or how it would be used. Is one of the tests demoing the expected toolkit usage?

The main entry point is the Face.GlyphData method, with a similar API to textlayout. For instance, you should be able to use it as a drop-in replacement in the new go-text/render implementation.

There are basic tests in renderer_test.go, but no complete example (as I feel like it is outside the scope of the package).

benoitkugler commented 1 year ago

Great, thanks !