LinuxCommandLibrary

fc-match

Find best matching font for a pattern

TLDR

Return a sorted list of best matching fonts

$ fc-match [[-s|--sort]] '[DejaVu Serif]'
copy

SYNOPSIS

fc-match [-a|--all] [-s PATTERN|--sort=PATTERN] [-v|--verbose] [-V|--version] [-l LABEL|--label=LABEL] [-C|--no-cache] [-h|--help] [PATTERN...]

PARAMETERS

-a, --all
    Output all fonts matching the pattern instead of just the best match

-s PATTERN, --sort=PATTERN
    Sort output using the specified pattern for ordering

-v, --verbose
    Print verbose details including all font properties

-V, --version
    Display Fontconfig and fc-match version information

-l LABEL, --label=LABEL
    Use LABEL (e.g., 'weight') for sorting matches

-C, --no-cache
    Ignore font cache and rebuild matches from directories

-h, --help
    Show command usage and options

DESCRIPTION

fc-match is a command-line utility from the Fontconfig library used to query available fonts matching specified patterns. Fontconfig manages font configuration on Linux systems, allowing applications to select fonts based on criteria like family, style, size, and language.

Without arguments, fc-match outputs the default system font. Provide a pattern like Sans, serif:lang=en, or monospace:size=12 to find the best match. It considers user (~/.config/fontconfig) and system (/etc/fonts) configurations, including font directories and priorities.

Common uses include scripting font selection, debugging configuration issues in apps like Firefox or LibreOffice, and verifying font fallbacks. Output shows the font file path and matched properties. With options, it can list all matches, provide verbose details, or sort results.

This tool is lightweight, fast, and essential for font management in X11, Wayland, and headless environments.

CAVEATS

Ignores invalid patterns silently; output depends on fontconfig cache (run fc-cache after font changes); multi-user systems may vary by user config.

EXAMPLES

fc-match → default font
fc-match Sans → best sans-serif
fc-match monospace:size=10:lang=ja → Japanese monospace
fc-match -a -v 'serif' → all verbose serif matches

PATTERN SYNTAX

Patterns use property:value like family:serif, slant:italic, weight:bold. See fontconfig(3) for full syntax.

HISTORY

Developed by Keith Packard in 2001 for XFree86/X.org font handling. Evolved with Fontconfig 2.x series; now at version 2.15+ under freedesktop.org. Key for modern desktop font subsystems.

SEE ALSO

fc-list(1), fc-cache(1), fc-cat(1), fc-query(1), fontconfig(3)

Copied to clipboard