Ubuntu: How to fix blurry text in IntelliJ or Visual Studio Code (2024)

by Daniel Veihelmann, published on 03/07/2024

With recent versions of Ubuntu (e.g. 22.10 or 23.10), you may encounter the problem that text in your IDE looks blurry. The usual suspect for this problem is called Wayland, which is the now-default window manager in Ubuntu.

Here are some steps you can try to resolve the font rendering issue for IntelliJ IDEA (or WebStorm) as well as Visual Studio Code.

1. Fix blurry text in Visual Studio Code on Ubuntu

Visual Studio Code is a great IDE, so it would be a shame if you have to use it with a blurry UI. Let's explore two potential solutions to address this problem:

Method 1: Start VS Code with the --ozone-platform=wayland flag

Passing the --ozone-platform=wayland to VS Code may resolve the issue. The nice thing about this potential solution is that you can easily try this out before making any permanent changes to your system.

Assuming Visual Studio Code is available as code on your command line (which it usually is), simply open a terminal (e.g. with Ctrl + Alt + T) and run

code --ozone-platform=wayland

You'll likely see a warning that the flag is unknown, but this is to be expected. Take a look at the VS Code instance that just opened. Is the text sharp?

If not, please try method #2.

If yes, that is great news! Let's ensure that VS Code is always opened with the flag above already set. For this, we need to do two things:

  1. Edit the code.desktop file (which is used to launch VS Code via Ubuntu's UI)
  • You should be able to find this file using Ubuntu's search (type code.desktop)
  • Look for the command that is invoked and add the --ozone-platform=wayland flag directly after the Exec=/usr/share/code/code command.
  1. Ensure that code from the command line also receives the flag.
  • One way to achieve this is to create a new command vscode that is just an alias for code --ozone-platform=wayland.
  • We can do this by editing ~/.bashrc and adding the following line:

.bashrc

alias vscode="code --ozone-platform=wayland"

Method 2: Switch back to X11

If method #1 did not work, switching back to the old X11 window system has a good change of success. This may sound cumbersome but is actually super easy to do:

  1. Log out of Ubuntu
  2. Locate the little button that appears in the bottom-right corner. Click it and switch to Ubuntu (or Ubuntu on Xorg).

Menu of Ubuntu's sign-in screen Source: beedom

  1. Log in as usual. Everything should look and feel the same as before.
  2. Open Visual Studio Code and check if the UI looks crisp now.

We hope one of the two methods worked!


Fix blurry text in IntelliJ IDEA (or WebStorm) on Ubuntu

As for Visual Studio Code, there are two potential solutions to fix a blurry UI in IntelliJ (or WebStorm):

Method 1: Run IntelliJ with flag sun.java2d.opengl

Sometimes, blurry text on IntelliJ IDEA (or WebStorm) on Ubuntu can be resolved by setting the sun.java2d.opengl JVM flag to true when running your IDE.

Enabling this flag is simple, here is what you need to do:

  1. Open IntelliJ (or WebStorm)
  2. In the main window menu, choose Help > Edit Custom VM Options
  3. Add the following line to the text file that is being opened: -Dsun.java2d.opengl=true

JVM option file in IntelliJ

  1. Save and restart IntelliJ.

With a bit of luck, setting the OpenGL flag will have resolved the issue and your code doesn't look blurry anymore. If not, please try this alternative solution:

Method 2: Switch back to X11

If the first method didn't work, your best bet is to switch to the X11 window manager, as described above

That's all we've got today. Happy coding! 💻️


Need to review a complex merge request?

Let's get you some help! Simply paste your URL below:

Works with gitlab github