Java Fonts and Linux

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

It looks like Rapsbian and Java 7 and Java 8 have some errors regarding the Font Configuration file.

bugs.java.com/view_bug.do?bug_id=7175487

It only responds to $HOME/.java/fonts config file and not the fontconfig.properties files. It appears that the problem is fixed in Java 9 beta. We will have to wait for Java 9 on Raspberry PI before we can have a properly fixed solution.

Since Ubuntu for some time has included the Red Hat Liberation fonts (same dimensions as MS True Type core fonts), attached is a fontconfig.Ubuntu.properties file that makes the Liberation fonts substitute for Dialog fonts in Java. Not quite as pretty (in my opinion), but they are not bad, and it saves a step or two.

Just copy the attached file to your ā€¦/jre*/lib/ folder. As noted in the above posts, however, you will have to do this each time you update Java.

I have confirmed that this works for Java jre1.8.0_111.

Bumping an old topic with fresh instructions:

I was setting up an Ubuntu 18.04 desktop with the OpenJDK-8-jre java install. It uses the system font configuration files and has no fontconfig.Ubuntu.properties file to fiddle with. After much research, trial and error, I found that what I needed to do was:

Install the MS TrueType fonts: sudo apt-get install msttcorefonts

Create the font config file in the proper place, with the proper name: sudo nano /etc/fonts/local.conf

Paste in the font config selecting the MS fonts for the generic names and save it:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<!-- -->
<fontconfig>
  <!-- Generic name aliasing -->
  <alias>
    <family>sans-serif</family>
    <prefer>
      <family>Arial</family>
    </prefer>
  </alias>
  <alias>
    <family>serif</family>
    <prefer>
      <family>Times New Roman</family>
    </prefer>
  </alias>
  <alias>
    <family>monospace</family>
    <prefer>
      <family>Courier New</family>
    </prefer>
  </alias>
</fontconfig>

Rebuild the font cache: sudo dpkg-reconfigure fontconfig

Altering the 60-latin.conf file as @nmudge was suggesting wasnā€™t effective, as I believe there were other, higher priority directives in place on my system. Putting the directives in the local.conf file did the trick.

6 Likes

As a quick note to the Brianā€™s post above, what he has listed worked great for me with Ubuntu 18.04. However, when I went to a Debian system I first had to enable the non-free packages:

sudo apt-add-repository non-free
sudo apt-get update
4 Likes

Update on my previous post:

In Debian 10 (Buster) it looks like you need the contrib sources. If you update /etc/apt/sources.list with ā€œcontribā€ (between main and non-free) and then sudo apt-get update you should be able to successfully install msttcorefonts.

Hereā€™s my updated sources.list file. This screenshot was taken after I did my previous terminal commands.

sudo apt-add-repository non-free
sudo apt-get update

For more information on sources, see SourcesList - Debian Wiki

As a reference, hereā€™s the stock /etc/apt/sources.list:

1 Like