Ugly fonts in Java applications on Ubuntu

54,439

Solution 1

So... Seems my problem is solved.

Step 1, Install and configure Infinality for better font rendering in Linux

sudo add-apt-repository ppa:no1wantdthisname/ppa
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install fontconfig-infinality

Step 2., Install OpenJDK7 with font fixes in Ubuntu

sudo add-apt-repository ppa:no1wantdthisname/openjdk-fontfix
sudo apt-get update
sudo apt-get upgrade

NetBeans: screenshot with improved fonts

Step 3: Applies nice font style linux

sudo /etc/fonts/infinality/infctl.sh setstyle linux

Solution 2

Try adding

export _JAVA_OPTIONS='-Dawt.useSystemAAFontSettings=gasp'

to your ~/.bashrc

A more detailed discussion can be found here.

Solution 3

Old topic but for future visits, here is a solution that works:

# Install both infinality and fontfix'ed JDK.
sudo add-apt-repository ppa:no1wantdthisname/ppa
sudo add-apt-repository ppa:no1wantdthisname/openjdk-fontfix
sudo apt-get update
sudo apt-get install fontconfig-infinality openjdk-7-jdk
# Apply a font style that looks good.
sudo /etc/fonts/infinality/infctl.sh setstyle linux
# And reboot the system.
sudo reboot

source : Demian Ferreiro in solution

Solution 4

After hours of searching and experimenting, I finally found a working solution!!! No need to mess up with fontforge, no need to patch your jdk, which is not allowed on a corporate workstation.

  1. REQUIRED Remove openjdk and install oracle jdk.
  2. Download deb from http://ppa.launchpad.net/no1wantdthisname/ubuntu/pool/main/f/fontconfig-infinality/
  3. Install it: sudo dpkg -i *.deb
  4. Enable osx font smoothing: sudo /etc/fonts/infinality/infctl.sh setstyle
  5. Reboot your system sudo reboot lightgdm

If you are an Android Studio (Intellij) user, try add the following lines to your studio(64).vmoptions:

-Dawt.useSystemAAFontSettings=on
-Dswing.aatext=true
-Dsun.java2d.xrender=true

Solution 5

As of version release 2016.1, JetBrains is including / bundling a JRE that has the font rendering corrected.

:)

Scott

Share:
54,439
Dmitry
Author by

Dmitry

Everything and everywhere

Updated on July 09, 2022

Comments

  • Dmitry
    Dmitry almost 2 years

    Help me, please. It's screen of my Netbeans:enter image description here PyCharm: enter image description here How can I fix it? I use Oracle Java 7. java version "1.7.0_25" Java(TM) SE Runtime Environment (build 1.7.0_25-b15) Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)

    PS: For comparison my Sublime Text:enter image description here

  • Dmitry
    Dmitry almost 11 years
    Changing fonts does not help.
  • Vishy
    Vishy almost 11 years
    Have you turned on anti-aliasing (which I believe is off by default) It is not clear to me why you find it ugly so I am just guessing.
  • Admin
    Admin almost 11 years
    yes @PeterLawrey is right, anti-aliasing is not just belong to software, you may check the VGA Driver config too
  • Nevercom
    Nevercom almost 11 years
    May i ask What is your java LookAndFeel ? (are you using any or its just how java apps look in Gnome Shell ?) because my netbeans installation (7.2) does not look good as yours (although font issue is solved)
  • Dmitry
    Dmitry almost 11 years
    What do you mean? I don't understand.
  • Dmitry
    Dmitry almost 11 years
    If you mean theme of my NetBeans - I use standard theme. My os is Elementary OS and NetBeans goes well with my interface themes.
  • Nevercom
    Nevercom almost 11 years
    Thanks, so you're using GTK look and feel and it just goew better with your GTK theme (I'm using Ubuntu's default Ambiance theme and it just doesn't look good as yours)
  • Akash Jain
    Akash Jain over 10 years
    step1 and step2 links's method working fine ! .. thanks for sharing !
  • Programster
    Programster about 10 years
    Finally! This actaully worked for me. My anorexic fonts are gone.
  • Léo Lam
    Léo Lam about 10 years
    It would be better if you could include essential parts of the steps in the answer! :)
  • Deepal
    Deepal over 9 years
    I got it worked! But today my OpenJDK7 was updated. Now the fonts are screwed up again. Reinstalled infinality and openjdk patch, but it does not seem to work.
  • Dmitry
    Dmitry over 9 years
    with '-Dawt.useSystemAAFontSettings=on' on my webstorm looks good
  • Hubro
    Hubro about 9 years
    What sorcery is this? This magically made the fonts in umongo beautiful. Why doesn't Java do this by default!? Seriously, check out the before and after, it's ridiculous
  • Rok Kralj
    Rok Kralj almost 9 years
    Hubro: A bit better, but still really bad.
  • Aleksandr Dubinsky
    Aleksandr Dubinsky almost 9 years
    What is this "patched" JDK? What was changed in it? Is it being updated together with the official updates? Seems like a crazy solution to such a problem.
  • Dmitry
    Dmitry almost 9 years
    It's old solution, and maybe not actual for now
  • joelostblom
    joelostblom over 8 years
    If you need to use oracle's java for one reason or another, installing fontconfig-infinality and then running sudo /etc/fonts/infinality/infctl.sh setstyle and selecting linux or osx also works as per Ian Wong's answer (which is hidden a bit further down at the moment).
  • joelostblom
    joelostblom over 8 years
    Fantastic! This makes applications like freeplane and cytoscape so much easier to use, I can actually read the menu items now! The styles linux and osx both worked for me, infinality did not look very good.
  • Sandro L
    Sandro L about 8 years
    This breaked my fonts this morning after the update :(
  • nn0p
    nn0p almost 8 years
    Why do you need apt-get upgrade?
  • Tobia
    Tobia over 7 years
    I didn't have a clue there were these great patches around. Thanks a lot! Everything looks much better now!
  • XMB5
    XMB5 over 6 years
    Adding this to my bashrc didn't work, so I added System.setProperty("awt.useSystemAAFontSettings", "on"); to the source of the program
  • Dominic Cerisano
    Dominic Cerisano over 6 years
    Excellent, only I would put it in /etc/environment as a system-wide fix.
  • scrutari
    scrutari over 5 years
    There is no need to set the env variable (setting env vars in different shells might be tricky, for example, tcsh export won't work). You can pass it as command line argument to java command: java -Dawt.useSystemAAFontSettings=on ....
  • dojuba
    dojuba over 4 years
    Used this as an argument to java call and worked like a charm. As a plus it doesn't need additional repos etc. Thanks a lot.