X text rendering ugly if any non-generic driver used

xorg

My Linux system has a graphics card that identified itself as "[AMD/ATI] Kaveri [Radeon R4 Graphics]".

If I run it with the default/generic driver (blacklist radeon and fglrx modules), fonts on X look great – letters are solid black or solid white and easily readable.

If I use either the open-source "radeon" or the proprietary "fglrx" driver, text becomes ugly – for example, the top bar of the letter "T" will be made up of some black pixels and some gray pixels. This doesn't seem to be specific to any one desktop environment or program, the text gets ugly anywhere. There may be subtle differences in the way images are displaying too, but it's hard to tell for sure.

I've confirmed that screen resolutions and DPI are the same in all cases, and looking at output from fc-match it doesn't look like there's any differences with hinting/anti-aliasing/etc. being turned on/off.

The ugly text is exactly the same (down to the same pattern of the grey dots in the letter "T") whether I use "radeon" or "fglrx", which leads me to believe it's not actually an issue with the driver, but with something X is doing. Eg. X is saying "I have detected that there is a driver capable of using $feature, I will now turn $feature on." and whatever that feature is has the side-effect of making text look ugly.

I know there are a bunch of guides out there for how to make Linux fonts look nicer (not having much luck with those so far), but what I would really like to know is what X is doing differently when I have the radeon or fglrx module loaded — if I could just get it to stop doing whatever-that-is and display my text the same way it does when treating my card as a generic card, the text would look great.

Any ideas what X might be doing differently between these scenarios and how to get it to stop?

Best Answer

Finally figured out the problem - it was a DPI thing.

With no radeon or fglrx driver, the default DPI was 102x102, with either driver loaded it was setting the DPI to 96x96. When I tried using xrandr to set the DPI back to 102x102, it wasn't fixing the fonts because fonts in programs that were already running were not affected by the change.

Finally tried launching X by hand after editing my startx script to include "-dpi 102" in "defaultserverflags" and X then did start at 102x102 DPI, and text looked fine.

I still don't understand why the difference between 96x96 DPI and 102x102 DPI would make black letters develop gray patches, but at least I know how to fix it now!

Edit: To add some more details for anyone who Googles across this later with a similar issue:

  1. Editing startx is a troubleshooting measure that doesn't make a permanent change (unless you normally start X from the command line). To permanently change it, I had to edit /etc/lightdm/lightdm.conf and set xserver-command=X -dpi 102 . This may differ depending on what login manager you use (gdm, kdm, etc.) but they should all have an option somewhere for what commands to pass to X when starting it, and that is where you want to change your DPI. You cannot change your DPI in xorg.conf or xorg.conf.d, as discussed here and here.

  2. There is another setting, Xft.dpi, that tells the Xft what DPI to use for fonts. If this is not set anywhere, it should default to the same DPI X is using (I think). If it is set, you should be able to see what it is set to using "xrdb -q". It sounds like this setting can be changed in ~/.Xresources, ~/.fonts.conf, or your system-wide fonts.conf (distro-dependent location). I did not end up having to mess with this to get mine working, but wanted to include this in case it helps someone who Googles across this later.

  3. 102x102 happened to be the correct DPI for my screen, but that doesn't necessarily mean it will be for yours. Consult the documentation for your monitor or try some different values to see what works for you.

  4. It is also worth mentioning that the font configuration article at the Arch Linux Wiki is incredibly detailed and useful for a variety of font-related issues, regardless of what distro you actually use.

Related Question