SerCeMan / fontogen

Hey, Computer, Make Me a Font
https://serce.me/posts/02-10-2023-hey-computer-make-me-a-font
MIT License
442 stars 26 forks source link

Use uharfbuzz to extract glyph shapes #5

Closed simoncozens closed 10 months ago

simoncozens commented 10 months ago

This uses uharfbuzz instead of fontTools to extract the glyph outlines. You'll want to do this for two reasons:

1) It's really fast. 2) It gives you easy access to setting variations, and getting outlines with OT variations applied.

This second point means that you can easily create a large number of "fonts" from a single variable font. I've decided to use normalised variation coords (-1..1 for each axis) since it's easier to generate these than to have to grovel through the fvar table for the appropriate user-space range.

simoncozens commented 10 months ago

Oh, you'll need to regenerate the Pipfile.lock yourself since for some reason my environment was complaining about the install.

behdad commented 10 months ago

While I support using uharfbuzz to speed up drawing, I want to point out that TTFont.getGlyphSet also takes a location argument to support variable fonts.

Also, maybe make the draw-funcs a singleton, instead of creating for each instance.

behdad commented 10 months ago

This is great change, specially because of the speedup.

2. It gives you easy access to setting variations, and getting outlines with OT variations applied.

This in fact is possible with fontTools. You can pass location to font.getGlyphSet().