Intellij IDEA font smoothing in linux

蓝咒 提交于 2019-11-29 00:05:40

问题


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?


回答1:


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



回答2:


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.




回答3:


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.




回答4:


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)




回答5:


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.




回答6:


This applies to IntelliJ IDEA 2018

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

IntelliJ IDEA offers 2 versions for the Linux OS, one version has an embedded JRE (This is 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, there is another solution:

  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 work on IntelliJ 2018.




回答7:


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.




回答8:


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"


来源:https://stackoverflow.com/questions/17346942/intellij-idea-font-smoothing-in-linux

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!