Issue: When we render text using a TrueTypeFont and LCD mode, the rendered text is corrupted with Metal pipeline on macOS.
Root cause: When FreeType rasterizes the LCD glyphs for TrueTypeFont it adds padding bytes https://github.com/openjdk/jdk/blob/master/src/java.desktop/share/native/libfontmanager/freetypeScaler.c#L1033. So glyph width and rowBytes are not same, and when we convert this LCD Glyph into BGRA data in MTLTextRenderer.m we are not considering this padding and it corrupts the text. Fix: Use rowBytes information instead of width for LCD glyph and fill BGRA data with proper offsets. I have also removed initialization of BGRA array to 0, because we fill these arrays completely without any conditions. Initially i was thinking of manual test but using already present 'A.ttf' test font file in JDK, i am able to capture this LCD text corruption and create an automated test. I have kept this test generic and to run on default pipeline on all platforms, if not needed i can make the test macOS and Metal specific. The generic test runs fine in CI pipeline. --------- - [x] I confirm that I make this contribution in accordance with the [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai). ------------- Commit messages: - 8349701: TrueType fonts are rendered incorrectly in VolatileImage with Metal Changes: https://git.openjdk.org/jdk/pull/32651/files Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=32651&range=00 Issue: https://bugs.openjdk.org/browse/JDK-8349701 Stats: 143 lines in 3 files changed: 122 ins; 18 del; 3 mod Patch: https://git.openjdk.org/jdk/pull/32651.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/32651/head:pull/32651 PR: https://git.openjdk.org/jdk/pull/32651
