JDK-8015289 : [macosx] Rotated text is drawn to the opposite direction on Mac OS X ?
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 7
  • Priority: P3
  • Status: Resolved
  • Resolution: Duplicate
  • Submitted: 2013-05-23
  • Updated: 2014-11-17
  • Resolved: 2013-06-17
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 8
8Resolved
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
java version  " 1.7.0_21 " 
Java(TM) SE Runtime Environment (build 1.7.0_21-b12)
Java HotSpot(TM) 64-Bit Server VM (build 23.21-b01, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Mac OS X 10.7.5

A DESCRIPTION OF THE PROBLEM :
Rotated String is drawn to the opposite direction on Mac OS X.
When we rotate graphics by g.rotate(?Math.PI / 2) and g.drawString( " ABC " ),  " B "  should be drawn upper  " A " . But  " B "  is drawn under  " A " .  " C "  is drawn under the  " B " .

REGRESSION.  Last worked in version 6u45

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Run the program to test
2. Check the shown window

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
90 degrees rotated  " ABC123 "  should be shown.
ACTUAL -
Rotated  " 321CBA "  is shown at the wrong position.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;

public class RotatedStringFrame extends JFrame {
    @Override
    public void paint(Graphics g) {
        Graphics2D g2 = (Graphics2D) g;
        g2.setFont(new Font(Font.SERIF, Font.PLAIN, 24));
        g2.rotate(-Math.PI / 2.0);
        g2.drawString( " ABC123 " , -200.0f, 40.0f);
    }

    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                RotatedStringFrame frame = new RotatedStringFrame();
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                frame.setSize(200, 400);
                frame.setVisible(true);
            }
        });
    }
}

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
We can avoid this bug by using drawString(AttributedStringIterator) instead of drawString(String).