Linux
About DPI in general and HiDPI in particular
DPI (dots per inch) is a quantity that tells how much Pixels of the screen are the physical centimeter of its area. If the monitor works in non-native resolution, then it is a question of virtual resolution pixels. Since ancient times and until very recently, the value of 96 DPI was the standard – that is, conventional monitors, if different from it, are so much that it could be neglected. 120 DPI was once the maximum value that was usually tested.
Not surprisingly, for so many years, software developers have adopted this value for an unshakable constant. Suddenly came monitors with 160-192 DPI and started. All the programs that at least some size in the interface were set in pixels, got panels colliding on each other, signatures cut off to the first letter, and buttons, for successful pressing of which it is necessary to give a cash prize.
The word HiDPI refers to the situation on monitors with DPI> 160. The DPI of the operating system is not necessarily equal to the DPI screen. On the contrary, DPI systems can be twisted to make the interface larger-smaller. Moreover, the systems distinguish DPI in total, DPI fonts and DPI, given to full-screen applications.
What about the others?
Makos rescued her authoritarian rule. Since almost all programs create their own interface through the same API, it was simply corrected, and it turned out Linux right away. Separate ineradicable shoals only emphasize, as far as everything is generally good.
Android was born on systems with a large spread of DPI, so I could do everything from the very diapers, and the textbooks for programmers took this into account.
Windows allowed to rotate DPI fonts at all times. That’s only DPI graphics from this did not change. Individual elements changed in size because they are tied to the font size, or the screen. But the dimensions given in pixels, from this did not move. In Win 10, at last, normal HiDPI support appeared, but only for programs written for Win 10. For the rest, a crutch is created that simply zooms the program window to translate the position of clicks. The magnification makes the window blurry, and the translation works crookedly. Worse, this increase tries to start for full-screen applications too, so to play it, it needs to be turned off, and to work – to turn it on.
What about Linux?
And in Linux, as always, Bacchanalia. We have two major sets for the GUI (Qt and GTK), each of which has relatively recently survived the rewriting from scratch, so the old and new version is still in process. Plus several smaller sets (EFL, wxWidgets). Plus several languages that use their own means, for example Java. Plus a few ancient libraries, on which no one is writing, but the necessary software on them still happens. (GTK 1, Motif) Even if the X server and window manager correctly handle the DPI, it’s not a fact that the whole zoo will accept this information and will work fine.
You can much for not loving Ubuntu with Unity, but one thing I have to say. I do not know how to configure HiDPI in Unity because everything always worked out of the box. All other DE: Cinnamon, KDE, XFCE, also have a corresponding checkbox. This flag configures DE itself, applications written on its main library (only new version) and a couple of flags for Qt / GTK. And the rest is all poboku. As a result, for example, in the players, the Play button remains tiny. And the icons in the tray are small, but not all. A year after such a system – and a man in Overwatch plays only for MacKryak, because a person has pixelike accuracy on the mouse and he hates everybody.
I will tell you how to configure KDE. Not as in the instructions, but so that everything works. Deadbeef, Yakuake, Blender. I checked this, mainly in Arch. In other distributions, it may be that something I describe is already done or done differently. Think with your head or write in the comments – we’ll figure it out.
Setting the X-Files
The first thing to check, but do Iksi know that we have HiDPI? For this we need a softphone xdpyinfo
– it is in turnip. Set, if not installed, the native resolution of the monitor, (and restart the X-boxes). Run in the console inside the iks (that is, not by Ctrl-Alt-F *)
xdpyinfo | Grep -B 2 resolution
Screen # 0:
Dimensions: 3840x2160 pixels (621x341 millimeters)
Resolution: 157x161 dots per inch
We see three pairs of values-screen resolution, real screen sizes, and DPI (separately vertically and horizontally) If all three pairs look like the truth, then turn away from the monitor and give praise to the higher essence Of your choice; For if xdpyinfo returns a nonsense and DPI = 96, then your higher essence sends you a toll.
The most common causes of incorrect DPI are EDID curves and branded firewood video cards. About the ATi video card I will not say anything, because I’m looking for them. Not that they are anything bad, but ATi + Linux = unnecessary problems. C Intel should work for itself. NVidia also until recently persistently poganila DPI. First, disable G-sync in nvidia-settings
still no compositing manager is friendly with it. If it does not work, turn on KMS. Kernel Mode Setting is the method by which the screen resolution is controlled by the Linux kernel, not by Iksy. In addition to direct assignment, this allows you to bypass a lot of buggy code 20 years ago in Iksah. Unfortunately, the procedure for including KMS on Nvidia’s proprietary drivers is dependent on the distribution, so I will only describe in general terms. Add modules nvidia, nvidia_modeset, nvidia_uvm, nvidia_drm
in initramfs, rebuild it, and then add the parameter nvidia-drm.modeset = 1
to the kernel. Googlite.
If in the previous paragraph you did not understand anything, then you can simply abandon the NVidia branded firewood and use Nouveau for the time being – there is KMS out of the box. In Kubunt, this is done through a program that manages the drivers.
If all of the above did not help and xdpyinfo still writes garbage, then maybe it’s not the video drivers that are to blame but the EDID curves of the monitor. First run in the same console
xrandr --dpi 192
And run some program. If it is bigger, then the method works. Paste this command in .xprofile
and restart the X-boxes. In the future I will talk a lot about .xprofile
. This file is in the home folder of each user, which configures the operation of the graphical applications. If it does not exist, just create it:
touch ~ / .xprofile
If it works, Hurray! If not, first check that your distribution from KDE does not have the support .xprofile
. For this, add something like
touch ~ / net_ne_vyrezali
and reload it again.
Still does not work? Let’s write the DPI to the ICs manually. Create, if not already, the file /etc/X11/xorg.conf.d/90-monitor.conf and write in it
Section "Monitor"
Identifier "Prikolny monitor"
DisplaySize 286 179 # In millimeters
EndSection
And for company firewood Nvidia
Section "Monitor"
Identifier "Prikolny monitor"
Option "DPI" "192 x 192"
EndSection
Please note that everywhere I force the DPI value to 192, more precisely to any value that is a multiple of 96. It works more accurately than the actual DPI, because the gladiolus. Here the paradox of the designer works:
- If DPI is a multiple of 96, fonts in applications working with text are better rendered. Especially in applications on Cairo.
- If the DPI is equal to a real DPI monitor, then the 1: 1 scale on the screen will be the same size as on the paper.
The stupid name of the monitor I wrote, so that in all graphical utilities it was clear that our setting is read and tries to apply.
We save, restart the X-Files and exult. Or we drink bitter and wait for Wayland to finish it.
Setting in KDE
So, finally, configure HiDPI in KDE correctly. In the menu → System Settings → Display and Monitor there is a large button at the bottom Scale Display . By pressing it, a window opens with a single slider Scale . Now attention! If you still can not configure DPI in X, close this article, put the value of the slider to your liking, and enjoy what works. And that does not work – humble (This is usually Chrome, Skype, QtCreator, Yakuake, GTK)
If the DPI in Ix is correct, then do not touch this slider! Ideally, even, do not twist it back and forth, because it seems he is somewhere writing something while doing this. Close this window nafig. According to the article in the blog of the creator of this slider (salt in comments), it overrides the system DPI and puts a few more variables. The problem is that this overriding is not seen by all programs, and it turns out porridge. Therefore, we will not touch the slider, but we will adjust everything manually.
In general, at this stage, if DPI is correct, then everything should be already quite large. We pass in System Settings → Fonts . By default, there is a font size of 11. If you achieve enough harmony 10-14 – put, the applications will catch up. If more or less – it makes sense to try and pryzhamanit system DPI as mentioned above. Below is the Force Font DPI field. You can tweak it if you want, but keep in mind that not all applications read this value. Not even so. Some applications read this value not with all their parts. So if you try to fix the system DPI in 96, there will be a mess. But to raise the DPI 167 monitor to the ideal 192 can.
Close the Fonts window. In general, now is the time to restart the X-Files and see what happened. Must work and have a handy KDE size, all its settings and applications. The plasma panel, by the way, itself will not grow. But it is vector, and it can always be stretched – click the sandwich on the left and the buttons will appear. The same size in Dolphin must be supplied manually. If somewhere else in KDE applications, the buttons and panels are too small, you need to zoom in on the size of the icons in System Settings → Icons.
Setting up other applications
Chrome, Atom and others
These applications read DPI directly from where it comes from and follow it as a knight to the code. If they read something wrong, then they will look like something wrong. Usually they ignore the settings in System Settings and follow the DPI that xdpyinfo returns. If there is 96, then for Chrome you can use the argument - force-device-scale-factor = 2
; for Atom there is a curve plugin hidpi
in the official turnip, for other programs its crutches.
QtCreator, Yakuake, and other applications on Qt5
In general, they should work. But QtCreator does not have a scale of tools, and Yakuake has a strip with tabs. The cause in the bug and in the environment variable QT_AUTO_SCREEN_SCALE_FACTOR
. When it is 1
Qt5 tries to find the value of DPI itself, and when 0
– waits for this value to be given to it in other variables. The bug is that KDE is sending garbage.
In short, we need to set these variables to the variable QT_AUTO_SCREEN_SCALE_FACTOR = 1
and it will work. This can be done either selectively or globally. Selectively – in the Menu Editor. Just do not forget to add the application again to the panel and into the autorun. This is necessary because the .desktop entries are copied, not linked. The second option is to set this variable system-wide, in .xprofile or even / etc / environment or where in your distribution the variables are written. There are two nuances. First, KDE forces this variable to 0 in the script / usr / bin / startkde . It must be opened and edited, commenting out the line
#export QT_AUTO_SCREEN_SCALE_FACTOR = 0
After this, remember to repeat this fix every time KDE is updated. The second nuance is that KDE developers warn in the comments: setting this variable globally can cause some Qt5 applications to be increased twice. But this does not happen to me. Further, if the system DPI is incorrect, you must set the variable QT_SCALE_FACTOR = 2
in .xprofile
Do not forget that the variable QT_DEVICE_PIXEL_RATIO
is obsolete. If you put it somewhere, you need to remove it.
Applications on Qt4
These applications, in general, poorly know HiDPI. But not all is lost. Qt4 creates a very flexible interface. Start qtconfig-qt4
. First, look at the font and set the convenient size. Then, on the Interface tab, find a crutch called “ Global strut ” (in translation – global crutch.) This setting means that instances of QWidget and its children can not be smaller than this size in pixels, that would not be with them Did. Using Minimum Width you can specify the width of the scroll bars, and using Minimum Height – the height of the toolbars.
Applications on GTK3
Here everything is simple. It is necessary to set two variables in . Xprofile : GDK_SCALE = 2
Command GTK to increase all in 2 times. The value must be an integer. GDK_DPI_SCALE
controls the increase in fonts. If after GDK_SCALE
the fonts turned out to be huge, it is necessary to put GDK_DPI_SCALE = 0.5
Applications on GTK2
Here everything is complicated. GTK2 does not know HiDPI at all. But there is a hack. The software called Oomox is the GTK theme generator (skins). Including, with its help you can collect such a theme under GTK2, which will simulate HiDPI. Or find a topic ready.
Applications on Qt3, Gtk1, Motif
Here everything is quite complicated. There are two possible hacks. First, you can take advantage of the ability of Kwin to increase the entire screen. System Settings → Desktop Effects → Desktop Effects → Zoom . The middle button on the left is the settings, including the keys for turning on and off. The second way is to start the application in the remote desktop server and connect to it locally. I’ll just insert a link to the script, because it’s a separate issue to set it up. Linux Linux Linux
Linux
Java applications
More steep and commercial programs on Java behave like Chrome: read DPI from X and follow it. Programs can be simplified easier with one of two arguments: -Dsun.java2d.uiScale = 2
increases the interface by 2 times, and -Dswing.defaultlaf = com.sun.java.swing.plaf.gtk. GTKLookAndFeel
tells it to use it for rendering in sizes from GTK. Let me remind you that in .xprofile you can create a variable
export _JAVA_OPTIONS = '- Dawt.useSystemAAFontSettings = on -Dswing.aatext = true -Dswing.defaultlaf = com.sun.java.swing. Plaf.gtk.GTKLookAndFeel '
This example includes anti-aliasing in fonts and GTK.
Well, like that somehow.