Blurry text when using Sway or fractional scaling on Wayland

IntelliJ IDEs - like other Java applications - use X11 to talk to the Xorg server and render on Linux. When running on a desktop with Wayland (like Ubuntu 21.04), Java actually continues to work through X11, but this time the Xorg server is implemented by XWayland, providing a migration path for the applications that don't (yet) use Wayland directly. 

Without fractional scaling enabled, XWayland simply lets X applications render the same way as under "pure" Xorg suggesting the desired DPI through the Xft.dpi X resource value. In this configuration, text is rendered as sharp as under “pure” Xorg.

When using Sway or with the fractional scaling enabled, any scale above 100% - fractional or not - reduces the screen size available to X applications proportionally. For example, this is what an X application sees with "fractional" scaling of 200%:

$ xrandr --current
Screen 0: minimum 16 x 16, current 1280 x 800, ...

and this is with the same scaling of 200%, but fractional scaling disabled:

$ xrandr --current
Screen 0: minimum 16 x 16, current 2590 x 1664, …

As you can see, the screen size with fractional scaling is roughly twice as small. So in this mode Wayland provides a smaller screen to X windows that are then pixel-stretched according to the system's scaling factor. This makes the window's contents look somewhat blurry, which is most noticeable with text. The effect can be seen with any "pure" X application like XTerm, for instance. 

Many applications have already been ported to use Wayland, either directly or through a toolkit like Gnome. Java is on its way to be ported. The Wayland rendering pipeline project has just started (see  the announcement) and JetBrains has joined this initiative. 

Until Java has learned to use Wayland natively or until the fractional scaling feature of Wayland is reworked to avoid pixel-stretching X windows, workarounds for blurry text would be to

  • when using Sway, switch off scaling completely
  • switch off fractional scaling ([link1] [link2]) or
  • go back to using "pure" X session without Wayland ([link]). 

References

1 comment
Comment actions Permalink

Summary: If you have a 4K screen that is usable at 200%, do not enable fractional scaling. Use the 200% option without fractional scaling.

If you have multiple monitors and only one of them is hidpi, the JetBrains IDE must be launched on that monitor. This is the trickiest part.

0

Please sign in to leave a comment.

Have more questions?

Submit a request