Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

From Xfce Docs:

In case you want to override the DPI (dots per inch) value calculated by the X-server, you can select the checkbox and use the spin box to specify the resolution to use when your screen renders fonts.

But how does X-server do its calculation? What assumptions are made in the process and can some of the parameters be overridden?

It may know how many pixels I have on my display, but is that enough?

share|improve this question
add comment

3 Answers

How does X-server calculate DPI?

The DPI of the X server is determined in the following manner:

  1. The -dpi command line option has highest priority.
  2. If this is not used, the DisplaySize setting in the X config file is used to derive the DPI, given the screen resolution.
  3. If no DisplaySize is given, the monitor size values from DDC are used to derive the DPI, given the screen resolution.
  4. If DDC does not specify a size, 75 DPI is used by default.

It may know how many pixels I have on my display, but is that enough?

No, it not only knows the virtual screen size in pixel but (usually) also physical display size in millimeters. You can check your display dimensions by running the following in a terminal window:

 ~ $ xdpyinfo | grep dimension
dimensions:    1366x768 pixels (361x203 millimeters)

The calculation which is your X server doing is the following:

  • 1366 pixels divided by 361 millimeters multiplied with 25.4 millimeters per inch = 96.11191136 dots per inch (DPI).
  • 768 pixels divided by 203 millimeters multiplied with 25.4 millimeters per inch = 96.09458128 dots per inch.

You can check what DPI your X server has calculated using the following command:

 ~ $ xdpyinfo | grep resolution
 resolution:    96x96 dots per inch

Looks good, doesn't it?

For further reading:

share|improve this answer
    
@alois-mahdal I guess I misunderstood the question at first. I've improved the answer adding the display dimensions used by X server. –  vertoe Jul 23 '13 at 11:38
add comment

As far as I know, starting with version 1.7, xorg defaults to 96 dpi. It doesn't calculate anything unless you specify DisplaySize via Xorg config files. Also, don't rely on xdpyinfo output.
My laptop runs on Intel SandyBridge. Excerpt from my Xorg.0.log on a fresh Archlinux install:

(==) intel(0): DPI set to (96, 96)

running

xdpyinfo | grep -E 'dimensions|resolution'

returns:

dimensions:    1600x900 pixels (423x238 millimeters)
resolution:    96x96 dots per inch

which is far from being true. I know that my screen size is 344x193 mm so obviously xdpyinfo calculates the physical size based on pixel resolution (1600x900) and default 96 DPI. If I add

........
DisplaySize     344 193
........

in /etc/X11/xorg.conf.d/monitor.conf and restart, Xorg.0.log correctly reports:

(**) intel(0): Display dimensions: (344, 193) mm
(**) intel(0): DPI set to (118, 118)

However, xdpyinfo | grep -E 'dimensions|resolution' always returns:

dimensions:    1600x900 pixels (423x238 millimeters)
resolution:    96x96 dots per inch

Still, no visual changes as I'm using Gnome, and 96 DPI is also hard-coded in gnome-settings-daemon. After patching the latter, I can enjoy my native 118 DPI. But even after all that, xdpyinfo still returns:

dimensions:    1600x900 pixels (423x238 millimeters)
resolution:    96x96 dots per inch
share|improve this answer
add comment

Dots Per Inch = Dots ( pixels ) / Inches ( physical size of monitor ).

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.