-
Notifications
You must be signed in to change notification settings - Fork 10
Correctly render fonts that have italic_angle set #3
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
Conversation
This font property means that the glyphs must be skewed in the renderer.
|
Do you have any links to the OpenType spec that say that this is how the italicAngle parameter from the |
|
Somehow I'm having trouble even finding the relevant part of freetype code, but there's clearly something going on here. I tested by comparing PDF and PNG output. Here's a typst.app demo, the preview rendered as png is wrong but the pdf download appears right: https://typst.app/project/rJvhfkyHUXchKZUXKhEXNz |
|
I think I know what's going on. It's not the italic_angle from the post table that is taken into account by other renderers. It's the FontMatrix from the CFF font embedded in the OpenType container. You can see it here in skrifa. |
|
I think I'd consider this a ttf-parser bug, especially since skrifa just factors it in. |
|
Yep, agreed. |
|
That makes much more sense |
|
In the medium term, we'll probably migrate to skrifa, but not sure when. Regardless, it would imo make sense for this to be fixed in ttf-parser, in case you want to make a PR upstream at https://github.com/harfbuzz/ttf-parser/ and then we can bump here. |
|
The skrifa code is confusing me about the interaction between units_per_em and the transform. Univers has units-per-em 1000 and font matrix "0.001 0 0.000212557 0.001 0 0". It looks like Outlines::subfont() will generate a Subfont with scale: size * 0.001 based on units_per_em, but then ScalingTransformingSink will first apply the font matrix, which itself has a scale of 0.001, then also multiply by the scale, which seems like it would apply the 0.001 scale a second time. What am I missing? |
|
I’m not sure honestly, my guess would have been that you multiply the font matrix by the upend value (so by default you have 1000 * (0.001 0 0 0.001 0 0) which yields the identity matrix, but not sure. |
|
Yes after further gazing at skrifa code it is actually doing that (in a very roundabout way) |
|
I think the reasons for this are:
So a lot more code to basically achieve the same thing. |
Some fonts use the shear part of this matrix to do an oblique version. See discussion at typst/pixglyph#3
Some fonts use the shear part of this matrix to do an oblique version. See discussion at typst/pixglyph#3
Some fonts use the shear part of this matrix to do an oblique version. See discussion at typst/pixglyph#3
This font property means that the glyphs must be skewed in the renderer.