HiDPI configuration Follow
- JRE-managed HiDPI mode (default on macOS since JDK7, on Windows since 2018.2/JBR8, on Linux since 2019.2/JBR11). JBR stands for JetBrains Runtime, Java runtime based on OpenJDK and maintained by JetBrains.
Enabled via the VM option: -Dsun.java2d.uiScale.enabled=true
(Help | Edit Custom VM Options).
In this mode the UI scaling is defined by the product of the two scale factors: the user scale (managed by the IDE) and the system scale (managed by the JBR).
- IDE-managed HiDPI mode (legacy mode).
Enabled via the VM option: -Dsun.java2d.uiScale.enabled=false
(Help | Edit Custom VM Options).
In this mode the UI scaling is defined only by the user scale factor (managed by the IDE).
Two types of scale factors
- The user scale factor is derived from the IDE main font size:
Settings > Appearance and Behavior > Appearance > Use custom font
The font size is presented in relative points in the JRE-managed HiDPI mode (the real font size in pixels can be bigger). In this mode the default font size defines the user scale as 1.0.
In the IDE-managed HiDPI mode the font size is presented in absolute points (matching the real font size in pixels). In this mode the default font size depends on the desktop scaling and it defines the user scale that can differ from 1.0. (Note that the font size in the editor is not affected by the main font size and is configured separately).
It's possible to force the user scale factor by providing the VM option below. In this case the font size is untied from the user scale what may cause UI imperfections (and so this option is not recommended other than for debugging purposes).
-Dide.ui.scale=<floating point value>
- The system scale factor is configured on the OS level. However, it's possible to force the system scale factor by providing the VM option (mostly used for debugging purposes):
-Dsun.java2d.uiScale=<floating point value>
It's possible to inspect the current IDE scaling settings via Help | Find Action: "Show HiDPI Info" (available in -Didea.is.internal=true mode, and by default since 2019.2.1).
The instructions below relate to the system scale factor settings.
Single-monitor DPI is supported. DPI is defined by Xft.dpi X resource value.
$ xrdb -q | grep -i dpi
$ xrandr --dpi <dpi>
It can also be set via your Linux Desktop settings, or via gnome-tweak-tools.
The system scale factor in the JRE-managed HiDPI mode is determined by the following settings, in order:
- If the system scale factor is forced via -Dsun.java2d.uiScale property - it's just used.
- The following GSettings are considered (use dconf-editor to edit):
Per-monitor DPI key (Wayland, not well supported yet):
Global DPI key:
(These keys, used since OpenJDK 9, are currently disabled in JBR 11:
- If GDK_SCALE environment variable is set, the above scale factor is multiplied by it.
See: https://developer.gnome.org/gtk3/stable/gtk-x11.html .
This can be unexpected and there're the following options to cope with it:
- Compensate it via setting GDK_DPI_SCALE env variable (since 2019.2.1).
- Unset GDK_SCALE before starting the IDE.
- Force the system scale factor (see 1).
- Switch to the legacy IDE-managed HiDPI mode (see the "HiDPI modes" section).
- If none of the above settings is defined, then the system scale is derived from the Xft.dpi value (e.g. 192 dpi will define 2.0 scale factor).
GDK_SCALE is applied to Xft.dpi as well (since 2019.2.1, see 3).
Note, currently fractional scale factor is not supported on Linux in the JRE-managed HiDPI mode. So if Xft.dpi defines a fraction scale, then the IDE is automatically switched to the legacy IDE-managed HiDPI mode (and the GDK_SCALE is not applied).
- If none of the above settings is defined, then the system scale factor is set to 1.0.
On Linux desktop environments other than Gnome, IDE still behaves like GDK application obeying the HiDPI settings above.
Guide: https://wiki.archlinux.org/index.php/HiDPI .
Per-monitor DPI is supported since JBR 8. Configured as scale factor in Display Settings system dialog.
Guide: DPI Scaling in the Windows 10 Anniversary Update .
Per-monitor DPI is supported since JDK 7. Currently, the system scale factor is either 2.0 on Retina and 1.0 on a standard display.
Please sign in to leave a comment.
Using linux mint 19 on a macbook pro retina mid 2015, (window of intellij and font where tooo small) used a combination of:
on: Help -> Edit custom vm options (idea64.vmoptions file)
To correct retina display, adjust the font of the editor , worked fine for me
On Linux + Gnome, when I undock from my Thunderbolt dock the scale of the system changes from 100% to 200%, perfect as my laptop is a much smaller screensize with same resolution. Other apps such as Brave/Chrome instantly honor my new system scale. But IntelliJ does not, and I have to "just restart" to get the new scale to take effect. We need IntelliJ to update as soon as system scale changes, not just on launch.
I just found this article after realizing what was going on and doing some searches and I will tinker with the options here to see what I can find out. Thanks for posting it.
UPDATE: Found an issue filed for this via https://intellij-support.jetbrains.com/hc/en-us/community/posts/360000629184/comments/360000394760 > https://youtrack.jetbrains.com/issue/IDEA-194145. I am engaging there now, the suggestion doesn't yet work for me yet, follow that thread for updates if you have same issue.
I've answered you in IDEA-194145.
I am running latest Intellij IDEA in WSL2. I have a 4k monitor, and have set scale to 150% on Windows. To achieve the same thing with the X Server, I have set GDK_SCALE=2 & GDK_DPI_SCALE=0.75. All gui apps running on WSL adjust fine, except for Idea which scales to 200% instead of 150%.
Below you can see the HiDPI Info. I have tried many combinations of all possible scale parameters but with no luck.
I filed a new issue.
Please, vote and follow for updates. If you aren't familiar with YouTrack, see this instruction.
I can only underline, what Serge Baranov writes here, that fractional scaling is not yet well supported in Wayland.
I am using a 4K display with 150% scaling and when starting IDEA under Linux Mint everything looked fine. In Ubuntu everything looked blurry. The reason is, that Mint uses X11 (Cinnamon does not support Wayland yet) while Ubuntu uses Wayland by default.
I played around a lot with different settings and came to the conclusion - and this is my personal recommendation - that IDEA works best under X11 if fractional scaling is needed. If that is true for you, switch your Gnome session to X, set the fractional scaling again system-wide, and everything should be fine out of the box. Make sure you undo your previous settings changes as well (GDK*SCALE, dconf, idea64.vmoptions).
If you do not need fractional scaling I found IDEA to also look well with Wayland and 200% scaling (and factional scaling turned off).
To switch to X on Ubuntu, logout, click on the gear icon in the bottom right corner and select "Ubuntu on Xorg".
The simple reason seems to be that IDEA is Swing/AWT based, which itself is not ported to Wayland yet. Therefor XWayland is used, which itself has its limitations, especially with fractional scaling, multiple monitors or resolution changes.
Some interesting links in the context, if someone wants to dig deeper:
https://openjdk.java.net/projects/caciocavallo/ - Caciocavallo: Portable GUI Backends (OpenJDK project)
https://stackoverflow.com/a/66333053 - points to an experimental AWT implementation using Wayland
https://gitlab.freedesktop.org/xorg/xserver/-/issues/1054 - in XWayland scaling cannot be turned off on a per-application basis (open issue)
https://wiki.archlinux.org/title/Weston - Weston - can be used for experiments with Wayland
I think that the "Monitor Scale" parameter is the one that causes your issue. I did not try under WSL yet, but "native" Ubuntu creates me a file ~/.config/monitors.xml. If you have this file you could try to configure <scale>1.5</scale> there (+restart WSL). A further step could be to remove the GDK_SCALE setting, too.
I have a two display: 15" 4k (laptop, scale at 200%) and 32" 4k (scale at 100%)
Whit default options looks good in laptop display, but too big in external one.
So made this for the external monitor (you have to undo this and restart the ide if want to use the other monitor)
Add this vmoptions:
And increase font size to 17 in Appearance & Behavior > Appearance > Font Size
And increase font size to 18 in Editor > Font
this option makes me happy as never before, many thanks for such option, but it will be very good if it will be possible to configure from GUI