JDK-8180613 : Layout is incorrect for rotated text
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 9
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_10
  • Submitted: 2017-05-18
  • Updated: 2021-07-19
  • Resolved: 2021-07-19
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.
Other
tbdResolved
Related Reports
Duplicate :  
Description
Text layout for a font with rotation transform produces incorrect results.
Here's a small program that demonstrates the issue:

import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import javax.swing.WindowConstants;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.font.GlyphVector;
import java.awt.geom.AffineTransform;

public class FontLayoutDrawingTest {
    public static void main(String[] args) {
        SwingUtilities.invokeLater(() -> {
            JFrame frame = new JFrame();
            frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
            frame.add(new MyComponent());
            frame.setSize(200, 200);
            frame.setVisible(true);
            frame.setLocationRelativeTo(null);
        });
    }

    private static class MyComponent extends JComponent {
        @Override
        protected void paintComponent(Graphics g) {
            Font font = new Font(Font.SERIF, Font.PLAIN, 30).deriveFont(AffineTransform.getQuadrantRotateInstance(1));
            char[] text = new char[] {'A', 'B'};
            Graphics2D g2d = (Graphics2D) g;
            GlyphVector gv = font.layoutGlyphVector(g2d.getFontRenderContext(), text, 0, text.length, Font.LAYOUT_LEFT_TO_RIGHT);
            g2d.drawGlyphVector(gv, 80, 50);
        }
    }
}

Running it using Java 8, produces expected result (RotatedLayout-java8.png). With Java 9, letters are overlapping on rendering (RotatedLayout-java9.png). Switching to ICU layout engine (by adding -Dsun.font.layoutengine=icu command line option) produces correct result.
Comments
Gone since JDK 17 b24 which has the fix for JDK-8256372
19-07-2021