Skip to content

Gamma, fonts, and DPI…

April 20, 2011

A previous endeavor that I invested too much time in was getting TTF rendering on my LCD screens to look crisp and amazing (mostly fueled by the boyfriend’s amazing looking Droid screen when he first got it). The endless tweaking of .fonts.conf only yielded “decent” values. Making regular fonts look good made bold fonts look malformed, making bold look good made regular fonts look blurry, making both look good made fonts on dark backgrounds look awful, and so on. I had to settle on all around “acceptable” settings to keep my sanity. I know this is why people use bitmap fonts and avoid XFT, but I’m not as big a fan–I prefer blurry over blocky.

I figured out this had to do with DPI also. Despite having read that X should properly calculate DPI, I have found across different distributions, versions, different video cards, and different monitors that X always sets it to 96. On my old laptop, I figured out it had a 114 DPI screen, and figured out I could set it manually in xrandr. However, that large of a DPI shift made my fonts look huge, and after adjusting all the sizes, I didn’t see a noticeable difference. Thus, I didn’t bother.

I recently began using ‘arandr’ for more than just changing displays easily after realizing it’s “Save Layout” function creates a shell script that simply executes the appropriate xrandr command to get that setup. I just added a ‘–dpi xxx’ to the end from my computed DPI, and had the script executed from my WM startup script.

Fast forward to switching to my new T410, which after a few days I noticed was very ‘blue’. When I tried to set my favorite wallpaper (mostly brown), and noticed it was flat and almost gray, I decided I had to do something about this. I found the easiest way would be to use xgamma, and with the help of this site I set off to correct my gamma and color levels, after quickly adding the xrandr dpi setting to my startup script (didn’t bother putting it in until now)

What a nightmare! I am not joking about how tedious and difficult this is on a laptop LCD. By the time I got what looked like decent levels (all colors at 2.2 gamma), my grays looked brown and my browns looked purple. Manually adjusting from that point to where the colors I cared about looked right did not match on the color gamma levels. This is likely due to our eyes being more sensitive to green, and the least sensitive to blue: the author of that page notes he ignores the blue one because it is too dark. At this point I settled on (RGB) 0.75, 0.70, 0.65. Things looked right and that was good enough for me. I shutdown and went to sleep.

I write this the morning after, having booted into not only the changed DPI setting, but also the corrected gamma levels and have to say, it looks awesome. Between the higher DPI and better gamma levels, my font’s look much crisper and cleaner, and my colors look correct and not washed out. I am very pleased.

Story aside, the settings I used to get to this point follow. A quick note: I know there are system wide ways to change these values, but as stated in previous posts: I’m a big fan of local home directory alternatives. This involves less sudo/su to root privileges, less tweaking of system files, and also the ability to easily rsync between different computers as a regular user.


<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
	<!-- Set Droid fonts as default Sans/Serif fonts -->
		<prefer><family>Droid Serif</family></prefer>
		<prefer><family>Droid Sans</family></prefer>

	<match target="font">
		<edit name="autohint" mode="assign"><bool>false</bool></edit>
		<edit name="antialias" mode="assign"><bool>true</bool></edit>
		<edit name="hinting" mode="assign"><bool>true</bool></edit>
		<edit name="hintstyle" mode="assign"><const>hintfull</const></edit>
		<edit name="lcdfilter" mode="assign"><const>lcddefault</const></edit>

	<!-- Helvetica is a non true type font, and will look bad. This replaces it with whatever is the default sans-serif font -->
	<match target="pattern" name="family" >
		<test name="family" qual="any" >
		<edit mode="assign" name="family" >

~/.screenlayout/ (The arandr script, for DPI)

xrandr --output LVDS1 --mode 1280x800 --pos 0x0 --rotate normal --output VGA1 --off --dpi 107

~/.config/i3/config (Partial, startup apps plus gamma settings, can be in any startup scipt such as .xinitrc)

# Startup Programs
exec ~/.screenlayout/
exec xgamma -rgamma 0.75 -ggamma 0.70 -bgamma 0.65
exec nitrogen --restore &
exec i3status | dzen2 -ta 'r' -bg "#3a3a3a" -fg "#ffffff" -fn "-*-terminus-*-*-*-*-12-*-*-*-*-*-iso10646-*" &
exec xscreensaver no-splash &

From → Anecdotes, Howto

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s