Intel KMS and setting correct DPI in xorg-server-1.7.x

Today I switched from xorg-server-1.6.5 to xorg-server-1.7.6, as it is now available in portage and considered as stable.

PaweÅ‚ Hajdan’s advice, I’ve found on Planet Gentoo, allowed me to avoid all the driver problems, such as broken keyboard or touchpad.

But a major xorg-server update without any problems would be boring, wouldn’t it?

Awfully small fonts

After the update all fonts became smaller and much harder to read and didn’t look much better after increasing font size in Openbox, GTK, etc… And changing font sizes everywhere is clearly the opposite of a good solution.

Setting correct DPI

To check your current screen resolution, size and DPI, run:

xdpyinfo |egrep 'dimensions|resolution'

You should get something like:

dimensions:    1680x1050 pixels (444x277 millimeters)
resolution:    96x96 dots per inch

The numbers in brackets are your screen size in milimeters.

The xorg-server sets 96dpi by default and the screen size looks like calculated from the resolution and the default DPI settings, and therefore is all wrong.

The easiest way to get your real screen size is to check the screen specs or use a ruler. If you know the proper DPI you may calculate it using formula: x_resolution / dpi * 25.4, and respectively for y_resolution.

Then add DisplaySize x_size y_size to the “Monitor” section in your xorg.conf:

Section "Monitor"
    Identifier   "Monitor0"
    VendorName   "Monitor Vendor"
    ModelName    "Monitor Model"
    DisplaySize  331 207
EndSection

And with KMS you also need to add the Option “Monitor-LVDS1” “Monitor0” line to the “Device” section (notice the LVDS1 instead of LVDS - it’s necessary if you’re using Kernel Mode Setting):

Section "Device"
    Identifier  "Card0"
    Option      "Monitor-LVDS1"  "Monitor0"
    Driver      "intel"
    ...
EndSection

Now you may restart X server and once again use xdpyinfo to check whether the screen’s DPI was calculated correctly.