mkfontdir
Create index of X Window System font files
SYNOPSIS
mkfontdir [-x] [directory...]
PARAMETERS
directory...
One or more directories to scan for fonts and create or update the fonts.dir file. If no directories are specified, the current working directory (.) is used.
-x
Do not print an error message if the fonts.dir file cannot be updated. This option is typically used in scripts where suppressing error output is desired.
DESCRIPTION
mkfontdir is a utility program for the X Window System designed to create or update the fonts.dir file within specified font directories. This file serves as a crucial index, mapping font filenames to their full X Logical Font Description (XLFD) names. The fonts.dir file is essential for traditional X font servers (like xfs) and X applications to efficiently locate and load fonts without needing to scan every font file individually. When new fonts are added to a directory, mkfontdir should be run to ensure they are properly indexed and available to X applications. If a fonts.dir file already exists, mkfontdir attempts to merge new font information into it, preserving existing entries and updating outdated ones. It is primarily used for bitmap fonts, though it can also be used in conjunction with mkfontscale for scalable fonts.
CAVEATS
mkfontdir primarily generates the fonts.dir file, which is an index for bitmap fonts.
For scalable fonts (like TrueType, Type1), it's generally recommended to use mkfontscale first, which generates fonts.scale and can also update fonts.dir with proper XLFD names.
The created fonts.dir needs to be recognized by the X font server or clients. This usually involves adding the directory to the X font path using xset fp+ or configuring xfs or fontconfig.
Permissions: mkfontdir must have write permissions to the target directories to create or update fonts.dir.
PURPOSE OF FONTS.DIR
The fonts.dir file is a plain text file where each line represents a font. It maps the actual font filename to its full X Logical Font Description (XLFD) name, which includes various attributes like foundry, family, weight, slant, spacing, and size. This index allows X applications to request fonts by their XLFD name without needing to know the underlying filename.
INTERACTION WITH MKFONTSCALE
While mkfontdir alone can create a fonts.dir file primarily for bitmap fonts, it is often run in conjunction with mkfontscale. mkfontscale parses scalable font files (like TrueType or Type1) and generates a fonts.scale file, which also includes the XLFD names. mkfontscale can also update fonts.dir with these XLFD names for scalable fonts. For a complete font directory setup, the common practice is to run mkfontscale (which might implicitly call or handle fonts.dir generation) and then mkfontdir if needed, or simply let mkfontscale handle both.
HISTORY
mkfontdir has been a fundamental utility in the X Window System since its early days, originating with X11R5 or earlier. Its primary purpose was to efficiently index font directories by creating the fonts.dir file, which was crucial for X servers and clients to locate and load fonts. Before its introduction, manual indexing or inefficient scanning was required. With the evolution of font technologies, particularly scalable fonts, mkfontscale was developed to handle the more complex indexing of Type1 and TrueType fonts, often working in conjunction with mkfontdir. Despite the modern prominence of Fontconfig for font management in many Linux environments, mkfontdir remains relevant for traditional X applications and systems relying on the legacy X font server mechanism.
SEE ALSO
mkfontscale(1), xset(1), xfs(1), fonts.conf(5)