Java Fonts and Linux

Sorry to bump such an old thread, but I wanted to augment pphillips’ most recent post in case it’s useful to some other Linux user. Thanks for the post by the way. This was extremely helpful!

I’m a Linux user for my daily computing needs, but all of the users who run the Ignition clients run Windows. I had an issue where alignment of text wasn’t showing up the same in Windows and Linux, so I was forced to develop for Ignition within Windows (through a VM, at least). We’ve been running the gateway through Windows, so I assumed that was all that Inductive supported it for.

I recently decided to give it another go on Linux, since I recently found that the Ignition gateway specifically supports Linux as well. Here are the font orderings in the XML file mentioned by pphillips that I moved to achieve the same look and feel as on Windows. I need to do a bit more in depth testing for it, but the screens that I’ve looked at so far look good to me on Linux. The following XML elements should be moved to the top within their respective … grouping:

<family>Times New Roman</family> <family>Arial</family> <family>Lucida Sans Unicode</family> <family>Helvetica</family> <family>Courier New</family> <family>Courier</family> <family>Impact</family> <family>Comic Sans MS</family>

Has anyone else had any success (or lack of) with the techniques described above? I am running java 7 on a test linux client and after installing the ms fonts package, changing the font preference config file and running reconfiguring via dpkg, I’m still seeing native linux fonts.

In the attached file, the top half is windows, bottom is linux. Does anyone know the name of the font in the linux shot? Maybe Deja Vu Sans? I’m trying to pin it down so I can at least attack it from that direction.

Thanks for posting all the tips. Its very helpful.

Typically, the default sans-serif font in Ubuntu is Lucinda Sans. In the “60-latin.conf” file, I normally add “Arial” somewhere above “Lucinda Sans”, since the one at the top gets preference. Of course, if you change this file, you should rebuild the libfontconfig file.

The other thing is to first make sure the msttcorefonts got installed ok. They should be somewhere in one of the directories pointed to by “/etc/fonts/fonts.conf”. To make sure linux recognizes the fonts, run:

$ sudo fc-cache -f -v

Hope this helps.

running that and grep’ing for ms gives: “/usr/share/fonts/truetype/msttcorefonts: caching, new cache contents: 60 fonts, 0 dirs”

I’ve got arial and helvetica at the top of my 60-latin.conf file 60-latin.conf.txt (1.66 KB). Did you have to reinstall java or re-download the jnlp file or anything?

Thanks again for posting the tips.

Sorry, I misspoke about the default fonts - you were correct, Ubuntu default is DejaVu Sans rather than Lucinda Sans.

From my experience, you should not have to re-load Java or the jnlp file, but you may need to re-start the application. I think Java should pick this up when it starts up.

pphillips’ method will not work if an operating system specific fontconfig properties file exists that matches the operating system.

For example, if on Ubuntu the “/usr/lib/jvm/java-7-oracle/jre/lib/fontconfig.Ubuntu.properties” file must be removed.

I recently wrote a blog post about installing Windows fonts in Java on Linux.

Thanks Nick, for posting this. Good to have this clarified and in one location.

Trying to bump this up - the above packages no longer seem to be available. Anyone know how to install the MSfonts now?

Thanks!

Worked for me (Ubuntu 14.04).

apt-get install ttf-mscorefonts-installer

Using this works too, it automatically substituted ttf-mscorefonts-installer

apt-get install msttcorefonts

What’s missing for you?

Package ttf-mscorefonts-installer is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

Same version of Ubuntu…

That’s odd, I just tried it on a fairly virgin install of Ubuntu 14.04 (only change from stock was removing IcedTea and installing Java 8 ), and it worked great.

Are you running headless or anything unusual like that? Did you disable the multiverse repositories?

I am running headless. I got it to work after adding the kernel.org mirror and installing all dependencies on install. Thanks!

Well, I’ve installed msttcorefonts on Ubuntu 10.04 and 12.04 and Java 6 and 7 using these methods with good success each time. However, I’ve used the same technique(s) on Ubuntu 14.04 with Java 8 (jre_8u25) and have had no luck getting it to work. Doesn’t seem to respect the libfontconfig settings or fontconfig.properties (or no fontconfig.properties file). The mscorefonts are installed and usable - just won’t substitute Arial for the logical Dialog font.

Any one seen this? Is this a Java 8 bug? Or something different about Ubuntu 14.04?

Unfortunately, since Ignition v7.7 requires Java 8, and I need a client to fall-back to a local gateway, I pretty much have to use Java 8 on one of the clients. Any ideas would be appreciated.

Wasn’t there something about deleting /usr/lib/jvm/java-8-oracle/jre/lib/fontconfig.Ubuntu.properties?

EDIT: Oops. It was actually earlier in this thread… :laughing: I suppose I should ask if you did it as a sanity check. :wink:

Yeah, Jordan, from what I’ve seen, the Java jre’s dropped including the fontconfig.Ubuntu.properties file quite a while back. In the Java documentation that I can find, there is mention of Java (version?) using fontconfig.properties for those Linux versions it doesn’t include explicitly (e.g. RedHat, etc.). I’ve even tried re-naming fontconfig.properties, etc. to make sure it’s not using them and it doesn’t seem to help either.

In one case, I reverted back to Ubuntu 12.04 and Java 7, and it worked as it previously has with no problem. Next try would be Ubuntu 14.04 with Java 7, but it may be awhile before I get time to try it.

Got some time this morning to dig into this a bit more. Got things working with 14.04 and java 8 (yay!)

Instead of deleting the fontconfig.Ubuntu.propeties file, I modified it, including the corefonts (Arial, Times New Roman, Courier New)
fontconfig.Ubuntu1404.properties (14.9 KB)

Yay is right! Thanks for posting this, Jordan. This is very helpful.

I know this is an old topic, but I am attempting to get the Dialog font changed to Arial to match the Windows clients. I am attempting this on a Raspberry Pi 3. The client runs fine on it, except none of the above instructions have worked on getting the font corrected.

There is no fontconfig.properties file, but there is fontconfig.properties.src and also fontconfig.properties.Redhat.6.src, and similars (Turbo, etc).

Tried different combinations. Renaming the fontconfig.properties (downloaded form this thread) to fontconfig.properties.src and placing it in the /jre/lib/ path. Modified the 60-latin.conf in /etc/fonts/conf.avail.

Thoughts? Has anyone done this with in Raspian?

Any assistance would be greatly appreciated. Thanks.

BrandonSHill, I ran into the same exact problem. Did you find a fix for yours?

A fresh install of Oracle Java 8 on Ubuntu 16.04 amd64 gave the opportunity to re-test the instructions in this topic. Out-of-the-box the Ignition applications designed on the Windows platform work OK, but the font appearance and spacing is off. Installing the msttcorefonts core fonts package does by itself not fix the problem because Java is separately configured to continue using DejaVu Serif, DejaVu Sans, and DejaVu Sans Mono instead of Times New Roman, Arial, and Courier New.

Starting with a fresh Ubuntu 16.04 installation, use ppa approach from webupd8.org/2012/09/install- … a-ppa.html to install Java

sudo add-apt-repository ppa:webupd8team/java
sudo apt update
sudo apt install oracle-java8-installer

Install fonts

apt install msttcorefonts

The Java font file /usr/lib/jvm/java-8-oracle/jre/lib/fontconfig.Ubuntu.properties can be modified manually or by installing the fontconfig.Ubuntu1404.properties (14.9 KB)
posted in this thread by user JordanCClark on Tue Apr 28, 2015. A diff showed that the only differences are that the font names are replaced and locations for the msttcorefonts are added. Note that a Java update can re-install the original fontconfig.Ubuntu.properties file, so you may want to keep a copy of your font modifications available.

1 Like