-
Bug
-
Resolution: Fixed
-
P3
-
6
-
b28
-
generic
-
generic
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2160829 | 6u10 | Philip Race | P3 | Resolved | Fixed | b22 |
JDK-2194427 | OpenJDK6 | Philip Race | P3 | Resolved | Fixed | b20 |
The program below shows that when a font has a transformation such
that it includes a rotation and translation component, that TextLayout
and drawString disagree on the rendering location for that text.
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import javax.swing.*;
import java.util.HashMap;
import java.awt.font.*;
import java.awt.event.*;
public class txbug extends Component {
public Dimension getPreferredSize() {
return new Dimension(500, 300);
}
public void paint(Graphics g) {
Graphics2D g2d = (Graphics2D)g;
int x=130, y=130;
String s = "Text";
Font fnt = new Font("SansSerif", Font.PLAIN, 60);
g.setFont(fnt);
int xt=50, yt=90;
AffineTransform aff = AffineTransform.getTranslateInstance(xt, yt);
aff.rotate(90.0 * Math.PI/180.0);
g.drawLine(x+xt-10, y+yt-10, x+xt+10, y+yt+10);
g.drawLine(x+xt+10, y+yt-10, x+xt-10, y+yt+10);
fnt = fnt.deriveFont(Font.PLAIN, aff);
g.setFont(fnt);
g.setColor(Color.blue);
g.drawString(s, x, y);
g.setColor(Color.red);
FontRenderContext frc = g2d.getFontRenderContext();
HashMap attrMap = new HashMap();
attrMap.put(TextAttribute.STRIKETHROUGH,
TextAttribute.STRIKETHROUGH_ON);
fnt = fnt.deriveFont(attrMap);
TextLayout tl = new TextLayout(s, fnt, frc);
tl.draw(g2d, (float)x, (float)y);
}
public static void main(String[] args) {
JFrame f = new JFrame("Rotated font with translation");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().add(new txbug());
f.setSize(600, 400);
f.setLocationRelativeTo(null);
f.setVisible(true);
}
}
that it includes a rotation and translation component, that TextLayout
and drawString disagree on the rendering location for that text.
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import javax.swing.*;
import java.util.HashMap;
import java.awt.font.*;
import java.awt.event.*;
public class txbug extends Component {
public Dimension getPreferredSize() {
return new Dimension(500, 300);
}
public void paint(Graphics g) {
Graphics2D g2d = (Graphics2D)g;
int x=130, y=130;
String s = "Text";
Font fnt = new Font("SansSerif", Font.PLAIN, 60);
g.setFont(fnt);
int xt=50, yt=90;
AffineTransform aff = AffineTransform.getTranslateInstance(xt, yt);
aff.rotate(90.0 * Math.PI/180.0);
g.drawLine(x+xt-10, y+yt-10, x+xt+10, y+yt+10);
g.drawLine(x+xt+10, y+yt-10, x+xt-10, y+yt+10);
fnt = fnt.deriveFont(Font.PLAIN, aff);
g.setFont(fnt);
g.setColor(Color.blue);
g.drawString(s, x, y);
g.setColor(Color.red);
FontRenderContext frc = g2d.getFontRenderContext();
HashMap attrMap = new HashMap();
attrMap.put(TextAttribute.STRIKETHROUGH,
TextAttribute.STRIKETHROUGH_ON);
fnt = fnt.deriveFont(attrMap);
TextLayout tl = new TextLayout(s, fnt, frc);
tl.draw(g2d, (float)x, (float)y);
}
public static void main(String[] args) {
JFrame f = new JFrame("Rotated font with translation");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().add(new txbug());
f.setSize(600, 400);
f.setLocationRelativeTo(null);
f.setVisible(true);
}
}
- backported by
-
JDK-2160829 Incorrect handling of translation component of font transform.
- Resolved
-
JDK-2194427 Incorrect handling of translation component of font transform.
- Resolved
- relates to
-
JDK-6687298 Reg testcase java/awt/Graphics2D/DrawString/RotTransText.java fails in windows in pit build 6u10 b22
- Closed