X DPI Setting – Is It Only for Text Scaling?

dpignu-screenresolutionx11

On Linux the DPI (dot per inch) is set to 96 per default, it can be changed globally on the X start up parameter for instance X -dpi 120

This seem to mainly impact text/font scaling. In comparison when screen resolution (ex 1920×1080) is changed this impact everything (window/text/image/etc).

Is DPI meant only for text scaling?

Best Answer

DPI

DPI stand for dots per inch and is a measure of spatial printing/display, in particular the number of individual dots that can be placed in a line within the span of 1 inch (2.54 cm). Computer's screens do not have dots, but do have pixels, the closely related concept is pixels per inch or PPI and thus DPI is implemented with the PPI concept. The default 96 DPI mesure mean 96x96 vertically and horizontally. Additionally What is DPI and when does it matter? video is very informative.

Resolution

A native screen resolution, represent the number of pixels (X,Y horizontally and vertically) that a screen have physically. For instance a Full HD screen 1920x1080 have a count of 1920 physical pixel horizontally and a count of 1080 physical pixel vertically which mean 2073600 pixels in total for the whole screen.
Compared to the DPI (dots per inch), the resolution is not linked at all to a physical size measurement but is just an horizontal/vertical pixel count.

Xorg, DPI and Resolution

The X server needs, gets and uses the real/guessed screen spatial measurement along with its resolution in order to implement the DPI/PPI feature. On a desktop configuration we do use a screen resolution and a DPI/PPI value, each displayed element (text, application, etc) does implement a sizing mechanism to display its content, most of the time pixels are used this is why the DPI setting does not impact most windows size, because they are implementing a pixel measurement not DPI. On the other hand text/font does implement the DPI/PPI measurement and their size get changed when the DPI value is changed.

Commands and configuration

Changing the DPI with SDDM:

# Edit /etc/sddm.conf with the following
[X11]
ServerArguments=-nolisten tcp -dpi 120

Changing the DPI with Lightdm:

# Edit /etc/lightdm/lightdm.conf.d/lightdm.conf with the following 
[SeatDefaults]
xserver-command=X -dpi 120

Get the current DPI

xdpyinfo | grep dots
xrdb -query | grep dpi

Get the screen measurement

# Note that xrandr Xorg extension does not display an accurate measurement  
xrandr | grep -w connected
# alternative
xdpyinfo | grep -B2 resolution

Get an accurate screen measurement (sudo/root required)

monitor-edid
# or
monitor-edid | monitor-parse-edid
# or
get-edid | parse-edid

Links: 1, 2, 3

Related Question