JDK-8350203 : [macos] Newlines and tabs are not ignored when drawing text to a Graphics2D object
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 23,24,25
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2025-02-17
  • Updated: 2025-05-21
  • Resolved: 2025-05-13
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 25
25 b23Fixed
Related Reports
Blocks :  
Causes :  
Relates :  
Description
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.
Comments
The Linux ppc64le machine is Linux RHEL 8.5 . So it is not only something that is seen on SUSE 15.X . I created https://bugs.openjdk.org/browse/JDK-8356966 .
14-05-2025

[~mbaesken] Seems like it might be distribution-specific. Is the Linux ppc64le box also SLES 15.3?
14-05-2025

The new test java/awt/Graphics2D/DrawString/IgnoredWhitespaceTest fails now on Linux in our nightly tests; should we maybe make the test macOS only for now until the Linux issues are sorted out ? We see failures on Linux x86_64 (SLES15.3 machine), but also on Linux ppc64le . Example Failure : ----------System.out:(0/0)---------- ----------System.err:(14/1181)*---------- java.lang.RuntimeException: for text '\\t\\t\\t\\t\\tXXXXX': java.awt.Rectangle[x=300,y=273,width=119,height=26] != java.awt.Rectangle[x=356,y=273,width=119,height=26] at IgnoredWhitespaceTest.assertEqual(IgnoredWhitespaceTest.java:126) at IgnoredWhitespaceTest.test(IgnoredWhitespaceTest.java:96) at IgnoredWhitespaceTest.test(IgnoredWhitespaceTest.java:69) at IgnoredWhitespaceTest.main(IgnoredWhitespaceTest.java:62) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104) at java.base/java.lang.reflect.Method.invoke(Method.java:565) at com.sun.javatest.regtest.agent.MainWrapper$MainTask.run(MainWrapper.java:138) at java.base/java.lang.Thread.run(Thread.java:1447)
14-05-2025

Changeset: 85db4631 Branch: master Author: Daniel Gredler <dgredler@openjdk.org> Committer: Alexey Ivanov <aivanov@openjdk.org> Date: 2025-05-13 10:37:57 +0000 URL: https://git.openjdk.org/jdk/commit/85db4631ae5208fba74fa8b8638c32d4e42d3268
13-05-2025

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk/pull/23665 Date: 2025-02-17 14:06:53 +0000
17-02-2025