Mastering fc-query on Ubuntu: Inspecting Font Metadata

Overview

Investigating and registering typeface assets on Linux requires reliable command-line utilities. At the heart of font verification lies fc-query, a fundamental component of the Fontconfig suite designed to unpack raw font files. This guide demonstrates how to inspect low-level font metadata, determine family assignments, evaluate language coverage, and format custom terminal output through hands-on CLI examples.

1. Installing Fontconfig Tools and Baseline Typefaces

Before dissecting font files, ensure that the Fontconfig query utilities and a clean reference open-source typeface are present on your system by executing sudo apt-get update -qq && sudo apt-get install -y fontconfig fonts-dejavu-core.

Install fontconfig and baseline DejaVu fonts

Confirm that the binary has been properly linked within your system’s executable search path by running which fc-query.

Verify fc-query executable path

Unlike tools that consult pre-built system font caches, fc-query directly parses unindexed font files on disk to report underlying typographic parameters, styling attributes, and supported character ranges.
⚙️ [Key Options]

-i, --index : Specifies a zero-based face index when inspecting multi-font archives such as TrueType Collections (TTC).
-b, --brief : Produces an abbreviated, compact pattern summary.
-f, --format : Formats output attributes according to a user-defined template string.
-V, --version : Prints current binary release and version information.
-h, --help : Summarizes runtime syntax and command-line arguments.

Check fc-query version

2. Inspecting Raw Font Patterns and Internal Properties

Assign the target font path to a shell variable via FONT_FILE="/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf" to streamline subsequent commands.

Assign font path to shell variable

Verify that the target file exists on disk while reviewing its file size and access permissions with ls -l "$FONT_FILE".

Inspect file permissions and size

Examine the primary pattern structure generated from the font file by executing fc-query "$FONT_FILE" | head -n 25.
Direct execution of fc-query instructs the parser to reconstruct Fontconfig’s internal representation, revealing key properties including family, style, and weight.

Display initial 25 metadata attributes

3. Extracting Targeted Attributes via Custom Format Strings (-f)

Re-export the target font path variable to prepare for custom property queries by running FONT_FILE="/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf".

Reinitialize font path variable

Filter the verbose output down to essential fields—such as family name, style label, PostScript designation, and file container type—using fc-query -f "Family: %{family}\nStyle: %{style}\nPostScript: %{postscriptname}\nFormat: %{fontformat}\n" "$FONT_FILE".
By pairing the -f flag with attribute replacement placeholders (%{property_name}), you can isolate precise properties without parsing through unneeded noise.

Extract custom attributes using format string

Isolate specific numerical parameters governing stroke heaviness and glyph slope with fc-query -f "Weights: %{weight}\nSlants: %{slant}\n" "$FONT_FILE".
This selective extraction is particularly valuable for build scripts, rendering pipelines, or automated tests that need to validate whether a file represents an oblique or bold variant.

Inspect numerical weight and slant values

4. Managing Font Collections and Auditing Language Coverage

Set the font target once more in your current shell session by executing FONT_FILE="/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf".

Define font path variable for index inspection

Retrieve the complete descriptive name of the primary face within the container using fc-query -i 0 -f "Index 0 Fullname: %{fullname}\n" "$FONT_FILE".
When inspecting composite formats like TrueType Collections (.ttc), passing the -i parameter guarantees precise targeting of individual typeface variations stored inside the same file.

Query full name of font at index zero

Evaluate whether the typeface satisfies regional linguistic requirements by running fc-query -f "Supported Languages:\n%{lang}\n" "$FONT_FILE" | head -n 10.
The lang property computes internationalization readiness by cross-referencing available glyph coverage with standard orthographies, providing a pipe-delimited (|) list of supported RFC-3066 language tags.

Audit supported language tags from langset

Mastering fc-query gives administrators and developers an indispensable tool for diagnosing typographical issues and inspecting font binaries directly from the Ubuntu terminal. Incorporating these techniques into your workflow ensures quick verification and seamless font management across your Linux environments.