XOrg Font Configuration


Table of Contents

XOrg Font Configuration 
Contents 
X.org Font Configuration and beautification 
X.org Font Path and /etc/fonts/ 
Goodies 
Linux: Fonts 
Contents 
Getting fonts 
Installing X core fonts 
IDPI settings 
Xft Font System 
Freetype 
Fontconfig 
Xft-related 
Useful Commands 
Installing and Configuring Fonts 
Installing and Copying Fonts 
11.2.1. Xft 
11.2.2. X11 Core Fonts 
11.2.3. CID-Keyed Fonts 

XOrg Font Configuration 

http://wiki.archlinux.org/index.php/XOrg_Font_Configuration

Contents 

  1. X.org Font Configuration and beautification

    • 1.1 xorg.conf modules
  2. X.org Font Path and /etc/fonts/

    • 2.1 xorg.conf font path
    • 2.2 /etc/fonts/ font directories
    • 2.3 Adding new fonts
    • 2.4 fc-list and xlsfont utilities
  3. Some Font Downloads
  4. Goodies

    • 4.1 My fonts look like crap - I've configured everything right but it appears I just have no good fonts.
    • 4.2 I have some apps compiled against Gtk+ 2.2 and under and fonts still look like garbage.
    • 4.3 I have a similar problem as above with older Qt based apps.
    • 4.4 Fonts in Gtk apps are too small when using KDE
    • 4.5 The bytecode interpreter makes my fonts look crappy, and it's compiled in, do I need to recompile?
    • 4.6 Autohint works great but not for my bold fonts. How can I turn it off only for bold fonts?
    • 4.7 I have a TFT/DFP/LCD display uses a DVI cable and fonts look odd and fuzzy
    • 4.8 I don't want my fonts Antialiased under a certain point size.
    • 4.9 I'm using MS TrueType fonts (verdana) and want to enable anti-aliasing but only for bigger fonts that look too jagged.
    • 4.10 I wanna add more fonts.
    • 4.11 I want my font sizes to match my dpi settings
    • 4.12 I don't like font <enter name here> and want to use <another font name> instead
    • 4.13 I have tons of disgusting pixel fonts that I don't want
    • 4.14 Something or someone disabled all my non-scalable (bitmap) fonts, I want them back

X.org Font Configuration and beautification 

xorg.conf modules 

  • freetype - support for True Type (ttf, ttc), Type1 (pfa, pfb), CID (cid), CFF, Open Type, bitmap (bdf, pcf, snf), Windows (fnt), PFR, and Type42 fonts
  • type1 - support for Type1 (pfa, pfb) and CID (cid) fonts
  • speedo - support for Bitstream Speedo (spd) fonts
  • xtt - support for True Type (ttf, ttc) fonts (conflicts with freetype)
  • bitmap - support for bitmap (bdf, pcf, snf) fonts

As you can see, freetype provides everything provided by these other modules already. In addition, xtt will conflict with freetype.

X.org Font Path and /etc/fonts/ 

xorg.conf font path 

The font path described in the xorg.conf file is used for non-Xft fonts. It is worthwhile to specify a majority of fonts here. Applications which do not support Xft will fall back to the X Server's font path. Personally, I keep a minimum of fonts here - for use with xterm and it's ilk.

/etc/fonts/ font directories 

The conf files in /etc/fonts (fonts.conf and local.conf) are used for fontconfig (Xft fonts). fonts.conf should never be changed, and all changes should be done in local.conf (for system wide changes) or ~/.fonts.conf (for user based changes). Files in /etc/fonts/conf.d are sourced when they start with a number and end with .conf.

The directories listed in fonts.conf are scanned by fc-cache for use with fontconfig (/usr/share/fonts and ~/.fonts). All fonts should be placed in these directories. If installing new fonts, running fc-cache -fv will detect the changes.

Adding new fonts 

When new fonts are added, they are just files on your system. A handful of utilities need to be run in order to tell the system that new fonts have been added.

/usr/bin/fc-cache

This will update the fontconfig cache, assuming the new fonts can be searched by fontconfig (see the above section about /etc/fonts)

/usr/bin/mkfontscale
/usr/bin/mkfontdir
ln -s /usr/X11R6/lib/X11/fonts/encodings/encodings.dir encodings.dir

These utilities need to be run from inside the directory of the new fonts. mkfontscale creates a fonts.scale file and mkfontdir creates a fonts.dir file. These files are used by the X Server, and only need to be done if the fonts are to be served through the FontPath of X.org. The encodings soft link allows the X Server to use these new fonts under all supported encodings. After all this, you should have 3 new files in the font dir : fonts.scale, fonts.dir, and encodings.dir.

fc-list and xlsfont utilities 

These utilities will list, from the command line, all fonts available to each font subsystem. fc-list will list all fontconfig fonts, while xlsfont will list all X fonts. This is useful in combination with grep, i.e. "xlsfonts || grep -i bitstream" to see all bitstream fonts available.

Goodies 

How to add more fonts? 

Save your fonts in a directory and add it to /etc/fonts/local.conf

<dir>/path/to/dir</dir>

Fonts in Gtk apps are too small when using KDE? 

  • Install gtk-qt-engine
  • Change the font size for Gtk apps in `Control Center' -> `Appearance & Themes' -> `GTK Styles and Fonts'.

Some apps compiled against Gtk+ 2.2 and under fonts still look like garbage? 

Yeah, this happens. Modern GTK apps enable Xft by default, however, before 2.2 this was not the case. Maybe these apps should be updated to the newer GTK. If that is not an option, then adding the line export GDK_USE_XFT=1 to a global settings file (/etc/profile, /etc/profile.d/gnome.sh, ~/.xinitrc, etc) will enable Xft for older apps

For similar problem as above with older Qt based apps, similar solution, add export QT_XFT=true somewhere.

How can I turn autohint off only for bold fonts? 

Autohinter can give you nice fonts but often makes fonts too wide. This is especially annoying with bold fonts. Fortunatelly you can turn off autohinter for bold fonts while leaving it on for the rest.

First turn on autohinter (see above) and add the following to /etc/fonts/local.conf or ~/.fonts.conf

<match target="font">
    <test name="weight" compare="more">
        <const>medium</const>
    </test>
    <edit name="autohint" mode="assign">
        <bool>false</bool>
    </edit>
</match>

No fonts Antialiased under a certain point size? 

A sample of this is in the /etc/fonts/local.conf file. It is commented, just like the subpixel rendering section. Changes, if anything, should be made to the compare="less_eq" portion, and the <int>12</int> portion - these are the comparison operation and point size to compare, respectively.

<match target="pattern">
   <test qual="any" name="size" compare="less_eq">
      <int>12</int>
   </test>
   <edit name="antialias" mode="assign"><bool>false</bool></edit>
</match>

Enable anti-aliasing but only for bigger fonts that look too jagged? 

<match target="font" >
<test compare"more" name"size" qual="any" >
<double>12</double>
</test>
<edit mode"assign" name"antialias" >
<bool>true</bool>
</edit>
</match>
<match target="font" >
<test compare"more" name"pixelsize" qual="any" >
<double>17</double>
</test>
<edit mode"assign" name"antialias" >
<bool>true</bool>
</edit>
</match>

How to use <another font name> instead? 

Easy! Again, it's an entry in /etc/fonts/local.conf. Technically this just adds the "preferred" font in front of the list of names to be used, so it's not 100% guarenteed in the case of a missing font.

<alias>
   <family>Helvetica </family>
   <prefer><family>Bitstream Vera Sans Mono</family></prefer>
   <default><family>fixed</family></default>
</alias>

How to enable bitmap fonts? 

By default, fontconfig 2.3.2-4 and higher will disable the use of bitmap fonts. This setting is managed in /etc/fonts/conf.d/10-no-bitmaps.conf, or in higher versions, /etc/fonts/conf.d/10-bitmaps.conf. To enable bitmap fonts and keep them enabled after upgrades of fontconfig, place a symlink from yes-bitmaps.conf to 10-bitmaps.conf, overwriting the symlink to no-bitmaps.conf.

How to get rid of all the pixel fonts that I don't want? 

The only two fonts that you absolutely have to have in order to start X are 'cursor' and 'fixed', both of which are in the fonts/misc directory. If you want to get rid of all the pixel fonts besides these two, you can delete all the files in the misc directory besides cursor.pcf.gz and all the fonts that are similar to either 9x18.pcf.gz or 9x18-ISO8859-1.pcf.gz. When I deleted all the fonts besides those from the misc directory, I had about 337 files still in it, so if you have a lot less than that you should probably put them back before restarting X.

The bytecode interpreter makes my fonts look crappy? 

No need to recompile. Freetype's internal auto-hinting is just shut off. To force the autohinter to be on, add the following to /etc/fonts/local.conf or ~/.fonts.conf

<match target="pattern">
   <edit name="autohint" mode="assign">
      <bool>true</bool>
   </edit>
</match>

Someone else has a different opinion … The bytecode interpreter is supposed to beat the autohinter by a long shot so i don't see why anyone would want the autohinter.