0

Recently I just tested a simple java application which has got a JTextPane shows some simple utf-8 html content.
Everything is working perfect under windows, and Linux, simple not in Mac.
I'm sure this is not belong to fonts because all components render the same ut8-8 data correctly, except JTextPane.(also other applications don't have such this problem)
text render in windows/linux(correct):
enter image description here
text render in Mac(incorrect):
enter image description here
So the question is, is it kinda bug in MAC? do both windows and mac JVM use same source code and method for rendering text in JTextPane?

Thanks in advance.

mKorbel
  • 109,525
  • 20
  • 134
  • 319
  • You may be able to use one of the approaches shown in this [Q&A](http://stackoverflow.com/questions/5994815/rendering-devanagari-ligatures-unicode-in-java-swing-jcomponent-on-mac-os-x) – trashgod Apr 28 '14 at 08:35

1 Answers1

1

It could be issue with font. Physical font used to represent Logical font.

Read here and here. In simple words there are logical fonts (Monospaced is used to represent text with no font defined in the DefaultStyledDocument) which is represented by platform dependent physical font.

Try to figure out which physical font is ised in your case. Also try to set another font via setCharacterAttributes() and see whether the representation is changed.

StanislavL
  • 56,971
  • 9
  • 68
  • 98
  • Thank you so much dear, so why I don't have any problem with rest components such as JTextArea, or JTextBox ? also the same font works perfect with another applications. is there any tool for transferring the fonts from windows to mac? –  Apr 28 '14 at 06:43
  • JTextArea/JLabel use different font by default. JUst get all the **physical** fonts used in your application on Mac and post them as edit in your question. Asking for any tool is offtopic here and I doubt it's possible in common case. Some fonts may have representation for Mac and Win but other don't – StanislavL Apr 28 '14 at 06:47
  • Stan: I think it's a ligature rendering problem, mentioned [here](http://stackoverflow.com/questions/5994815/rendering-devanagari-ligatures-unicode-in-java-swing-jcomponent-on-mac-os-x). – trashgod Apr 28 '14 at 08:37
  • 1
    @trashgod could be you are right. I also had a similar issue with ligatures and it was fixed by changing font. Definitely the first attempt would be your flag but an alternative could be font changing. – StanislavL Apr 28 '14 at 08:45
  • @StanislavL buddy I tried the method trashgod mentioned and it didn't work. I just tested some cases. when I install the font and load it from OS font context, I have different render, same for loading the font using `Font#createFont()`, it has different render too. I just copied the fonts from wi machine to mac, should I convert them or do something? –  Apr 28 '14 at 11:12
  • I would choose just one font used on Win and on Mac without the problem and add it to your application to be used for the rendering. Can't say which exactly font is fine in your case. – StanislavL Apr 28 '14 at 11:30