Add runtime control for SK_FONT_HOST_USE_SYSTEM_SETTINGS#14
Conversation
…ttings like in SkiaSharp
|
Hi @tonsky! I was able to reach near-complete parity for primitive rendering. However, there is still an important issue with text rendering. During my investigation I found differences related to how gamma correction is handled. I understand that this is a rather specific area, but I would really appreciate it if you could update the current experimental m119 branch to include/support this setting. Thanks. |
|
As much as I value consistency, it sounds like we want SK_FONT_HOST_USE_SYSTEM_SETTINGS? In the sense that I want text rendered in Skia apps to match text seen in other areas of Windows. Think about it from user's perspective: user can see inconsistencies between native apps and skia apps, but they can't see inconsistencies between e.g. different versions of windows/different monitor settings. Yes, that means that Skia rendering output is system-dependent, but for a good reason?Unless I misunderstood something? |
|
You're right about the user-facing consistency argument, and I agree it's more important in general. As a possible middle ground — we could expose this as a runtime option on the native side: This would require a small patch to SkTypeface_win_dw.cpp in the Skia source, but it's minimal and self-contained. This way the default behavior stays as-is and matches Windows native rendering, while apps that need cross-wrapper consistency or machine-independent visual testing can explicitly opt out. |
|
I like that! |
|
Thanks! Building... |

Problem
When
SK_FONT_HOST_USE_SYSTEM_SETTINGSis defined at compile time, Skia readsgamma and contrast from Windows ClearType settings via DirectWrite API. While this
makes text match native Windows rendering, it introduces two issues:
(e.g. SkiaSharp) that are built without this flag will produce visually different
text on the same machine
one machine and fail on another due to different ClearType settings
Solution
Instead of removing
SK_FONT_HOST_USE_SYSTEM_SETTINGS(which would change thedefault behavior), this PR exposes it as a runtime option via a small patch to
SkTypeface_win_dw.cpp:This preserves the existing default behavior while allowing callers to opt out
when needed.
Testing
Verified pixel-level output matches SkiaSharp on the same machine after removing the flag.


Below is an outdated attempt at a solution
Remove
SK_FONT_HOST_USE_SYSTEM_SETTINGSflag on WindowsProblem
Text rendered via Skija produces slightly different antialiasing compared to other Skia wrappers (e.g. SkiaSharp) even when using the same Skia version (m119), same font, same size, and same paint settings. The difference is visible at the pixel color level in subpixel intensity of glyph edges.
Root Cause
The Windows build configuration included
-DSK_FONT_HOST_USE_SYSTEM_SETTINGSinextra_cflags. When this flag is defined, Skia reads gamma and contrast values from the system via the DirectWrite API (IDWriteRenderingParams):Without this flag, Skia uses its own hardcoded defaults (gamma ~1.4), which is consistent with the behavior of other wrappers and produces identical rendering across environments regardless of per-machine Windows ClearType settings.
Effect of the flag
Change
Removed
-DSK_FONT_HOST_USE_SYSTEM_SETTINGSfrom Windows build args inscript/build.py.