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

[skrifa] autohint bug fixes to match FT #1145

Merged
merged 4 commits into from
Sep 10, 2024
Merged

[skrifa] autohint bug fixes to match FT #1145

merged 4 commits into from
Sep 10, 2024

Conversation

dfrg
Copy link
Member

@dfrg dfrg commented Sep 9, 2024

This is a largish collection of small changes that bring the autohinter into a state where we match with FreeType for at least the Google Fonts and Noto collections.

Also updates fauntlet to use the new hinting API.

Builds on #1144 which should land first.

This is a largish collection of small changes that bring the autohinter into a state where we match with FreeType for at least the Google Fonts and Noto collections.

Also updates fauntlet to use the new hinting API.
@dfrg
Copy link
Member Author

dfrg commented Sep 9, 2024

cc @drott

Copy link
Contributor

@drott drott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see the hours that went into finding those differences, thanks for bringing this in alignment with FT. LGTM.

@@ -13,6 +15,20 @@ pub fn compare_glyphs(
// Don't run on bitmap fonts (yet)
return true;
}
if let Some(Hinting::Auto(_)) = options.hinting {
// This font is a pathological case for autohinting due to the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps add an issue reference?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do. I want to get some actual metrics from this font so we can potentially add limits to prevent this performance cliff. Beyond a certain level of geometric complexity, hinting is likely to produce useless results anyway.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, similarly we might want to disable it for COLRv1 fonts, but I can do that on the client side.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sgtm.

Filed #1147 and added a link in the comment

// Note: this is actually critical for matching FreeType in cases where
// we have more than one edge with the same fpos. When this happens,
// linear and binary searches can produce different results.
// See <https://gitlab.freedesktop.org/freetype/freetype/-/blob/57617782464411201ce7bbc93b086c1b4d7d84a5/src/autofit/afhints.c#L1489>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤯

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Took me a while to find this one :)

if group != ScriptGroup::Default {
// Divergent CJK behavior
// See <https://gitlab.freedesktop.org/freetype/freetype/-/blob/57617782464411201ce7bbc93b086c1b4d7d84a5/src/autofit/afcjk.c#L1544>
if dist < 54 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am aware these are coming from the source, but perhaps in a separate, follow-up CL, any chance we could attempt to give this bouquet of magic numbers some names, or add some comments?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’ll do the best I can. Updated #1141 to include this.

Base automatically changed from autohint_engage to main September 10, 2024 12:53
@dfrg dfrg merged commit 7799a96 into main Sep 10, 2024
10 checks passed
@dfrg dfrg deleted the autohint_bugfixes branch September 10, 2024 15:42
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.

2 participants