-
Bug
-
Resolution: Won't Fix
-
P4
-
None
-
1.1.6, 1.1.7, 1.2.0
-
generic, x86
-
generic, windows_95
Width of font metrics returned from FontMetrics is incorrect for Japanese font
if style is bold on Win95.(WinNT has no problem.)
Run the following code and see a result.
In the case of plain,
single char width * number of char = string width
but no longer valid if style is bold.
-=-=-=-=-=
import java.awt.*;
public class Graph extends Frame {
public void paint(Graphics gc){
String str = "\u3042\u3044\u3046\u3048\u304a\u304b\u304d";
gc.setColor(Color.black);
Font font = new Font("Serif", Font.PLAIN, 14);
FontMetrics fm = gc.getFontMetrics(font);
System.out.println(fm.stringWidth(str));
System.out.println(fm.charWidth(str.charAt(0)));
gc.setFont(font);
gc.drawString(str, 100, 100);
gc.setColor(Color.red);
gc.drawLine(100,100,100+fm.stringWidth(str), 100);
font = new Font("Serif", Font.BOLD, 14);
fm = gc.getFontMetrics(font);
System.out.println(fm.stringWidth(str));
System.out.println(fm.charWidth(str.charAt(0)));
gc.setColor(Color.black);
gc.setFont(font);
gc.drawString(str, 100, 150);
gc.setColor(Color.red);
gc.drawLine(100,150,100+fm.stringWidth(str), 150);
}
public static void main(String args[]) {
Graph me = new Graph();
me.pack();
me.setBounds(100,100,400,400);
me.setVisible(true);
}
}
if style is bold on Win95.(WinNT has no problem.)
Run the following code and see a result.
In the case of plain,
single char width * number of char = string width
but no longer valid if style is bold.
-=-=-=-=-=
import java.awt.*;
public class Graph extends Frame {
public void paint(Graphics gc){
String str = "\u3042\u3044\u3046\u3048\u304a\u304b\u304d";
gc.setColor(Color.black);
Font font = new Font("Serif", Font.PLAIN, 14);
FontMetrics fm = gc.getFontMetrics(font);
System.out.println(fm.stringWidth(str));
System.out.println(fm.charWidth(str.charAt(0)));
gc.setFont(font);
gc.drawString(str, 100, 100);
gc.setColor(Color.red);
gc.drawLine(100,100,100+fm.stringWidth(str), 100);
font = new Font("Serif", Font.BOLD, 14);
fm = gc.getFontMetrics(font);
System.out.println(fm.stringWidth(str));
System.out.println(fm.charWidth(str.charAt(0)));
gc.setColor(Color.black);
gc.setFont(font);
gc.drawString(str, 100, 150);
gc.setColor(Color.red);
gc.drawLine(100,150,100+fm.stringWidth(str), 150);
}
public static void main(String args[]) {
Graph me = new Graph();
me.pack();
me.setBounds(100,100,400,400);
me.setVisible(true);
}
}
- duplicates
-
JDK-4171071 [Win95/98] Japanese character beeing cut off
-
- Closed
-