How to install and use X-Windows fonts

Like any operation system and any graphical (GUI) system, X-Windows uses fonts. You can install and configure fonts for most window managers and programs. You can set fonts for most text based console programs and GUI programs.

X-Windows font system is configured in two systems. The Core X fonts are the older font system for fonts in the X-Windows System, and Fontconfig is the new system for fonts in X-Windows. Both are used in all X-Windows systems.

For simple instruction on installing fonts 
 * See: Quick font installation

=X-Windows font types=


 * Common font types
 * Bitmap fonts
 * Binary distribution format *.bdf
 * Portable Compiled Font (*.pcf or *.pcf.gz)
 * Server normal format *.snf (obsolete)
 * TrueType, freetype or opentype
 * (*.ttf)
 * *.ttc
 * Open Type Font Format (*.otf)
 * Type 1
 * Adobe Type 1 PostScript Font Binary (*.pfb)
 * Adobe Type 1 PostScript Font ASCII (*.pfa)
 * Adobe/Outlined Font Metrics (*.afm)
 * CID-keyed font, or CIDFont
 * Speedo
 * Bitstream Speedo outline font format (*.spd)

=Core X fonts (old system)= The core X fonts are the older font system for fonts in the X-Windows System. Even though is the old system, its is still used, and is necessary for many functions.


 * Software


 * Programs for listing/viewing/installing fonts
 * xfontsel - point and click selection of X11 font names
 * Source code: x.org directory of individual apps
 * Gentoo: emerge x11-apps/xfontsel


 * showfont - font dumper for X font server
 * Source code: x.org directory of individual apps
 * Gentoo: emerge x11-apps/showfont


 * fc-cache: creates fonts.cache1
 * Source code:
 * Gentoo: emerge 


 * format format conversion software
 * bdftopcf - convert X font from Bitmap Distribution Format to Portable Compiled Format
 * Source code: x.org directory of individual apps
 * Gentoo: emerge x11-apps/bdftopcf


 * Font installation software
 * mkfontdir: create an index of X font files in a directory (fonts.dir)
 * Source code: x.org directory of individual apps
 * Gentoo: emerge x11-apps/mkfontdir
 * mkfontscale: create an index of scalable font files for X
 * Source code: x.org directory of individual apps
 * Gentoo: emerge x11-apps/mkfontscale
 * xset: makes settings in X
 * Source code: x.org directory of individual apps
 * Gentoo: emerge x11-apps/xset


 * Font viewing software
 * xlsfonts (or fslsfonts): lists installed fonts, and properties
 * Source code: x.org directory of individual apps
 * Gentoo: emerge x11-apps/xlsfonts
 * xfd: displays fonts
 * Source code: x.org directory of individual apps
 * Gentoo: emerge x11-apps/xfd

Listing installed fonts
The program xlsfonts can be used for listing all installed fonts, as well as their properties


 * To install xlsfonts
 * This may already be install with your X install
 * From source: to be added
 * Gentoo: emerge x11-apps/xlsfonts


 * Listing installed fonts
 * Execute: xlsfonts


 * Listing font directory
 * Execute: xset q

Understanding font names
X font names are extremely confusing to decipher. This section helps to explain them


 * Examples of font name:
 * -adobe-new century schoolbook-medium-r-normal—8-80-75-75-p-50-iso8859-15
 * -misc-fixed-bold-r-normal—0-0-100-100-c-0-iso8859-10
 * -misc-fixed-medium-r-normal—18-120-100-100-c-90-iso8859-1
 * 6x13
 * 6x13bold
 * kana14


 * Basic format: the accuracy of this should be checked


 * -[foundry]-[family]-[weight]-[slant]-[setwidth]-[style]-[pixelSize]-
 * [pointSize]-[Xresolution]-[Yresolution]-[spacing]-[averageWidth]-[registry]-
 * [encoding]


 * Description of font variables:
 * foundry
 * Description: fonts group
 * Examples: adobe, fixed
 * family
 * Description: fonts name
 * Examples: fixed, times, courier
 * weight:
 * Description: boldness
 * Examples: normal, bold
 * slant
 * Description: slant
 * Examples
 * o=none
 * r=
 * setwidth
 * Description:
 * Examples:
 * style
 * Description:
 * Examples:
 * pixelSize
 * Description: font size
 * Examples: 8, 10, 12
 * pointSize
 * Description: font size
 * Examples: 120
 * Xresolution
 * Description: resolution
 * Examples: 72,100
 * Yresolution
 * Description: resolution
 * Examples: 72,100
 * spacing
 * Description:
 * Examples:
 * averageWidth
 * Description: widths of characters vary, this is the average
 * Examples:
 * registry
 * Description:
 * Examples:
 * encoding
 * Description: character set
 * Examples:
 * iso8859-1 (Latin 1 - Western Europe)
 * iso8859-2 (Latin 2 - Central and Eastern Europe)
 * iso8859-3 (Latin 3 - Esperanto and Maltese)
 * iso8859-4 (Latin 4 - superseded by Latin 6)
 * iso8859-5 (Cyrillic)
 * iso8859-6 (Arabic)
 * iso8859-7 (Greek)
 * iso8859-8 (Hebrew)
 * iso8859-9 (Latin 5 - Latin 1 with Turkish, not Icelandic)
 * iso8859-10 (Latin 6 - Nordic languages, replaces Latin 4)

Printing font location

 * xset q
 * prints 'Font Path' among other things

Display font
xfd -fa "10x20"

Installing fonts
Installing bitmap, type1, and freetype fonts.

Install bitmap fonts
Bitmap font come of the BDF format and somewhat more efficient binary PCF format

Converting BFD to PCF files is recommended
 * Converting fonts
 * Execute: bfdtopcf font_name.bdf
 * Compressing fonts
 * Execute: gzip font_name.pcf
 * Resulting file name
 * font_name.pcf.gz


 * Installing bitmap fonts
 * Execute the following commands, with the dir you wish
 * mkdir /usr/local/share/fonts/bitmap/
 * cp *.pcf.gz /usr/local/share/fonts/bitmap/
 * mkfontdir /usr/local/share/fonts/bitmap/
 * Refresh font cache
 * See: Refreshing cache

fonts.scale are not created for bitmap fonts.

Install Type1 fonts
Make sure Type1 fonts are enabled
 * Test.....
 * To Enable
 * Add the following to Modules section /etc/X11/xorg.conf
 * Load "type1"


 * Make a directory in /usr/share/fonts/ or where ever you wish
 * Example: mkdir /usr/share/fonts/Type1/
 * Make indexes
 * Creating fonts.dir
 * Execute: mkfontdir /usr/share/fonts/Type1/
 * Creating fonts.scale
 * Execute: mkfontscale /usr/share/fonts/Type1/
 * Refresh font cache
 * See: Refreshing cache

Install freetype (truetype) fonts
You can ether create a new directory for adding new fonts, or use a previous directory. If you use a previous font directory in the font path, then it only takes two steps to load the font.


 * Making a new freetype directory


 * Make a directory in /usr/share/fonts/ or where ever you wish
 * Example: mkdir /usr/share/fonts/freetype/
 * Copy fonts to directory
 * Make indexes
 * Creating fonts.dir
 * Execute: mkfontdir /usr/share/fonts/freetype/


 * Add font's directory to font


 * Refresh font cache
 * See: Refreshing cache


 * To add any new fonts to a previously used directory


 * Copy fonts to the directory
 * Execute: fc-cache
 * Restart any programs you wish to use the new fonts

Refresh font cache

 * Temporary
 * % xset fp+ /usr/local/lib/X11/fonts/TrueType
 * % xset fp rehash


 * Permanently
 * Execute the following
 * xset fp+ /usr/share/fonts/TTF/
 * xset fp rehash
 * fc-cache
 * Restart any program that you want to use the new fonts

=Testing fonts= % xterm -fn -ETL-Fixed-Medium-R-Normal—14-140-72-72-C-70-ISO8859-1 &

=Fontconfig (new font system)= 

Font names
Font name in the newer system are much more readable than the old system


 * Format


 * Examples


 * Common families of fonts
 * Bitstream Charter
 * Bitstream Vera family
 * Century Schoolbook
 * Luxi family
 * Nimbus family
 * URW Palladio
 * URW Bookman
 * URW Chancery
 * URW Gothic
 * Utopia

Listing installed fonts
If you wish to see the installed fonts on you system, fc-list is the program you want to use. Gnome, KDE, etc. have their own graphical programs.

List all fonts installed Nimbus Sans L:style=Regular Italic URW Palladio L:style=Roman Century Schoolbook L:style=Bold Italic Fixed:style=Bold Nimbus Sans L:style=Bold Times:style=Bold Italic URW Chancery L:style=Medium Italic Nimbus Roman No9 L:style=Regular Century Schoolbook L:style=Bold Century Schoolbook L:style=Italic ...
 * Execute: fc-list
 * Example output

Simple font installation
The simple installation is the same as the old system's font installation.

See Install freetype (truetype) fonts

fontconfig configuration
Configuration of fontconfig is fairly complex and usually unnecessary for most users.


 * Config files
 * /etc/fonts/fonts.dtd
 * a DTD that describes the format of the configuration files.
 * /etc/fonts/fonts.conf and ~/.fonts.conf
 * the conventional location for per-user font configuration, although the actual location is specified in the global fonts.conf file.
 * See also: /etc/fonts/conf.d/* and /etc/fonts/conf.avail/*

fonts.conf is the main configure for fontconfig. It allows specify parameters for many fonts, such as alias. The file is written in xml.
 * Configuration


 * For details and examples on howto config fontconfig
 * See: http://fontconfig.org/fontconfig-user.html

Configuring fonts for window managers and specific programs
Most of the fonts you see will mostly be set by your window manager, such as Gnome, KDE, etc.


 * Window managers
 * Configuring for Gnome and KDE


 * Programs
 * Configuring Konqueror, OpenOffice.org, Mozilla Firefox

=References=
 * http://www.math.utah.edu/~beebe/fonts/X-Window-System-fonts.html
 * http://web.mit.edu/answers/xwindows/xwindows_fonts.html
 * http://www.tldp.org/HOWTO/Font-HOWTO/index.html - in depth
 * http://www.faqs.org/docs/Linux-mini/FDU.html (obsolete)
 * X.Org man pages
 * http://www.x.org/archive/X11R6.8.0/doc/fonts2.html
 * X.Org fonts fontconfig
 * fontconfig User manual

From HowTo Wiki, a Wikia wiki.