Java: Fonts look garbled on Linux, but fine on windows

喜你入骨 提交于 2019-12-04 10:23:35

OpenJDK has to put out fonts which are copyright protected. Install Sun's Java and fonts will be somehwat better.

higuita

I have OpenJDK installed in Linux and all apps were with very, very bad fonts... after many tries to change fonts, antialias, installing Lucida fonts, etc. I found that my problem was in the /etc/fonts/conf.d/35-freefont.conf.

I simply removed that link, run fc-cache -f and all new Java apps got a much better font.

In my case, the freefont config was telling Java to use it instead of much better fonts. If you have a similar problem, simply run sudo mv /etc/fonts/conf.d /etc/fonts/conf.d.off and a fc-cache -f and test...

If it works, you also have a bad default font substitution and you should restore that dir and test each file.

If it stays the same, then you probably have another problem (don't forget to restore the conf.d dir)

Update

On Ubuntu 12.04, I had a similar problem, all Java fonts where bold. Removing /etc/fonts/conf.d/65-nonlatin.conf fixed the problem.

Could be font hinting gone bad. Check the font hinting settings of the Linux OS you're working with.

Could also be the font--try specifying a different one. The one you're using may simply render badly on Linux--some just do. Palatino is one I've found to be particularly bad.

You could try using pdffonts to help you analyse the problem - it would at least tell you the names of the fonts used in the PDF file, their type, if they are embedded etc. If the fonts are not embedded you could try installing them on the Linux machine.

There are 8 standard font families you do not need to embed as the PDF viewer should provide. Otherwise they will be substituted. What does the PDF look like in the other PDF Java Open Source viewers (Multivalent, JPedal)?

You can use openJDK and use Sun/Oracle's fonts!

First install openDJK (both runtime and dev packages)

Then install Sun/Oracle's runtime only. This will install the fonts, but you'll still be using openJDK's java to run everything.

Install the latest version of OpenJDK. Or recompile Freetype with hinting enabled. The Apple patents regarding hinting have expired.

Are the fonts embedded in the PDF?

Try to copy all your windows fonts, and put them into your linux environment.

I haven't test it but according to this forum post at inductiveautomation.com you can correct it by installing the fonts:

sudo apt-get install msttcorefonts

and changing lucidasans for arial in the properties of Java fonts:

sudo nano /usr/lib/jvm/java-6-sun/jre/lib/fontconfig.properties
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!