Howto: Beat Firefox’s UI fonts into submission

If I understand the Mozilla help pages correctly, Firefox (version 2, anyway) ignores your GTK settings for font size, preferring instead to calculate the appropriate sizes against the dimensions given in your xorg.conf file.

What that means is, if your xorg.conf file is hand-edited (like mine, in my Crux system), or if Firefox just doesn’t seem to interpret it properly, you end up with gigantamo UI fonts throughout (the opposite is possible too, but I’ve never had that problem). And if there’s anything I hate, it’s a program that pretends to know more than me about my system! :evil:

Anyway, fixing misaligned or miscalculated UI fonts in Firefox is fairly easy. You have the option of editing all the variables through the userChrome.css file inside your ~/.mozilla/firefox/…/chrome/ directory (you’ll probably have to make that file), but that can be mind-numbing in and of itself. You can get them all aligned and forced to the right size, only to discover a submenu or dialog later, that’s still in Reader’s Digest large print edition mode. For example …

window, input, tooptip, menubar, menubutton, menulist, menu, menupopup > * {
 font-size: 9pt !important

That works … but that’s not all the styles that you need to fix. The Preferences dialog, for example, will still need correction. And input boxes. And button labels. And … :shock:

Here’s what I prefer (it’s Mozilla’s “fallback” solution, I might add): Open Firefox’s guts — the about:config page. Search for “dpi” and you should get a key called “layout.css.dpi”. On my default installation it was preset to -1 — in other words, Firefox calculates the size according to xorg.conf, and ignores the GTK settings. Grr. …

On my lowly 1024×768 screen, setting that value to 75 (the dot pitch of my LCD) instead of -1 made everything lovely again — a nice, properly sized UI font throughout, and without tweaking every css variable to force 9-point Dejavu Sans Serif. Ah, peace at last. … :mrgreen:

P.S.: I should note that I’ve occasionally seen this font contortion issue in other distributions (including Ubuntu and Arch, at times in the past), not just the home-brewed ones.

About these ads

6 Responses to “Howto: Beat Firefox’s UI fonts into submission”

  1. 1 Embedded 2008/01/14 at 4:43 AM

    openSuSE 10.3 distributes Firefox layout.css.dpi to “Integer 0 User”


  2. 2 K.Mandla 2008/01/14 at 8:17 AM

    That might be an even better solution. I’ve also seen on other sites where Firefox 3 defaults to the GTK setting (or at least skins them to something similar — is that right?), which is really the way it should be done. I don’t know why in the world Firefox needs to be special, but it’s easy enough to fix, so I can’t complain too much. ;)

  3. 3 xabbott 2008/01/15 at 11:38 AM

    This works too:
    * {
    font-size: 9pt !important;

  4. 4 bautz 2008/01/15 at 5:52 PM

    layout.css.dpi 0 works in firefox 2 but not in firefox 3…

  5. 5 Chess Griffin 2008/01/27 at 11:55 AM

    Thanks for this. Setting layout.css.dpi to 0 worked for my on my 1024×768 Thinkpad x40.

  6. 6 Jonathan 2008/04/23 at 1:14 PM

    I came across this article when I was trying to convince Firefox to honor the GTK font setting in Openbox.

    Firefox casually ignored anything I tried, including the methods appearing thus far.

    I finally got Firefox to behave by configuring the default fonts in GNOME with the ‘appearances’ applet (gnome-appearance-properties). The relevant gconf that it sets is in ~/.gconf/desktop/gnome/font_rendering.

    I’m pretty sure this is a non-issue if GNOME isn’t installed, as it worked without any complaint on another computer with only XFCE installed.

    While on the topic of configuring fonts, I also came across this article ( on freetype2 configuration. It’s only tangentially related to Mozilla UI fonts, but I found it very helpful toward solving my problems.

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


Visit the Wiki!

Some recent desktops

May 6, 2011
Musca 0.9.24 on Crux Linux
150Mhz Pentium 96Mb 8Gb CF

May 14, 2011
IceWM 1.2.37 and Arch Linux
L2300 core duo 3Gb 320Gb

Some recent games

Apr. 21, 2011
Oolite on Xubuntu 11.04
L2300 core duo 3Gb 320Gb

Enter your email address to subscribe to this blog and receive notifications of new posts.

Join 405 other followers


This work is licensed under the GNU Free Documentation License. Please see the About page for details.

Blog Stats

  • 3,958,708 hits



Get every new post delivered to your Inbox.

Join 405 other followers

%d bloggers like this: