Intellij IDEA font smoothing in linux

22.8k Views Asked by At

I'm using IntelliJ IDEA on Arch Linux with KDE. OpenJDK version is 1.7.0_40.

Whole IDE fonts (includes code editor) are rendered without any antialiasing and font smoothing. I set in idea.properties file idea.use.default.antialiasing.in.editor to true, and added in _JAVA_OPTIONS variable -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true without any effect.

What else I can try to enable font smoothing?

8

There are 8 best solutions below

0
On

This is a known bug in OpenJDK. I don't think any amount of tweaking will fix this for you, it might make it a bit better, but the font rendering is broken in OpenJDK.

The most pain free fix IMHO, is to go to the AUR and install jdk7-compat, which is designed to run next to your normal JDK.

Don't worry if you never used the AUR, its really straight forward. Basically, what you do is

  1. insure you have base-devel installed with pacman -S base-devel
  2. download the tar from the AUR page I linked above, uncompress it.
  3. run 'makepkg -di' in the folder where you uncompressed to

and its done. Now, edit /usr/share/intellijidea-ce/bin/idea.sh and change the line which executes the program (its in the bottom of the file) so it looks like this

eval "/opt/java7/bin/java" $ALL_JVM_ARGS -Djb.restart.code=88 $MAIN_CLASS_NAME "$@"

This will make intelliJ run in the ORACLE JVM rather than the OpenJDK one, which fixes the font issues all together.

0
On

This applies to the current IntelliJ IDEA

The best solution is to download IntelliJ IDEA with the included JRE (the default download). This version runs on a custom JRE (Java Runtime Environment) that is patched to better handle fonts on Linux.

IntelliJ IDEA offers 2 versions for Linux, one version has an embedded JRE (the default download), while the other version doesn't have one and depends on the user's own Java installation.

If you don't want to re-install IntelliJ, Try the following:

  1. Download and extract this JRE
  2. Switch to it
  3. add -Djava2d.font.loadFontConf=false to both idea.vmoptions and idea64.vmoptions files located under intellij_installation_folder/bin/

N.B. The result of the first solution was a bit more nice-looking when I tried them.

As far as my testing goes, the @Corneliu Dascălu solution mentioned here no longer works on IntelliJ 2018 and up.

0
On

In /usr/share/intellijidea-ce/bin/idea.sh: edit this line:

ALL_JVM_ARGS="$VM_OPTIONS $COMMON_JVM_ARGS $IDE_JVM_ARGS $AGENT $REQUIRED_JVM_ARGS"

and make it like this:

ALL_JVM_ARGS="$VM_OPTIONS $COMMON_JVM_ARGS $IDE_JVM_ARGS $AGENT $REQUIRED_JVM_ARGS -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true"
4
On

Take a look here. I remember having the same problem when running IDEA, but after adding the line mentioned in the wiki the problem goes away.

export _JAVA_OPTIONS='-Dawt.useSystemAAFontSettings=setting' where setting may be

  • off or false or default – No anti-aliasing
  • on – Full anti-aliasing
  • gasp – Use the font's built-in hinting instructions
  • lcd or lcd_hrgb – Anti-aliasing tuned for many popular LCD monitors
  • lcd_hbgr – Alternative LCD monitor setting
  • lcd_vrgb – Alternative LCD monitor setting
  • lcd_vbgr – Alternative LCD monitor setting
1
On

It won't work with OpenJDK, even with whatever _JAVA_OPTIONS you choose, so remove it with sudo pacman -Rndd jdk7-openjdk jre7-openjdk jre7-openjdk-headless java-rhino and install the Oracle JDK 8 from Aur. After the installation you have to logout/login to update your java environment variables (f.e. JAVA_HOME). Voila, the font rendering is fine.

Enjoy!

PS: pacman -Rndd removes without dependencies but with the config files, expanded: pacman --remove --nosave --nodeps --nodeps.

IntelliJ Idea Community Edition 13.1.2 with Oracle JDK8 on Arch Linux

3
On

None of this ugly stuff is needed anymore. Download the latest IntelliJ (2016.1 onwards) for Linux. It includes a modified JRE with the fonts issue fixed. To fix Android Studio too make a symbolic link to the IntelliJ jre:

ln -s /PATH/TO/INTELLIJ/jre /PATH/TO/ANDROIDSTUDIO/jre

Alternatively, just open your file manager as root (assuming your IDEs are installed in the /opt directory or another system folder) and create a shortcut to IntelliJ's jre and move it to Android Studio installation folder, then rename it to 'jre'. This works for the latest android studio 2.0 but it should work with earlier versions too.

Android Studio now comes with the modified JRE so the symbolic link is not needed anymore, just download the latest version.

0
On

As mentioned, this is a bug in the JDK. The good news is that there's a patch for OpenJDK that greatly improves font rendering for IntelliJ on Linux, and brings the font quality up to par with what I've seen on my Mac.

(To be clear, this is significantly better than what can be obtained by tweaking idea.properties.)

To install it, use the packages below:

Ubuntu PPA https://launchpad.net/~no1wantdthisname/+archive/openjdk-fontfix

Arch AUR: https://aur.archlinux.org/packages/jre7-openjdk-headless-fontfix/
(I run Ubuntu/Elementary OS, so I can't vouch for this one personally)

1
On

I've found another solution here. It works for the Oracle JDK, but it may be helpful for people stumbling on this question. You have to edit the .vmoptions file (in my case it's idea64.vmoptions from /bin). Add these three lines:

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

If you encounter issues, you can remove the last line. You can test different versions for the first setting (get the options from the post above).

In addition, you can edit the font you're using and clear hinting (the post's author suggests using FontForge). I have not found this to be necessary.