googlefonts / fontc

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

Anchor propagation #782

Closed cmyr closed 2 months ago

cmyr commented 2 months ago

This implements basic anchor propagation in glyphs-reader. Propagation happens before the conversion to IR. Handling this here lets us more closely match the behaviour of glyphs.app.

This work is based on a python rewrite of the original objc; that work (by @anthrotype) is available in a google doc.

This code is now fairly well covered by tests, and I am reasonably confident that it replicates the behaviour of the original code in at least all the obvious cases.

~The original code is tricky and handles a bunch of edge cases. Some of that is included in this, and some of that is not. In particular, this does not handle the "*origin" anchor (see #769) and it does not handle the possible presence of the "anchor" field on a component, which we do not currently parse from the source.~

~This includes some tests for the most common cases, as well as some nice infra for adding additional tests in the future. This code is branchy and complex, and there are doubtless a bunch we aren't hitting. In particular there is special logic to swap top/bottom, left/right, and entry/exit in cases where a component has a rotation applied. I'm not even really sure what the use case is here, and thus what a good test case would be, but perhaps it's for something like using a 'u' as an 'n' by just rotating a component?~

anthrotype commented 2 months ago

Thanks Colin for implementing this. I know it must not have been fun 👍