Java JTextField and JTextArea are broken on 1.8.0 OS X Yosemite

时间:2015-06-30 13:55:23

标签: java macos jtextfield jtextarea text-rendering

I've just faced a general problem with JTextField in Java 8 on OS X 10.10 Yosemite:

My particular case: JTextField with a custom font does not handle/render the text correct.

  1. Cursor position is not calculated right
  2. Selection bounds are not calculated right
  3. In the case that text exceeds textfield bounds: text is not scrolled right, selecting and moving a text with the mouse produced heavily distorted display.

Similar effects affect JTextArea too.

I'm using Java 1.8.0_25 on OS X 10.10.2, so this is not 1.8.0_40 - specific.

A similar problem is described here: Java JTextField entry broken on 1.8.0_40 OS X Yosemite 10.10.2

My custom font is a OTF font Myriad: stored in MyriadPro-Bold.otf, loaded with following code:

Font loadFont(GraphicsEnvironment ge, InputStream fontInputStream) throws FontFormatException, IOException
{
    Font toreturn = Font.createFont(Font.TRUETYPE_FONT, fontInputStream);
    ge.registerFont(toreturn);
    return toreturn;
}

Does anyone know how to work this around? Or if this problem is going to be fixed in the near future?

0 个答案:

没有答案