On Mon, 31 Aug 2026 16:04:47 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 manual text rendering test With the new test, I do see an improvement, especially with CJK. I've tested it in both 1920x1080 at 100% and with high dpi monitor 2560x1440 at 175%. I only looked at the system font. results for 1920x1080 at 100%: pr: <img width="962" height="392" alt="Screenshot 2026-08-31 112211 - PR" src="https://github.com/user-attachments/assets/667b3b61-dd60-4c3a-874d-318383e40294" /> master: <img width="962" height="392" alt="Screenshot 2026-08-31 113211 master" src="https://github.com/user-attachments/assets/e71e387f-c09e-49ca-857b-88a650a0701b" /> diff: <img width="1618" height="870" alt="Screenshot 2026-08-31 114055" src="https://github.com/user-attachments/assets/2077cf09-79f6-49e6-9e60-f3901ae35686" /> results for 2560x1440 at 175%: pr: <img width="1688" height="688" alt="Screenshot 2026-08-31 115010 pr 1 75" src="https://github.com/user-attachments/assets/56f9d9d6-c77d-4629-b2a6-f43719e68d20" /> master: <img width="1688" height="688" alt="Screenshot 2026-08-31 114205 master 1 75" src="https://github.com/user-attachments/assets/f26672b1-d93e-4477-8f4a-ed8e8c1b2932" /> diff: <img width="1618" height="870" alt="Screenshot 2026-08-31 115111" src="https://github.com/user-attachments/assets/d3bd177b-4cb7-497c-bcb9-e9206d0af30b" /> just for comparison, here is macOS: <img width="1042" height="472" alt="fonts-master" src="https://github.com/user-attachments/assets/807ea9e4-930e-4702-b9a3-2c7822b3dc62" /> ------------- PR Comment: https://git.openjdk.org/jfx/pull/2284#issuecomment-5483046426 PR Comment: https://git.openjdk.org/jfx/pull/2284#issuecomment-5483058753 PR Comment: https://git.openjdk.org/jfx/pull/2284#issuecomment-5483071651
