system: Ubuntu 20.04.3 LTS
The default Resolution is 1280x720, the DPI is 96.
When adjust the 'fractional scaling' is 125%, I have two options to get the DPI:
Use the command: xrdb -query |grep dpi
the DPI is 192 ??!
Xft.dpi: 192
Use the command: xdpyinfo, the DPI is 120.
screen #0:
dimensions: 2048x1152 pixels (433x244 millimeters)
resolution: 120x120 dots per inch
Why the two commands return different DPI ?
When scaling to 125%, Why the dimensions is 2048x1152 ? (2048/1280 = 1.6, 1152/720 = 1.6)
Is the X11 API is wrong or other problem? Thanks.
Strictly speaking neither xrdb nor xdpyinfo are the right place to query the screen's pixel density.
xrdb shows you a DPI value, since it's the place where one can (but is not required to!) set a overriding DPI value for Xft, and some desktop environments to, just "because". xdpyinfo shows mostly values that already did exist waaay back in the original X11 core protocol, where one could also specify physical dimensions of a screen. The problem is, that on modern systems, which are capable of dynamically attaching and removing displays, things are done through XRandR and the capability to drive multiple X11 screens on the same X11 display no longer is used (it's all just one large X11 screen now). So depending on how you configured your monitors, the values reported by xdpyinfo are off.
To arrive at the correct pixel density, one must use XRandR (CLI query/set tool name is xrandr) to retrieve information about the physically connected displays. However be advised that it is perfectly possible for several displays of different pixel density to show overlapping regions of the X11 screen, and within those regions there's no unambiguous DPI value available.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With