> 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).

Jayathirth D V has updated the pull request incrementally with one additional 
commit since the last revision:

  Initialize index variable

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/32651/files
  - new: https://git.openjdk.org/jdk/pull/32651/files/4383b36d..b61cad39

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=32651&range=01
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=32651&range=00-01

  Stats: 6 lines in 1 file changed: 2 ins; 0 del; 4 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

Reply via email to