Bold fonts in my page layout application started failing under Java 5
on the mac. My app searches the system fonts for something like Arial-
Bold, but when I make a glyph vector out of it, it renders as plain.
My theory is that the system fonts are being created with new Font
(name, Font.PLAIN) and that is confusing Java 5 on the Mac. My test
case below at least shows that Java 5 Mac behaves differently than
all other platforms/versions I've used, though I've always been
confused as to how the style flag conflicts with font names. On Java
5 Mac, it draws the first Arial Bold text as plain - everyone else
draws it as bold. I don't know how to determine if the system fonts
from GraphicsEnvironment.getAllFonts is creating fonts with Font.PLAIN.
Anyone else seen something similar? If not, I'll file a bug.
jeff
public static void main(String args[])
{
// Create frame
javax.swing.JFrame frame = new javax.swing.JFrame();
frame.setSize(300, 300);
// Custom draw some text
public void paintComponent(Graphics g) {
// Get graphics 2d and font render context
Graphics2D g2 = (Graphics2D)g;
FontRenderContext c = g2.getFontRenderContext();
// Draw Hello World Arial
Font f1 = new Font("Arial", Font.PLAIN, 12);
g.setFont(f1);
GlyphVector gv1 = f1.createGlyphVector(c, "Hello World");
g2.drawGlyphVector(gv1, 10, 20);
// Draw Hello World Arial Bold style PLAIN
Font f2 = new Font("Arial-BoldMT", Font.PLAIN, 12);
g.setFont(f2);
GlyphVector gv2 = f2.createGlyphVector(c, "Hello World");
g2.drawGlyphVector(gv2, 10, 40);
// Draw Hello World Arial Bold style BOLD
Font f3 = new Font("Arial-BoldMT", Font.BOLD, 12);
g.setFont(f3);
GlyphVector gv3 = f3.createGlyphVector(c, "Hello World");
g2.drawGlyphVector(gv3, 10, 60);
}
});
// Show frame
frame.show();
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden