-
Bug
-
Resolution: Duplicate
-
P3
-
8
-
generic
-
generic
ADDITIONAL SYSTEM INFORMATION :
OS: Fedora release 20 (Heisenbug)
Java: jdk-8u391-linux-x64.tar.gz
A DESCRIPTION OF THE PROBLEM :
font size is more big than normal size (size: 14)
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
You can see the big font size if running my sample code. ( the size of string "-1.718xxx" is greater than 14)
---------- BEGIN SOURCE ----------
public class FontAffineTransformSample extends JPanel {
static int x3 = 103;
static int y3 = 200;
@Override
public void paint(Graphics g) {
Graphics2D g2 = (Graphics2D) g;
/*
* p2 (100,100)
* |\
* | \
* | \
* | \
* p1 p3
*/
int x2 = 100;
int y2 = 100;
int x1 = 100;
int y1 = 200;
// int x3 = 105;
// int y3 = 200;
g2.drawLine(x1, y1, x2, y2);
g2.drawLine(FontAffineTransformSample.x3, FontAffineTransformSample.y3,
x2, y2);
g2.drawOval(FontAffineTransformSample.x3 - 5,
FontAffineTransformSample.y3 - 5, 10, 10);
double agl = FontAffineTransformSample.angle(x1, y1, x2, y2,
FontAffineTransformSample.x3, FontAffineTransformSample.y3);
System.out.println(agl);
AffineTransform fontAF = new AffineTransform();
fontAF.rotate(Math.toRadians(agl));
Font newFont = new Font("Dialog", Font.BOLD, 14).deriveFont(fontAF);
g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
g2.setFont(newFont);
g2.drawString(String.valueOf(agl), x2 + 10, y2 - 10);
}
public static void main(String[] args) {
JFrame f = new JFrame();
FontAffineTransformSample pnl = new FontAffineTransformSample();
f.add(pnl);
f.setSize(400, 400);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setLocationRelativeTo(null);
f.setVisible(true);
}
public static double angle(int x1, int y1, int x2, int y2, int x3, int y3) {
// angle
double angle12 = Math.atan2(y1 - y2, x1 - x2);
double angle32 = Math.atan2(y3 - y2, x3 - x2);
return (angle32 - angle12) * 180.0 / Math.PI;
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Remove code line: g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
FREQUENCY : always
OS: Fedora release 20 (Heisenbug)
Java: jdk-8u391-linux-x64.tar.gz
A DESCRIPTION OF THE PROBLEM :
font size is more big than normal size (size: 14)
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
You can see the big font size if running my sample code. ( the size of string "-1.718xxx" is greater than 14)
---------- BEGIN SOURCE ----------
public class FontAffineTransformSample extends JPanel {
static int x3 = 103;
static int y3 = 200;
@Override
public void paint(Graphics g) {
Graphics2D g2 = (Graphics2D) g;
/*
* p2 (100,100)
* |\
* | \
* | \
* | \
* p1 p3
*/
int x2 = 100;
int y2 = 100;
int x1 = 100;
int y1 = 200;
// int x3 = 105;
// int y3 = 200;
g2.drawLine(x1, y1, x2, y2);
g2.drawLine(FontAffineTransformSample.x3, FontAffineTransformSample.y3,
x2, y2);
g2.drawOval(FontAffineTransformSample.x3 - 5,
FontAffineTransformSample.y3 - 5, 10, 10);
double agl = FontAffineTransformSample.angle(x1, y1, x2, y2,
FontAffineTransformSample.x3, FontAffineTransformSample.y3);
System.out.println(agl);
AffineTransform fontAF = new AffineTransform();
fontAF.rotate(Math.toRadians(agl));
Font newFont = new Font("Dialog", Font.BOLD, 14).deriveFont(fontAF);
g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
g2.setFont(newFont);
g2.drawString(String.valueOf(agl), x2 + 10, y2 - 10);
}
public static void main(String[] args) {
JFrame f = new JFrame();
FontAffineTransformSample pnl = new FontAffineTransformSample();
f.add(pnl);
f.setSize(400, 400);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setLocationRelativeTo(null);
f.setVisible(true);
}
public static double angle(int x1, int y1, int x2, int y2, int x3, int y3) {
// angle
double angle12 = Math.atan2(y1 - y2, x1 - x2);
double angle32 = Math.atan2(y3 - y2, x3 - x2);
return (angle32 - angle12) * 180.0 / Math.PI;
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Remove code line: g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
FREQUENCY : always
- duplicates
-
JDK-8147839 Synthetically Bolded Fonts are Stretched Vertically under rotation.
-
- Resolved
-