FULL PRODUCT VERSION :
Java 1.6.0_01-b06
ADDITIONAL OS VERSION INFORMATION :
Windows XP sp2
A DESCRIPTION OF THE PROBLEM :
Wrong rendering of transformed fonts on Windows with Java 6.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the example, with real transformation matrix (which was obtained after some transformation in real program). Note, that it doesn't appear with Java 1.4.2, only with Java 6.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Normal string "3 500"
ACTUAL -
Expected string with skewed numbers.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.AffineTransform;
class DrawStringTest extends Frame
{
DrawStringTest(String s)
{
super(s);
setBounds(0, 0, 500, 300);
setVisible(true);
}
public void paint(Graphics g)
{
Font f = new Font("Dialog", Font.PLAIN, 12);
String s1 = "3 500";
AffineTransform tr = new AffineTransform();
double[] m = new double[6];
tr.getMatrix(m);
//m00 m10 m01 m11 m02 m12
m[0] = 0.8749999999999999;
m[1] = 0.0;
m[2] = 0.0;
m[3] = 0.875;
m[4] = 5.675000000000001;
m[5] = 107.11192516891774;
/*m[0] = 0.875;
m[1] = 0.0;
m[2] = 0.0;
m[3] = 0.875;
m[4] = 7.0;
m[5] = 107.11192516891774;*/
tr = new AffineTransform(m);
g.setFont(f);
((Graphics2D)g).transform(tr);
g.drawString(s1, 0, 0);
}
public static void main(String[] args)
{
DrawStringTest f = new DrawStringTest("DrawStringTest");
f.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent ev){
System.exit(0);}
});
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
"Rounding" of transformation matrix, like:
double[] m = new double[6];
_graphics.getTransform().getMatrix(m);
for (int i = 0; i < 6; i ++)
m[i] = (double)Math.round(m[i]*1000000000)/1000000000;
_graphics.setTransform(new AffineTransform(m));
Release Regression From : 5
The above release value was the last known release where this
bug was not reproducible. Since then there has been a regression.