HiDPI configuration

HiDPI modes

  1. 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).

  2. 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

  1. 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>
    (e.g. -Dide.ui.scale=1.25).

  2. 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>
    (e.g. -Dsun.java2d.uiScale=1.75).

    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.

Linux

JBR 8

Single-monitor DPI is supported. DPI is defined by Xft.dpi X resource value.

To get:

$ xrdb -q | grep -i dpi

To set:

$ xrandr --dpi <dpi>

It can also be set via your Linux Desktop settings, or via gnome-tweak-tools.

JBR 11

The system scale factor in the JRE-managed HiDPI mode is determined by the following settings, in order:

  1. If the system scale factor is forced via -Dsun.java2d.uiScale property - it's just used.

  2. The following GSettings are considered (use dconf-editor to edit):

    Per-monitor DPI key (Wayland, not well supported yet):
    ubuntu.user-interface/scale-factor

    Global DPI key:
    org.gnome.desktop.interface/scaling-factor

    (These keys, used since OpenJDK 9, are currently disabled in JBR 11:
    com.canonical.Unity.Interface/text-scale-factor
    org.gnome.desktop.interface/text-scaling-factor
    ).

  3. 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).
  1. 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).

  2. 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 .

Windows

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 .

macOS

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.

23 out of 50 found this helpful
14 comments

Using linux mint 19 on a macbook pro retina mid 2015, (window of intellij and font where tooo small) used a combination of:

 -Dhidpi=false

-Dide.ui.scale=2.0

on: Help -> Edit custom vm options (idea64.vmoptions file) 

To correct retina display, adjust the font of the editor , worked fine for me

2

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. 

Edited by Elijah Lynn
0
Avatar
Permanently deleted user

Hi Elijah,

I've answered you in IDEA-194145.

Edited by Permanently deleted user
0

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.

1
Avatar
Permanently deleted user

Hi Liakoskonstantin,

I filed a new issue.

Please, vote and follow for updates. If you aren't familiar with YouTrack, see this instruction.

 

0

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

Edited by Harald Fassler
0

Liakoskonstantin

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.

0

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:
-Dsun.java2d.uiScale.enabled=true
-Dsun.java2d.uiScale=1

And increase font size to 17 in Appearance & Behavior > Appearance > Font Size
And increase font size to 18 in Editor > Font

1

-Dsun.java2d.uiScale.enabled=false

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

Edited by Paulus Gn
2

Recently updated to 2023.3 new IDE for DataGrip and PhpStorm on Kubuntu with KDE Plasma display global scale at 150%.  PhpStorm IDE looked correct but DataGrip looked like it was ignoring Kubuntu's global scale.

I set -Dsun.java2d.uiScale.enabled=true and DataGrip started to honor the global scale once again.  According to the documentation above (and prior experience), this should be the default, but it appears to not be in the new IDE for DataGrip.  Again, PhpStorm worked as expected.

Detailed specs: Currently running 2023.3.2, Build #DB-233.13135.68, built on December 14, 2023.  Using DataGrip and PhpStorm in a Kubuntu VM (22.04 with KDE Plasma 5.24.7, KDE Frameworks 5.92.0, Kernel 5.15.0-91-generic (64-bit), Graphics Platform X11) on VirtualBox 7.0 (v7.0.12 r159484) hosted on Windows 11 Pro (23H2, 22631.2861) with Kubuntu Display Configuration at 3840x2400 and Global scale at 150%.

1

Fractional scaling is not working for DataSpell after 2023.1.5 on Ubuntu 22.04 Gnome.  It is working across the other Jetbrains products I use, Goland, PHPStorm, PyCharm.

edit: the global method does not work, but the IDE-specific *does* work

Edited by Wes Nichols
0

Currently on Kubuntu 24.04 wayland beta (just 5 days away from the official release). IntelliJ and Pycharm 2024.1 don't seem to scale. Tried the -Dsun.java2d.uiScale.enabled=true command and did nothing. Tried changing -Dide.ui.scale=1.75 and the ui scaling changed, but of course the fonts were microscopical. Also tried -Dsun.java2d.uiScale=1.75 and again did nothing.

Edited by Hmacias54
1

I dont use fractional scaling on ubuntu, so 100% is too small and 200% is too big. In PyCharm & other ide you can change scaling in settings → Appearance → Accessibility → Zoom. For a 4k 28in monitor I find 150% is good. 

2

Just installed JetBrains, everything is TINY (fonts/elements etc).

Looks like i need to read a whole bunch of stuff about graphic, compatibility with libraries, settings etc. WHY?

Really not interested in  that stuff.

Can't you make it like VS Code?? It starts then it works. 

1

Please sign in to leave a comment.

Have more questions?

Submit a request