Ugly fonts in Java applications on Ubuntu
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:
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.
- REQUIRED Remove openjdk and install oracle jdk.
- Download deb from http://ppa.launchpad.net/no1wantdthisname/ubuntu/pool/main/f/fontconfig-infinality/
- Install it:
sudo dpkg -i *.deb
- Enable osx font smoothing:
sudo /etc/fonts/infinality/infctl.sh setstyle
- 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
Comments
-
Dmitry almost 2 years
Help me, please. It's screen of my Netbeans:
PyCharm:
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:
-
Dmitry almost 11 yearsChanging fonts does not help.
-
Vishy almost 11 yearsHave 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 almost 11 yearsyes @PeterLawrey is right, anti-aliasing is not just belong to software, you may check the VGA Driver config too
-
Nevercom almost 11 yearsMay i ask What is your java
LookAndFeel
? (are you using any or its just how java apps look inGnome Shell
?) because my netbeans installation (7.2) does not look good as yours (although font issue is solved) -
Dmitry almost 11 yearsWhat do you mean? I don't understand.
-
Dmitry almost 11 yearsIf you mean theme of my NetBeans - I use standard theme. My os is Elementary OS and NetBeans goes well with my interface themes.
-
Nevercom almost 11 yearsThanks, 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 over 10 yearsstep1 and step2 links's method working fine ! .. thanks for sharing !
-
Programster about 10 yearsFinally! This actaully worked for me. My anorexic fonts are gone.
-
Léo Lam about 10 yearsIt would be better if you could include essential parts of the steps in the answer! :)
-
Deepal over 9 yearsI 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 over 9 yearswith '-Dawt.useSystemAAFontSettings=on' on my webstorm looks good
-
Hubro about 9 years
-
Rok Kralj almost 9 yearsHubro: A bit better, but still really bad.
-
Aleksandr Dubinsky almost 9 yearsWhat 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 almost 9 yearsIt's old solution, and maybe not actual for now
-
joelostblom over 8 yearsIf you need to use oracle's java for one reason or another, installing
fontconfig-infinality
and then runningsudo /etc/fonts/infinality/infctl.sh setstyle
and selectinglinux
orosx
also works as per Ian Wong's answer (which is hidden a bit further down at the moment). -
joelostblom over 8 yearsFantastic! This makes applications like freeplane and cytoscape so much easier to use, I can actually read the menu items now! The styles
linux
andosx
both worked for me,infinality
did not look very good. -
Sandro L about 8 yearsThis breaked my fonts this morning after the update :(
-
nn0p almost 8 yearsWhy do you need
apt-get upgrade
? -
Tobia over 7 yearsI didn't have a clue there were these great patches around. Thanks a lot! Everything looks much better now!
-
XMB5 over 6 yearsAdding this to my bashrc didn't work, so I added
System.setProperty("awt.useSystemAAFontSettings", "on");
to the source of the program -
Dominic Cerisano over 6 yearsExcellent, only I would put it in
/etc/environment
as a system-wide fix. -
scrutari over 5 yearsThere 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 tojava
command:java -Dawt.useSystemAAFontSettings=on ...
. -
dojuba over 4 yearsUsed 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.