Skip to content
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

why build.sh uses fontmake with --no-optimize-gvar option? #40

Open
anthrotype opened this issue Sep 14, 2022 · 10 comments
Open

why build.sh uses fontmake with --no-optimize-gvar option? #40

anthrotype opened this issue Sep 14, 2022 · 10 comments

Comments

@anthrotype
Copy link

just curious why you decided to turn off the gvar IUP optimization? Is it for speed or does it create issues somewhere else?

@justvanrossum
Copy link
Owner

It creates subtle rendering issues with a EHLT value of 0: the highlight outlines should reduce to an infinitely thin line, but with IUP optimization there are tiny differences, making the highlight path not disappear completely.

@justvanrossum
Copy link
Owner

image

See the super thin but visibly noisy white line on the edge. It's completely gone if I don't do IUP optimization.

@anthrotype
Copy link
Author

Interesting... /cc @behdad @drott @rsheeter

@behdad
Copy link

behdad commented Sep 14, 2022

Very interesting and bizarre. I'll try to reproduce.

Just checking, what rasterizer is that renderer using? FreeType?

@justvanrossum
Copy link
Owner

justvanrossum commented Sep 14, 2022

I don't really know if it's FreeType: the screenshot is from Chrome on macOS. But I get the same (or similar) artifacts when extracting the outlines with fonttools, and similar (but likely different) artifacts when using the harfbuzz draw API via FontGoggles.

This is zooming in on the middle stroke of E.highlight in Fontra (which uses the new fonttools var glyph set):

Screen.Recording.2022-09-14.at.18.38.02.mov

It looks like the IUP points are not rounded to the unit grid, and we get ever so slightly different rounding errors

Here is the Nabla font with the IUP optimization on: Nabla[EDPT,EHLT]_IUP.ttf.zip

Check the E.highlight glyph with the EHLT axis set to 0.

@behdad
Copy link

behdad commented Sep 14, 2022

It looks like the IUP points are not rounded to the unit grid, and we get ever so slightly different rounding errors

Interesting. Yes, that would explain this. I wonder if the spec should say IUP results are rounded to grid...

Alternatively you can try changing the tolerance in varLib init add_gvar to 0 instead of .5; that should fix this but significantly reduce effectiveness of IUP.

@behdad
Copy link

behdad commented Sep 14, 2022

cc @PeterCon

@justvanrossum
Copy link
Owner

(Looking closer: I think one off-curve point is IUP optimized, and its counterpart isn't.)

Note that the distance between those off curve points (which should ideally be zero) is far less than one unit. I estimate between 1/4th and 1/3rd unit.

I don't think anything is broken here, and this is an edge case, and I'm 100% happy with turning off the optimization for this font.

Turning on IUP optimization makes the font about 10KB smaller, but at about 550KB total file size, I'm not sure I care.

@PeterConstable
Copy link

I gather this issue arises for many (or most?) glyphs in the font?

@behdad
Copy link

behdad commented Sep 14, 2022

Turning on IUP optimization makes the font about 10KB smaller, but at about 550KB total file size, I'm not sure I care.

Yeah in general I've found the IUP optimization to have such a small win (2 to 3%, as you observe).

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

No branches or pull requests

4 participants