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

Visual differences in autohinting, more pronounced at fractional font sizes #1097

Closed
drott opened this issue Aug 19, 2024 · 2 comments
Closed
Assignees

Comments

@drott
Copy link
Contributor

drott commented Aug 19, 2024

In this Skia CL #890696 I am experimenting with hooking up the autohinting preview #1083.

This should now create an autohinting instance when Skia's hinting is set to kSlight or when it is set to normal or full and force autohinting is on.

First of all: Results are looking good, I think autohinting gets successfully activated, and vertical differences are reduced compared to no autohinting active in Fontations. Bottom and top crossbars / feet of glyph shapes are aligned with the pixel grid and appear sharper. 👍

Depending on font size, I do notice some differences to FreeType in GM_fontations_compare_ft_NotoSans.

With Noto Sans Regular, at scaled font size 24, there is a pixel positioning difference in the top part of the bowl of the lowercase a.

1st column: Fontations, 2nd column: FreeType, 3rd column: diff

Scale size 24:

image

The upper part of the bowl of the a seems to be somewhat squished and too thin in FreeType. The thickness of the top part seems to be better maintained in Fontations.

Scale size 20.531250:

image

Again, differences on the lowercase a, but more importantly, Fontations and FreeType disagree on the placement of the top bar of the T, and the top pixel of the A and L by one pixel:

image

In the FreeType case, this compresses the distinction between lowercase and uppercase a bit?

@dfrg Curious to hear your thoughts on:

  • Are there resolution differences in the internal computations?
  • What might be the cause of these differences?
  • Do you observe these in your testing?
@rsheeter rsheeter added this to the Skrifa for Chrome milestone Aug 19, 2024
@dfrg
Copy link
Member

dfrg commented Aug 29, 2024

Thanks for taking the time to experiment with autohinting integration. Results like these are really useful in refining the implementation.

First, I haven't done any large scale testing yet. Glyphs that are not assigned to a specific script/style fall back to the CJK algorithm which isn't complete, so we'd essentially fail any font-wide comparison on the notdef glyph.

For a first pass, the intention is to match FreeType exactly so any variance can be considered a bug, a few of which seem to be on display here :) While I agree that the bowl of our lowercase 'a' looks slightly better in isolation, Raph pointed out that it no longer aligns with the crossbar of the uppercase 'A' which seems generally undesirable if we want to preserve visual consistency.

The height difference in the fractional scaling is surprising. My assumption is that we were computing fixed point scaling factors differently, but having just looked through the Skia code, I believe the computation is identical. It ultimately boils down to fixed_div(int(ppem * 64.0), upem) in both Skia/FreeType and Skrifa from what I can tell. There might be a difference in how we derive an integral ppem from these values and that could affect the results.

As a next step, I'll take a look at Noto Sans and see if I can identify where we're going wrong here.

@drott
Copy link
Contributor Author

drott commented Sep 30, 2024

Fixed by #1145.

@drott drott closed this as completed Sep 30, 2024
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

3 participants