I have a weird problem when drawing strings with some specific true type fonts in Java 32bit on Windows 10.
Since Java 7u13, when a font character / glyph is wider than 4 times its height, it is not displayed at all using Graphics2D.drawString (e.g. glyph 4001em wide with a base font size of 1000em):
public void paint(Graphics g) {
Graphics2D g2 = (Graphics2D)g;
g2.setFont(new Font("myFontWithWideGlyphForX", Font.PLAIN, 12));
g2.drawString("XXXX", 10, 10);
}
However, the font displays correctly on JLabel, so after some research on the basic Swing code, I realized that setting the rendering tip KEY_TEXT_ANTIALIASING to VALUE_TEXT_ANTIALIAS_LCD_HRGB makes the text render correctly:
public void paint(Graphics g) {
Graphics2D g2 = (Graphics2D)g;
g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB);
g2.setFont(new Font("myFontWithWideGlyphForX", Font.PLAIN, 12));
g2.drawString("XXXX", 10, 10);
}
It seems that the rendering algorithm works differently after setting the atialiasig subpixel and displays the font correctly.
Java 7u11 , - VALUE_TEXT_ANTIALIAS_LCD_HRGB.
- , "J":
http://www.fontspace.com/digital-magic/hdgems5 - Java 7u11, .
VALUE_TEXT_ANTIALIAS_LCD_HRGB , (, ). - , 7u13? ? , , ?