Java Font Display Problem
Posted
by Yan Cheng CHEOK
on Stack Overflow
See other posts from Stack Overflow
or by Yan Cheng CHEOK
Published on 2010-05-14T13:30:11Z
Indexed on
2010/05/14
13:34 UTC
Read the original article
Hit count: 206
java
I realize that, in my certain customer side, when I use the font provided by Graphics2D itself, and decrease the size by 1, it cannot display properly.
private void drawInformationBox(Graphics2D g2, JXLayer<? extends V> layer) {
if (MainFrame.getInstance().getJStockOptions().getYellowInformationBoxOption() == JStockOptions.YellowInformationBoxOption.Hide) {
return;
}
final Font oldFont = g2.getFont();
final Font paramFont = new Font(oldFont.getFontName(), oldFont.getStyle(), oldFont.getSize());
final FontMetrics paramFontMetrics = g2.getFontMetrics(paramFont);
final Font valueFont = new Font(oldFont.getFontName(), oldFont.getStyle() | Font.BOLD, oldFont.getSize() + 1);
final FontMetrics valueFontMetrics = g2.getFontMetrics(valueFont);
/*
* This date font cannot be displayed properly. Why?
*/
final Font dateFont = new Font(oldFont.getFontName(), oldFont.getStyle(), oldFont.getSize() - 1);
final FontMetrics dateFontMetrics = g2.getFontMetrics(dateFont);
Rest of the font is OK. Here is the screen shoot (See the yellow box. There are 3 type of different font within the yellow box) :
© Stack Overflow or respective owner