Skip to content

Fontconfig

How to install

Debian based:

sudo apt install fontconfig

fc-list

패턴에 맞는 모든 폰트나 fontconfig가 아는 모든 폰트의 List 출력

fc-match

fc-cache

글꼴 추가 후 글꼴 캐시를 재 생성하여 추가 글꼴을 사용 가능하게 함.

Flags

  • -f: 강제 갱신
  • -r: 존재하는 폰트 캐시 지우고 갱신
  • -s: 시스템 전반적인 디렉토리만 갱신
  • -v: status 정보 출력
  • -V: font config 버전 출력

fc-cat

폰트 캐시파일로 부터 폰트 정보 읽어옴

fc-query

폰트 파일에 대한 정보 볼 수 있음

Examples

Look at the table of charset for the font:

fc-query /usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf  | less

List Unicode character ranges for all supported code points (glyphs?):

fc-query --format='%{charset}\n' /usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf | less

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:

xfd -fa /usr/share/fonts/truetype/unifont/unifont_upper.ttf

fc-scan

폰트 파일이랑 디렉토리 읽어옴

fc-pattern

Lists best font(s) matching the supplied pattern(s).

fc-validate

Validate font file(s) and reports the results.

See also

  • xfd - 전체 폰트를 x11 윈도우로 출력