Java does a pretty good job at making applications look the same on Windows and Linux. But the default fonts that Java uses on Linux are not the same fonts used for Windows. This causes a problem for implementing GUI projects on Linux that will be used on Windows. The default font used on Linux can have different dimensions than the fonts used on Windows causing differences in the flow of text and messing up components in windows. Here is an example: The solution is to install and use Microsoft's free "TrueType core fonts for the Web" on Linux and configure Java to use those fonts. You might wonder if it is legal to install these Microsoft fonts on a Linux computer. The answer is yes it is legal. And you don't have to own any copies of Windows. The license for these fonts is short and easy to read. You can read it here: https://www.microsoft.com/typography/fontpack/eula.htm The key parts of the license are, "The SOFTWARE PRODUCT is licensed, not sold." and "You may install and use an unlimited number of copies of the SOFTWARE PRODUCT." Here are instructions on how to install and configure Java to use these fonts on Ubuntu Linux. These instructions work for Oracle Java 7, Oracle Java 8 and OpenJDK 7.
Thanks to Kyle Chase and pphillips for providing information about how to do this on the IA Forum topic Java Fonts and Linux. I would love to hear your experiences about installing Windows fonts in Java on Linux. Leave a comment about your experience or about this article. Did you find this blog post useful? Sign up for my mailing list to get notified of future blog posts.
17 Comments
Abu Junayd
8/20/2014 03:41:21 pm
I recently switched from Windows to Ubuntu and was thinking of going back to Windows because of the horrible looking fonts in the java software I'm working on.
Reply
Nick Mudge
8/21/2014 01:06:02 am
Hi Abu,
Reply
Dennis Leblanc
12/5/2014 04:05:39 am
I followed these steps but unfortunately my Dialog fonts still don't look right on lInux. I am running Lubuntu 14.04, Ignition 7.7.1 and Java 1.8.0_25
Reply
12/5/2014 04:27:41 am
Okay, did you delete this file: /usr/lib/jvm/java-8-oracle/jre/lib/fontconfig.Ubuntu.properties ?
Reply
rodrigo
5/21/2015 01:30:39 am
Worked like a charm, thank you
Reply
Klaus
9/3/2015 01:55:50 am
Many thanks for the instructions! Now the application looks in Linux like in Windows.
Reply
11/1/2015 01:59:17 pm
Worked for me with RHEL 6.7 on vm, thanks!
Reply
John
2/16/2016 11:57:51 am
I tried to edit the file but it wouldn't let me. I'm guessing I'll have to chmod the file in order to edit it.
Reply
Ammar Akouri
5/23/2016 02:40:21 pm
Man you just did me a hude favor ! Thank you so much !
Reply
Be aware that in later versions of Linux (Mint 18 for example), the DejaVu font files start with a lower number in /etc/fonts/conf.avail and so have a higher priority then 60-latin.conf. You should either comment out the relevant sections of the DejaVu files or rename the Latin file to a lower number and create a new soft link in /etc/fonts/conf.d.
Reply
5/18/2017 01:55:40 am
WuInstall - Manage Windows Updates
Reply
kosmos890
11/6/2017 08:47:14 am
Hi Nick
Reply
Nick Mudge
11/6/2017 09:11:52 am
Hi kosmos890,
Reply
kosmos890
11/6/2017 09:56:58 am
Thanks for your reply Nick.
Martin
2/11/2019 09:15:24 am
Even this is an old post. I ran into "the same".
Reply
Tadeu
8/2/2019 03:41:50 am
Thanks a lot, it is 2019 and I was having this problem... the solution was:
Reply
Leave a Reply. |
AuthorNick Mudge See our blogs here
http://blog.perfectabstractions.com Links
Archives
March 2017
Categories
All
|