-
Bug
-
Resolution: Fixed
-
P2
-
11, 13, 14
ADDITIONAL SYSTEM INFORMATION :
Tested on Windows 10 and OpenJDK 14 ea.
A DESCRIPTION OF THE PROBLEM :
If we draw a bold string using Graphic2D#rotate and Grahic2D#drawString, the each characters are drawn gradually going upper locations compared to the baseline.
This seems different depending on the font that is used to draw the string. In my environment the OS is the Japanese version of Windows 10. In such environment, if the font is "Dialog" only BOLD and wide characters are drawn at wrong positions. However, if we use "MS P Gothic" as a font, even normal alphabet characters are drawn at wrong positions.
This does not happen with Oracle JDK 8, but does happen with Oracle JDK 13 and OpenJDK 11, 12, 13, 14 ea.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Please run the code I attach in the "Source code for an executable test case".
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
All of the text lines are drawn parallelly, regardless of the rotated angle.
ACTUAL -
Bold strings gradually goes upper direction, so the positions of the characters go away from the plain texts, or overlap with the plain texts.
---------- BEGIN SOURCE ----------
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class Hoge extends JPanel {
public static void main(String[] args){
String text = System.getProperty("java.vendor") + " " + System.getProperty("java.version");
JFrame frame= new JFrame(text);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(new Hoge());
frame.setSize(1000, 1000);
frame.setVisible(true);
}
public void paint(Graphics g){
Graphics2D g2 = (Graphics2D)g;
String fontName = "ï¼ï¼³ ï¼°ã´ã·ãã¯";
int fontSize = 20;
int posY=25;
for(int i=0;i<3;i++){
posY=25;
if(i==0){
g2.setColor(Color.BLACK);
fontName = "Dialog";
}if(i==1){
g.translate(200, 100);
g2.rotate(0.8);
g2.setColor(Color.red);
}else if(i==2){
g2.setColor(Color.BLUE);
fontName = "ï¼ï¼³ ï¼°ã´ã·ãã¯";
g.translate(200, -200);
}
g2.setFont(new Font(fontName, Font.BOLD, fontSize));
g2.drawString("THIS IS A HALF-WIDTH AND BOLD STRING. FONT=" + fontName , 50, posY+=25);
g2.setFont(new Font(fontName, Font.BOLD, fontSize));
g2.drawString("THISãISãAãNONï¼ï¼¨ï¼¡ï¼¬ï¼¦ãANDãBOLDãSTRING. FONT==" + fontName, 50, posY+=25);
g2.setFont(new Font(fontName,Font.PLAIN, fontSize));
g2.drawString("THISãISãAãNONï¼ï¼¨ï¼¡ï¼¬ï¼¦ãANDãPLAINãSTRING. FONT==" + fontName, 50, posY+=25);
g2.setFont(new Font(fontName, Font.BOLD, fontSize));
g2.drawString("THIS IS A HALF-WIDTH AND BOLD STRING. FONT=" + fontName , 50, posY+=25);
}
}
}
---------- END SOURCE ----------
FREQUENCY : always
Tested on Windows 10 and OpenJDK 14 ea.
A DESCRIPTION OF THE PROBLEM :
If we draw a bold string using Graphic2D#rotate and Grahic2D#drawString, the each characters are drawn gradually going upper locations compared to the baseline.
This seems different depending on the font that is used to draw the string. In my environment the OS is the Japanese version of Windows 10. In such environment, if the font is "Dialog" only BOLD and wide characters are drawn at wrong positions. However, if we use "MS P Gothic" as a font, even normal alphabet characters are drawn at wrong positions.
This does not happen with Oracle JDK 8, but does happen with Oracle JDK 13 and OpenJDK 11, 12, 13, 14 ea.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Please run the code I attach in the "Source code for an executable test case".
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
All of the text lines are drawn parallelly, regardless of the rotated angle.
ACTUAL -
Bold strings gradually goes upper direction, so the positions of the characters go away from the plain texts, or overlap with the plain texts.
---------- BEGIN SOURCE ----------
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class Hoge extends JPanel {
public static void main(String[] args){
String text = System.getProperty("java.vendor") + " " + System.getProperty("java.version");
JFrame frame= new JFrame(text);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(new Hoge());
frame.setSize(1000, 1000);
frame.setVisible(true);
}
public void paint(Graphics g){
Graphics2D g2 = (Graphics2D)g;
String fontName = "ï¼ï¼³ ï¼°ã´ã·ãã¯";
int fontSize = 20;
int posY=25;
for(int i=0;i<3;i++){
posY=25;
if(i==0){
g2.setColor(Color.BLACK);
fontName = "Dialog";
}if(i==1){
g.translate(200, 100);
g2.rotate(0.8);
g2.setColor(Color.red);
}else if(i==2){
g2.setColor(Color.BLUE);
fontName = "ï¼ï¼³ ï¼°ã´ã·ãã¯";
g.translate(200, -200);
}
g2.setFont(new Font(fontName, Font.BOLD, fontSize));
g2.drawString("THIS IS A HALF-WIDTH AND BOLD STRING. FONT=" + fontName , 50, posY+=25);
g2.setFont(new Font(fontName, Font.BOLD, fontSize));
g2.drawString("THISãISãAãNONï¼ï¼¨ï¼¡ï¼¬ï¼¦ãANDãBOLDãSTRING. FONT==" + fontName, 50, posY+=25);
g2.setFont(new Font(fontName,Font.PLAIN, fontSize));
g2.drawString("THISãISãAãNONï¼ï¼¨ï¼¡ï¼¬ï¼¦ãANDãPLAINãSTRING. FONT==" + fontName, 50, posY+=25);
g2.setFont(new Font(fontName, Font.BOLD, fontSize));
g2.drawString("THIS IS A HALF-WIDTH AND BOLD STRING. FONT=" + fontName , 50, posY+=25);
}
}
}
---------- END SOURCE ----------
FREQUENCY : always