Change Dots per Inch - X Window


DPI stands for Dots Per Inch.

After changing resolution using xrandr, connecting new screens, etc, sometimes DPI value is messes up.
I find this problem when opening new applications like firefox or thunderbird in ratpoison and stumpwm (font size becomes too small).


Query DPI value


To know curent DPI value for the X server:

$ xdpyinfo | grep dots
resolution: 50x50 dots per inch


Calculate a right DPI value for your screen


Get screen physical size:
$ xrandr | grep -w connected
LVDS-1 connected 1366x768+0+0 (normal left inverted right x axis y axis) 344mm x 194mm

Convert millimeters to inches:
344 / 25.4 = 13.5433

194 / 25.4 = 7.6378



Get current pixel resolucion:

$ xrandr
VGA-1 disconnected (normal left inverted right x axis y axis)
1920x1080 (0x295) 148.5MHz



DPI:
1920 / 13.54 = 141.8020

1080 / 7.6378 = 141.4020


We are going to use 141 DPI.


Set new DPI values


$ xrandr --dpi 141

or

$ xrandr --output VGA-1 --mode 1920x1080 --dpi 141/VGA-1


and restart firefox, or whatever app that has font problems.



REFERENCE


How to find and change the screen DPI?