-
Bug
-
Resolution: Fixed
-
P2
-
1.2.0
-
1.2beta4
-
generic
-
generic
-
Verified
TextLayout.draw can not draw ASCII text on Win32 if ms*.ttc is used.
(fonts can be found on Japanese Win32)
Try the following code.
import java.applet.*;
import java.awt.*;
import java.awt.font.*;
import java.awt.geom.*;
import java.text.*;
public class TextL extends Applet{
public void init() {
GraphicsEnvironment ge =
GraphicsEnvironment.getLocalGraphicsEnvironment();
Font[] fonts = ge.getAllFonts();
for (int i=0; i<fonts.length; i++) {
System.out.println(fonts[i].getName());
}
}
public void paint(Graphics g) {
int w = getSize().width;;
int h = getSize().height;;
Graphics2D g2 = (Graphics2D)g;
Font f1 = new Font("MS Mincho", Font.PLAIN, 12);
Font f2 = new Font("Serif", Font.PLAIN, 12);
String str = new String("MS-DOS Windows 1234567890");
TextLayout tl1 = new TextLayout(str, f1, g2.getFontRenderContext());
TextLayout tl2 = new TextLayout(str, f2, g2.getFontRenderContext());
float sw = (float) tl1.getBounds().getWidth();
float sh = (float) tl1.getAscent();
g2.setColor(Color.blue);
tl1.draw(g2,w/2-sw/2,h/2-25);
g2.setColor(Color.red);
tl2.draw(g2,w/2-sw/2,h/2+25);
}
}
TextLayout instanciated with font object representing MS Mincho will not print
text correctly. Solaris has no problem even if exactl same font is used.
(fonts can be found on Japanese Win32)
Try the following code.
import java.applet.*;
import java.awt.*;
import java.awt.font.*;
import java.awt.geom.*;
import java.text.*;
public class TextL extends Applet{
public void init() {
GraphicsEnvironment ge =
GraphicsEnvironment.getLocalGraphicsEnvironment();
Font[] fonts = ge.getAllFonts();
for (int i=0; i<fonts.length; i++) {
System.out.println(fonts[i].getName());
}
}
public void paint(Graphics g) {
int w = getSize().width;;
int h = getSize().height;;
Graphics2D g2 = (Graphics2D)g;
Font f1 = new Font("MS Mincho", Font.PLAIN, 12);
Font f2 = new Font("Serif", Font.PLAIN, 12);
String str = new String("MS-DOS Windows 1234567890");
TextLayout tl1 = new TextLayout(str, f1, g2.getFontRenderContext());
TextLayout tl2 = new TextLayout(str, f2, g2.getFontRenderContext());
float sw = (float) tl1.getBounds().getWidth();
float sh = (float) tl1.getAscent();
g2.setColor(Color.blue);
tl1.draw(g2,w/2-sw/2,h/2-25);
g2.setColor(Color.red);
tl2.draw(g2,w/2-sw/2,h/2+25);
}
}
TextLayout instanciated with font object representing MS Mincho will not print
text correctly. Solaris has no problem even if exactl same font is used.