RFR: 8350203: [macos] Newlines and tabs are not ignored when drawing text to a Graphics2D object

Daniel Gredler dgredler at openjdk.org
Mon Feb 17 14:13:06 UTC 2025


On other platforms like Windows and Linux, the `\n`, `\r` and `\t` characters are ignored when drawing text to a `Graphics2D` object. On macOS this is not currently the case.

See, for example, `CMap.getControlCodeGlyph(int, boolean)` or `RasterPrinterJob.removeControlChars(String)`.

This bug was found while running `test/jdk/java/awt/print/PrinterJob/PrintTextTest.java` on macOS.

The new test class passes on Linux, Windows and macOS.

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

Commit messages:
 - Make Graphics2D.drawString ignore tabs and newlines on macOS
 - Add actual bug ID
 - Add ignored whitespace test

Changes: https://git.openjdk.org/jdk/pull/23665/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=23665&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8350203
  Stats: 193 lines in 2 files changed: 191 ins; 0 del; 2 mod
  Patch: https://git.openjdk.org/jdk/pull/23665.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/23665/head:pull/23665

PR: https://git.openjdk.org/jdk/pull/23665


More information about the client-libs-dev mailing list