APR
29
2008

How to change the X11 DPI under kUbuntu

I don't know why, but often I have the impression that KDE fonts are quite big, and this can be changed by modifying the X11 dpi settings.

Let's head over to good old Slackware. How is it done here ?

Enter /usr/bin/startx, which starts since ages with
"# This is just a sample implementation of a slightly less
# primitive interface than xinit.
...
# Site administrators are STRONGLY urged to write nicer versions.
"

At the end there is the line:
xinit $client $clientargs -- $server $display $serverargs

If I append e.g "-dpi 75" to this line (or set it correctly in one of the args), X will start with this dpi setting.

Now let's try the same with (k)Ubuntu 7.10. /usr/bin/startx looks just the same, including the comments that the site administrator should do something. What happens if we append -dpi 75 here ?
Nothing.
Why ? Because, as I found out, xinit reads here /etc/X11/xinit/xserverrc, which looks like this:

exec /usr/bin/X11/X -dpi 100 -nolisten tcp

So the dpi is already set here. So let's change it here too. Now, voila, if I run startx, X starts with 75 dpi :-)

Ok, next step. Now I login via kdm. Again I'm back ti 98 dpi. So it seems here it works in some other way.
How to find out ?

$ cd /etc
$ grep -Ri dpi *

which yields /etc/kde3/kdm/kdmrc with this line:

ServerArgsLocal = -nolisten tcp

So here X starts without special setting and defaults to 98 dpi. So let's append -dpi 75 here too and restart kdm.

Now, kdm starts with 75 dpi (and small fonts), so I continue and login to KDE. What do I see ? Big fonts, i.e. it still looks like 98 dpi. What does kinfocenter (or xdpyinfo) say ? Both report 75 dpi.
Now this seems weird. X reports 75 dpi but fonts look like 98 dpi ? Hmm.

Let's try again, maybe there is something more:

$ cd /etc
$ grep -Ri dpi *

Indeed, there is also a /etc/X11/Xsession.d/40guidance-displayconfig-restore, which talks about DPI. And it calls /usr/bin/displayconfig-restore. Now let's see what this does. It is a pyhon script, and it has a function FixXorgDPI. This function sets the dpi according to some calculations. Disabling this function (e.g. by inserting return right at the beginning) helps, finally kdm and KDE and X start with 75 dpi ! :-)

Conclusion ?

It may have been meant good, but please, don't implement hacks which circumvent the normal system tools. If I set all possible parameters to the dpi value I'd like to have, I don't want some clever custom script to completely ignore what I said explicitely.

Alex

P.S. I guess the same is true for NetworkManager, which sits in the background and fiddles around with network interfaces, making it impossible to manually debug problems...

Comments

I have a feeling that your 98 dpi is probably actually quite correct. Well, okay, generalisation here, but that’s exactly what my display reports to X, and after some calculations based on the display’s pixel size (as written in its manual), it turned out to be indeed true. There should be no need for you to fiddle with it, change your font sizes instead.


By ralesk at Wed, 04/30/2008 - 00:11

Yes, 98 is probably actually correct. Still I think it's strange that font size 9 gives relatively big fonts, so that I'd like to have them smaller. But the next smaller step is 8, which is 11 % smaller, which is a lot.
10 or 11 alway gave nicely sized fonts, and 8 was always quite small. I get that behaviour back if I set the dpi to 75.

Beside that, that was actually not my point.
My point was that the (k)ubuntu developers first hardcoded the dpi in multiple locations, and as if this wasn't enough, additionally run a tool which overrides that setting again. This makes all your X knowledge in this regard worthless.
Distros shouldn't do that.

Alex


By Alexander Neundorf at Wed, 05/07/2008 - 22:27

Imagine if someone climbed a challenging mountain, and he had some problems with his gear on the way. Afterwards, he contacts the gear manufacturer to ask them to change some things. Lo and behold, the gear manufacturer writes back and says, "Why are you climbing THAT mountain? There is no need to."

That's what your response sounds like to me.

I understand that KDE's developers want it to work out of the box for as large a user base as possible. These kinds of hacks may be appropriate to make that happen. However, there ought to be clear documentation available for those who are used to making these customizations in the standard way.


By Marc at Thu, 11/13/2014 - 22:47

Have you tried
% echo "Xft.dpi: 75" | xrdb -m -


By miffe at Wed, 04/30/2008 - 00:41

Don't set your DPI manually. Set the DisplaySize in xorg to the proper size of your screen and you will get the correct DPI. If the fonts are too big at that DPI, then change the font size. A font point is a physical measure (1/72 inch) so 10 pt font should be the same size on every screen. If it's not, your screen configuration is wrong.


By leos at Wed, 04/30/2008 - 01:49

It is not very difficult to get the correct DPI setting for a dimension. For a visible screen area that has a height of H inch and a width of W inch and for a PX x PY pixels modeline, the resolution in X-dimension is

X-DPI = PX / W

and for Y-dimension

Y-DPI = PY / H

The advantage of xorg is that one just enters W and H in milimeters as DisplaySize into xorg.conf and one always has the correct resolution.


By ponto at Wed, 04/30/2008 - 12:33