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
[varLib.mutator] Improve CharString rounding #3481
base: main
Are you sure you want to change the base?
Conversation
Because CharString commands are relative, rounding point coordinates can result in accumulating round errors causing the last point in the contour to not match the first point, leaning to rendering artifacts. This test demonstrates this.
Since CharString point coordinates are relative, rounding each point independently can accumulate rounding errors causing to the last point to not match the first one, which leads to rendering artifacts. This is a hack to round the absolute point coordinates, but using pens to convert the relative coordinates to absolute ones and back. This is a hack since it drops hinting operators, and it can’t preserve the original operators, in addition to being slower. There is probably a more clever way to doing this.
Smells like a variant of this: #2838 |
Use AFDKO’s tx for instancing CFF2 table, to work around issues with FontTools instancer (fonttools/fonttools#3481).
I think so (here at the instancing not merging side, though). Not rounding at all works as well, but it gives larger file size and can expose bugs in implementations not prepared to handle fractional CFF coordinates. |
|
thanks for spotting this Khaled
would be nice to find out how tx manages to do this while, if I understand correctly, also preserving hinting and other operators. Maybe @skef could help undestand this? |
Note that the hints are represented with absolute positions and are (currently) in "hint substitution" style rather than "hintmask" style (for CFF variants they're translated back into hintmask style after processing). |
Since CharString point coordinates are relative, rounding each point independently can accumulate rounding errors causing to the last point to not match the first one, which leads to rendering artifacts.
This is a hack to round the absolute point coordinates, but using pens to convert the relative coordinates to absolute ones and back.
This is a hack since it drops hinting operators, and it can’t preserve the original operators, in addition to being slower.
There is probably a more clever way to doing this.