Skip to content

Conversation

@tbodt
Copy link

@tbodt tbodt commented Aug 28, 2025

This font property means that the glyphs must be skewed in the renderer.

This font property means that the glyphs must be skewed in the renderer.
@laurmaedje
Copy link
Member

laurmaedje commented Aug 28, 2025

Do you have any links to the OpenType spec that say that this is how the italicAngle parameter from the post table should be interpreted? It is my understanding that this is purely metadata and that italics must be baked into the outline data to have an effect on rendering.

@tbodt
Copy link
Author

tbodt commented Aug 28, 2025

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

@laurmaedje
Copy link
Member

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.

@laurmaedje
Copy link
Member

I think I'd consider this a ttf-parser bug, especially since skrifa just factors it in.

@LaurenzV
Copy link

Yep, agreed.

@tbodt
Copy link
Author

tbodt commented Aug 28, 2025

That makes much more sense

@tbodt tbodt closed this Aug 29, 2025
@laurmaedje
Copy link
Member

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.

@tbodt
Copy link
Author

tbodt commented Aug 29, 2025

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?

@LaurenzV
Copy link

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.

@tbodt
Copy link
Author

tbodt commented Aug 31, 2025

Yes after further gazing at skrifa code it is actually doing that (in a very roundabout way)

@LaurenzV
Copy link

I think the reasons for this are:

  1. skrifa also supports outlinining at a specific font size, while ttf-parser always uses units per em.
  2. skrifa also supports hinting.
  3. skrifa tries to maintain compatibility with FreeType, so some.

So a lot more code to basically achieve the same thing.

tbodt added a commit to tbodt/ttf-parser that referenced this pull request Sep 2, 2025
Some fonts use the shear part of this matrix to do an oblique version.

See discussion at typst/pixglyph#3
@tbodt
Copy link
Author

tbodt commented Sep 2, 2025

harfbuzz/ttf-parser#198

tbodt added a commit to tbodt/ttf-parser that referenced this pull request Sep 2, 2025
Some fonts use the shear part of this matrix to do an oblique version.

See discussion at typst/pixglyph#3
tbodt added a commit to tbodt/ttf-parser that referenced this pull request Sep 4, 2025
Some fonts use the shear part of this matrix to do an oblique version.

See discussion at typst/pixglyph#3
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