Java Fonts and Linux

#21

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

0 Likes

#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.

0 Likes

#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:

0 Likes

#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.

0 Likes

#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)

0 Likes

#26

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

0 Likes

#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.

0 Likes

#28

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

0 Likes

#29

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

#30

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.

0 Likes

#31

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.

0 Likes

#34

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.

4 Likes