Skip to content

Some hacks for CFF support (and other things) in maximum_color - #489

Draft
skef wants to merge 1 commit into
googlefonts:mainfrom
skef:cffhacks
Draft

skef wants to merge 1 commit into
googlefonts:mainfrom
skef:cffhacks

Conversation

@skef

@skef skef commented Dec 4, 2025

Copy link
Copy Markdown

This isn't a real PR. I wound up needing to convert a CFF-based SVG font to COLRv1 and these were the various hacks I used to build it with nanoemoji. I'm just sharing this in case it may come in handy. Some of the changes would work as-is but some just overwrite the glyf path (especially in glue_together) because I was just trying to get something done.

I don't know what's going on with the ascender_override stuff. The extractor was writing in 750 where what was needed was -250. I don't know if that's a CFF-specific thing, something to do with the encoding of the SVGs in the font, or something else.

I also had to deal with some out of bounds gradients. Could be a problem with the source data, not sure.

The underlying problem here, and most likely the reason CFF wasn't supported all the way through in the first place, is the brittleness and decentralization of the fontTools cffLib structures. This is in stark contrast to how the same structures are represented in ttx XML. It would be nice if there were an edit-oriented model one could switch between, possibly based on the XML hierarchy.

@rsheeter

rsheeter commented Dec 4, 2025

Copy link
Copy Markdown
Contributor

most likely the reason CFF wasn't supported all the way through in the first place

IIRC this is because maximum_color was pretty much written specifically for Noto Color Emoji and that doesn't ship in cff form. nanoemoji cff output should work fine afaik?

@skef

skef commented Dec 4, 2025

Copy link
Copy Markdown
Author

This may well just be my ignorance about the stack, but it wasn't obvious to me how to use nanoemoji directly when starting from a finished font. I didn't see an equivalent of the code in glue_together, for example.

My goal was to convert an SVG font to COLRv1, which is something I can imagine a number of other people wanting to do, and this seems to be the repo that gets you closest. But if what you're saying is that that workflow isn't really a goal, and maximum_color was just thrown in for incidental reasons, then that's fine.

@anthrotype

Copy link
Copy Markdown
Member

My goal was to convert an SVG font to COLRv1

that's exactly what maximum_color is for! Thanks for the PR, I'll take a look soon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants