Java Fonts and Linux


#9

Java 7 no longer uses the fontconfig.properties file on Linux, though it still has all of the files as if it did. It now uses the Linux font configuration file libfontconfig, which has to be re-built after the fonts are installed.

First, with a text editor, modify the file: /etc/fonts/conf.avail/60-latin.conf
This is an xml file that tells fontconfig which latin font families to prefer for each alias type (serif, sans-serif, monospace, etc.). Move or delete font families under each appropriate alias to get the preferred fonts to the top of each list.

Next, to rebuild libfontconfig, run the following from the command line (prefix sudo if appropriate, of course):

dpkg-reconfigure fontconfig

#10

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>


#11

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.


#12

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.


#13

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.


#14

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.


#15

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.


#16

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


#17

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

Thanks!


#18

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?


#19

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…


#20

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?


#21

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


#22

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.


#23

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:


#24

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.


#25

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)


#26

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


#27

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.


#28

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