-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
KeyError: 'glyf' when trying to convert Gilbert font to COLR #435
Comments
thanks for trying out our tools! I think maximum_color is assuming that the input font already contains a "glyf" table, but in your case it only has the "SVG " table, is that correct? |
the error because of spaces in the filename is a bit embarassing, will get that fixed as well 😅 |
Hm so, yeah, yours is a CFF-flavored opentype font (.otf) so it does not contain any "glyf" table, only "CFF ", with the outlines of the black-&-white only glyphs. In the meantime, I suggest you do this. Convert your CFF-flavored opentype font to a TrueType-flavored one (.ttf), so it will have "glyf" instead of "CFF ". You can use this otf2ttf.py script in fonttools/Snippets directory.
|
Many thanks for the hints! I converted the font to a ttf as you mentioned and indeed the final output seems to work in both Firefox and Chromium. And when stored as a woff2, the file size difference is quite small (102kb vs 96kb). |
Cool! Is that FireFox Nightly? |
is the 102kb the one that contains both SVG and COLRv1? |
No, it is Firefox 104.0.2 (and Chromium 105.0.5195.125).
Yes, I'd assume so. |
ah, ok - Firefox stable 104 is probably just reading the OT-SVG table, not the COLRv1. If you try the latest Nightly it should work with COLRv1 as well. You may not notice the difference because the two tables are suppose to look the same, but you can strip the SVG table and leave only COLR in it to check if FF Nightly loads the COLRv1 table (e.g. |
Indeed. Without the SVG table, the file size becomes 41kb as a woff2 and doesn't work in Firefox stable anymore. So I will stay with the larger file for a while and switch to COLR-only once it is supported in all browsers. |
By the way, your font doesn't use gradients, only flat colors with transparency, it could also be encoded as a COLR version 0, and that should make it work almost everywhere, so you might not even need to provide both an SVG and a COLR version 1 table. |
maybe i'll add an option to maximum_color to make it create a COLRv0 from a suitable OT-SVG font like yours |
I have a quick WIP patch to allow converting your OT-SVG font to COLRv0, it's not ready to merge yet https://github.com/googlefonts/nanoemoji/compare/otsvg-to-colrv0?expand=1 with this, I was able to add a COLRv0 to your font (the .ttf variant), then after stripping the SVG table from it using ttx, I get an uncompressed .ttf file of 109KB, after woff2 compression it gets down to 33KB. Not bad! |
i just noticed that that your font doesn't actually contain any transparency, if I grep for "opacity" I get nothing among the .svg files extracted from the OT-SVG table. In fact the colors in the CPAL table generated by maximum_color end all with |
Okay, I can reproduce all of this and indeed the 33KB COLRv0-only file works fine in both Firefox and Chromium. BTW @Theelx, you might be interested in this as you also mentioned using this font in this repository (#380) |
ah thanks, that's ok, sorry I thought you were the author of the fonts :) |
Okay, I think I have summarized everything at https://github.com/Findus23/RainbowRoad/tree/main/src/font Thanks again for all the help! |
Thanks so much for the ping! I made a workaround myself, but it only worked for some of the characters because of reasons I can't remember, so I didn't publish it. I'm ecstatic that you seem to have gotten it to work though! |
To support generatinv COLRv0 from OT-SVG font. Fixes #435
To support generating COLRv0 from OT-SVG font. Fixes #435
@Findus23 FYI, I fixed the bug with spaces in filenames #442 and added a --colr_version flag to maximum_color (so one can select version 0 instead of the default version 1) in #443. I filed a separate #444 for tracking support for CFF-flavored OT-SVG, but won't work on it immediately as there's the otf2ttf.py workaround. |
Hi,
I wanted to convert the Gilbert font from https://www.typewithpride.com/ to COLRv1 so that it also works in Chrome.
The default file name of
Gilbert-Color Bold Preview5.otf
seems to fail because of the spaces in the name.But even after renaming the file, I can't seem to get it to work with
maximum_color /path/to/test.otf
:The text was updated successfully, but these errors were encountered: