Fontconfig
lastmod 2024-08-07created 2020-11-265 edits
How to install
Debian based:
fc-list
Lists all fonts matching a pattern, or all fonts fontconfig knows about
fc-match
fc-cache
After adding fonts, rebuilds the font cache so the added fonts become available.
Flags
-
-f: force update -
-r: erase existing font caches and update -
-s: update system-wide directories only -
-v: print status information -
-V: print font config version
fc-cat
Reads font information from font cache files
fc-query
Shows information about a font file
Examples
Look at the table of charset for the font:
List Unicode character ranges for all supported code points (glyphs?):
Both commands could work with an non-installed font file. If the font has been installed, the command fc-match does the same work.
fontcharlist.sh
You can try the following script (called fontcharlist):
#!/bin/bash -
Usage() { echo "$0 FontFile"; exit 1; }
SayError() { local error=$1; shift; echo "$0: $@"; exit "$error"; }
[ "$#" -ne 1 ] && Usage
width=70
fontfile="$1"
[ -f "$fontfile" ] || SayError 4 'File not found'
list=$(fc-query --format='%{charset}\n' "$fontfile")
for range in $list
do IFS=- read start end <<<"$range"
if [ "$end" ]
then
start=$((16#$start))
end=$((16#$end))
for((i=start;i<=end;i++)); do
printf -v char '\\U%x' "$i"
printf '%b' "$char"
done
else
printf '%b' "\\U$start"
fi
done | grep -oP '.{'"$width"'}'
To actually see the exact same glyphs from a font use xfd:
fc-scan
Reads font files and directories
fc-pattern
Lists best font(s) matching the supplied pattern(s).
fc-validate
Validate font file(s) and reports the results.
See also
- xfd - displays an entire font in an x11 window