0
我意識到,在我的某些客戶方面,當我使用Graphics2D本身提供的字體並將尺寸減小1時,它無法正確顯示。Java字體顯示問題
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);
其餘的字體是OK的。這裏是屏幕拍攝(見的黃色框有黃色方框內的3類不同的字體。): alt text http://www.investalks.com/attachments/month_1005/10051420318460461ffea5a2f9.jpg