Today, I’d like to share a tip I found out while working with a beta release for a distirbution of Linux with KDE’s 3.5.7 version. As many readers of this blog know, I use PCLinuxOS 2007 as my main desktop and have done so since about 2005. The font configuration in PCLinuxOS is quite nice. I have a 19 inch LCD Monitor at home with 1280×1024 resolution. I notice no problems with the font on that monitor.
Working on a separate 20 inch monitor with a distribution in development however is another story. The fonts didn’t look beautiful at all. After some installation of custom fonts, things looked better, but the resolution is a bit higher on this LCD at 1400×1050. Easy to fix right? Just increase the DPI in the KDE Control Center to 120 right? Not so fast…even when it’s set to 96×96 there, it isn’t always set to 96×96. So let’s take a look at how you can force KDE to run at the correct DPI for your monitor which will, in turn, make your fonts look MUCH better. For those of you who are satisfied with your fonts, you might want to check out the commands below to see if you’re running at the DPI you think you are.
Open Konsole and let’s check your resolution:
xdpyinfo | grep dimension
This will tell you what the actual resolution of X is on your desktop. Next, look at the DPI setting.
xdpyinfo | grep resolution
Surprised? I was. I found that at the high resolution I was running at, the DPI was set to 86×86 despite my attempts to force it to 96×96 in the KDE Control Center.
So how does one combat this? It takes a bit of calculation with a formula followed by a one line entry into your xorg.conf. Easy enough? Almost too easy…couldn’t the KDE programmers, say, employ a control center menu for this? It’s possible…let’s hope it’s in KDE 4.0.
First, the formula. Using the dimensions you found above, you’ll have to calculate 2 numbers…one for horizontal and one for vertical. As my resolution is 1400×1050, I will use this as the example. The formula is as follows:
displaysize = (<pixelsize>/DPI-Desired)*25.4
In my case, displaysize = (1400/100)*25.4. This equals 355. I wrote this down for later. Now I need to use 1050 (my vertical setting for resolution 1400×1050) in the same formula (displaysize =(1050/100)*25.4) which comes out to 266. Keep these two numbers handy…remember, if you want 96 or 120 DPI for your monitor…sub in those numbers for the DPI-Desired and divide your resolution by them as shown in the formula above.
Open up xorg.conf in your favorite text editor..for example, my favorite is kate so I issue the following command: Alt-F2 (a run dialog pops up) >> kdesu kate /etc/X11/xorg.conf. You’ll be prompted for your root password to access this file. After it opens, find the “Monitor” section. Just before “EndSection” place a line like the following (substitute the values you found using the formula above):
DisplaySize 355 266 # 1400×1050 100dpi
Your display size may be different…just remember to place horizontal first, followed by vertical. Now you’ll need to restart X. Close all your applications and hit Control-Alt-Backspace. Log back in and issue the command we used previously for DPI:
xdpyinfo | grep resolution
If you followed the directions above correctly, your altered DPI settings should display. Gnome does this through a handy menu that’s very easy to use. It’s head and shoulders above what KDE does with fonts and setting DPI. Using Gnome at work for the past 4 months has shown me the many areas that KDE falls behind…but it also shows me the many areas where Gnome just doesn’t get the job done. In this case, KDE fails horribly on configuring DPI for nice looking fonts. Luckily, I was able to assemble information from various places on the web to get the job done. The page that helped me the most was Matt Parnell’s Brain, a weblog that had an entry with this formula. I wanted to reproduce the information here with a bit more hand holding so new users would be able to use the tip without getting confused. Hopefully, this helps!
This content is published under the Attribution-Noncommercial-Share Alike 3.0 Unported license.