Skip to content

[skrifa] support interpreter-version 35#1496

Open
mahkoh wants to merge 3 commits intogooglefonts:mainfrom
mahkoh:jorth/iv-35
Open

[skrifa] support interpreter-version 35#1496
mahkoh wants to merge 3 commits intogooglefonts:mainfrom
mahkoh:jorth/iv-35

Conversation

@mahkoh
Copy link
Copy Markdown

@mahkoh mahkoh commented May 13, 2025

With this change, font rendering appears to be essentially identical to freetype.

Chromium compiled with this patch (and a small skia patch to use InterpreterVersion::from_environment):

image

Firefox:

image

There are some small differences but they might be caused by a different component.

I've not added any tests. Let me know if/how this should be tested.

Closes #1215

@mahkoh
Copy link
Copy Markdown
Author

mahkoh commented May 13, 2025

It might also be necessary to round the font size somewhere. Otherwise fonts with fractional pixel sizes in chromium don't render correctly.

@mahkoh
Copy link
Copy Markdown
Author

mahkoh commented May 13, 2025

I was able to fix the aforementioned issue by rounding font sizes when the interpreter version is 35. This makes chromium render text with fractional pixel sizes like firefox, that is, there is a hard jump at .5 and everything between x-0.5 and x+0.5 renders the same.

I believe that FreeType performs this rounding and that it does not depend on the interpreter version, but without interpreter-version=35 I could not easily spot the difference whereas interpreter-version=35 makes it obvious.

@dfrg
Copy link
Copy Markdown
Member

dfrg commented May 14, 2025

Thank you for taking this on! I won’t be able to do a thorough review until next week but, at a glance, the code looks good and I don’t foresee any issues with landing this in some form.

@LaurenzV
Copy link
Copy Markdown
Contributor

LaurenzV commented Jun 8, 2025

I just wanted to provide another data point for this: I just encountered a font that actually renders wrongly if hinting is disabled! If I don't enable hinting, the characters look like this, completely garbled:

image

With the current hinting mechanism, they look slightly better but still wrong:
image

With your patch, they look correct:
image

So this would definitely be nice having. :)

@tarko
Copy link
Copy Markdown

tarko commented Jun 8, 2025

For others, who arrive here looking for solution how to make font rendering beautiful again in Chrome 136+, now that the flags used to disable Fontation have been deprecated - you can still use google-chrome --disable-features=FontationsLinuxSystemFonts

This disables fontation and falls back to freetype so FREETYPE_PROPERTIES="truetype:interpreter-version=35" is respected again.

@dfrg
Copy link
Copy Markdown
Member

dfrg commented Jun 8, 2025

I just wanted to provide another data point for this: I just encountered a font that actually renders wrongly if hinting is disabled! If I don't enable hinting, the characters look like this, completely garbled:

I believe this is #1303. For Skia/Chrome, we check the result of the require_interpreter() method and set the hinting target to Mono when that returns true. The result is very similar to the v35 interpreter.

@LaurenzV
Copy link
Copy Markdown
Contributor

LaurenzV commented Jun 8, 2025

Ah interesting, will try that!

EDIT: Okay, can confirm that this fixes it, thanks for the hint!

Comment thread skrifa/src/outline/hint.rs
@drott
Copy link
Copy Markdown
Contributor

drott commented Jun 25, 2025

For others, who arrive here looking for solution how to make font rendering beautiful again in Chrome 136+, now that the flags used to disable Fontation have been deprecated - you can still use google-chrome --disable-features=FontationsLinuxSystemFonts

Note that this option is removed after 139.0.7258 https://chromiumdash.appspot.com/commit/2fc1ae192a45eb6f1716e232dd1626317f8d299e
We no longer intend to carry the FreeType support.

See https://crbug.com/349952802 and reasoning in https://developer.chrome.com/blog/memory-safety-fonts#why_replace_freetype

@mahkoh
Copy link
Copy Markdown
Author

mahkoh commented Jun 26, 2025

Then lot's hope this PR gets reviewed and merged until then.

I'll be out of the office during August so ideally that would happen before then.

@tarko
Copy link
Copy Markdown

tarko commented Jun 26, 2025

yes please

@drott, moving on from freetype is certainly good idea but don't leave us hanging here :)

@mahkoh
Copy link
Copy Markdown
Author

mahkoh commented Aug 23, 2025

Ping

@valadaptive
Copy link
Copy Markdown
Contributor

It looks like this is still failing CI for the reason I mentioned above. I've made a PR to your PR which should fix it.

@mahkoh
Copy link
Copy Markdown
Author

mahkoh commented Aug 24, 2025

I've merged your change but I don't think that is what has kept this PR from being reviewed.

@rsheeter
Copy link
Copy Markdown
Collaborator

I don't think that is what has kept this PR from being reviewed

Apologies, will ask internally.

@rsheeter
Copy link
Copy Markdown
Collaborator

https://issuetracker.google.com/issues/415076053 is marked WontFix, which I take to mean Chrome doesn't intend to work on this. Given that is there still a reason to land this?

@valadaptive
Copy link
Copy Markdown
Contributor

#1215 is still open. I believe various API consumers in the Rust text ecosystem also want this hinting style (e.g. dfrg/swash#96).

This PR doesn't seem to introduce that much new code to test; it seems to be a few new branches in what is already a straight port of FreeType code. How much would it cost in code review time and ongoing maintenance burden?

@tarko
Copy link
Copy Markdown

tarko commented Aug 25, 2025

https://issuetracker.google.com/issues/415076053 is marked WontFix, which I take to mean Chrome doesn't intend to work on this. Given that is there still a reason to land this?

Doesn't it automatically fix it for chrome when it lands in fontations?

@rsheeter
Copy link
Copy Markdown
Collaborator

How much would it cost in code review time and ongoing maintenance burden?

Little but not zero is probably fair?

Doesn't it automatically fix it for chrome when it lands in fontations?

I am under the impression Chrome would need code to activate it before it would do anything.

@kevina
Copy link
Copy Markdown

kevina commented Aug 25, 2025

https://issuetracker.google.com/issues/415076053 is marked WontFix, which I take to mean Chrome doesn't intend to work on this. Given that is there still a reason to land this?

It looks like the reason that issue was closed was because the author did not provide a justification for honoring FREETYPE_PROPERTIES=truetype:interpreter-version=35:

we no longer honor FREETYPE_PROPERTIES= - however, we do still take into account FontConfig rendering settings that are configured on the system.

What is the specific rendering issue you're trying to address with the FREETYPE_PROPERTIES environment variable? I suggest to file a specific issue for that.

@mahkoh
Copy link
Copy Markdown
Author

mahkoh commented Aug 26, 2025

I am under the impression Chrome would need code to activate it before it would do anything.

Skia needs to call the function to load the interpreter version from the environment.

@mahkoh
Copy link
Copy Markdown
Author

mahkoh commented Aug 26, 2025

#1215 is still open. I believe various API consumers in the Rust text ecosystem also want this hinting style (e.g. dfrg/swash#96).

Vscode has also reverted the switch to fontations on their end due to the changed font rendering (linked above). So it's not just other rust code but also downstream from chromium.

@tarko
Copy link
Copy Markdown

tarko commented Aug 26, 2025

Electron due to chromium is also affected ofc, thats why I run slack and signal-desktop with --disable-features=FontationsLinuxSystemFonts as well

@dfrg
Copy link
Copy Markdown
Member

dfrg commented Aug 26, 2025

Both the vscode and swash issues seem unrelated to the v35 interpreter. In the vscode case, this appears to be lack of support for embedded bitmaps. For swash, there is no way to request the monochrome hinting target and we don’t have a bi-level scanline converter with dropout control.

@mahkoh
Copy link
Copy Markdown
Author

mahkoh commented Sep 23, 2025

Ping

@mahkoh
Copy link
Copy Markdown
Author

mahkoh commented Nov 29, 2025

Could you please review this? It's only +234 −53 so it should not be that much work. The code is almost a 1-to-1 copy of the corresponding freetype code and can mostly be checked by comparing the two sources.

It would be one thing if you had said from the start that you don't want this. But instead you encouraged people that this is something that you supported.

I just don't want to have to have to recompile chromium just to get back the font rendering that I've enjoyed for the past 15 years.

@tarko
Copy link
Copy Markdown

tarko commented Nov 29, 2025

Yes, please

@zaafonin
Copy link
Copy Markdown

Please consider this. Electron apps like VSCode suffer because of new font rendering.

@angristan
Copy link
Copy Markdown

Hate to do it but bumping this, font rendering is so painful right now 😢

@S0yKaf
Copy link
Copy Markdown

S0yKaf commented Apr 15, 2026

Hello? It's been almost a year.

@insilications
Copy link
Copy Markdown

Please consider reviewing this change...

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.

skrifa: Ability to enable horizontal hinting