On Thu, 10 Sep 2026 17:47:40 GMT, Martin Fox <[email protected]> wrote:

>> This PR attempts to improve LCD text rendering on Windows and Linux. Changes 
>> include:
>> 
>> - (Windows only) When setting up DirectWrite the code now uses the 
>> NATURAL_SYMMETRIC rendering mode except for very small glyphs where it uses 
>> NATURAL. Using NATURAL_SYMMETRIC avoids distorted glyphs at specific pixel 
>> sizes (see [JDK-8389632](https://bugs.openjdk.org/browse/JDK-8389632)) and 
>> retains the curves along the top and bottom of the glyphs. Using NATURAL at 
>> small sizes avoids glyphs turning very fuzzy and light.
>> 
>> - The code is now consistently converts the colors from sRGB to a linear 
>> space (more or less), composites them, and then converts the result back to 
>> sRGB.
>> 
>> - The shader applies a contrast equation to the LCD glyph mask which helps 
>> emphasize the stems. The same equation is used by Skia and probably added by 
>> Microsoft when they cleaned up text rendering for Chromium. BTW it’s just 
>> the equation for a parabola that goes through points (0, 0) and (1, 1).
>> 
>> My testing was mostly done on a 27 inch display with a resolution of 
>> 2560x1440 and a screen scale of 150%. This was low enough to notice a 
>> difference. Resolutions higher than that (like full-on Retina) tend to hide 
>> a lot of sins.
>> 
>> I recommend reading “The Raster Tragedy in Skia” which is concise but covers 
>> a lot of ground. It contains a section on the challenges of compositing text 
>> in sRGB space and also the issues getting LCD text to look dark enough 
>> without inflating the stems. I wish I had found this earlier in the process.
>> 
>> ---------
>> - [x] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> Martin Fox has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   Added Swing version of the cascade

I have no issue with improvements to font rendering.
However I caution that it is subjective and also sensitive to use case and the 
hardware / software environment. 
System properties aren't something we'd want users to have to mess with but are 
likely very valuable in cases where someone insists the new value is "worse" .. 
if they can go back to the exact old configuration so they/we know it is 
exactly that change that made the difference. And it provides a mitigation 
option if there are any big problems.
Also people can experiment with what they prefer .. and send data back here.
I do ask that the fix includes a way to specify the DW defaults. Which can be 
both font-specific for specific sizes and rendering modes. I suspect DW reads 
the 'gasp' table, and I read last week a release note for a forthcoming 
freetype release where they added support in freetype for this.
https://gitlab.freedesktop.org/freetype/freetype/-/commit/a5a62a4df41b421dff2f9a9fe9b48b9226cc18ee

-------------

PR Comment: https://git.openjdk.org/jfx/pull/2284#issuecomment-5733565779

Reply via email to