MyNixOS website logo
Description

Determine fonts used to render text.

Fontwhich is a commandline tool that used pango to determine which default fonts would be used to render some text, or which font would be used for a particular language script.

Fontwhich

Fontwhich is a small CLI tool that uses pango to show which default fonts are used to render some text.

It should work on any Linux distro with the Cairo and Pango libraries: it requires the fonts to be available but not a graphical session.

Usage

$ fontwhich --version

0.3

$ fontwhich --help

fontwhich

Usage: fontwhich [--version] [-f|--font FONT] [-b|--utf8] [-u|--unicode]
                 [-s|--sample-text]
                 (--list-langs | (-l|--lang LANG) | --all-langs | TEXT)

  Describes the fonts used to render text with pango
  https://github.com/juhp/fontwhich#readme

Available options:
  -h,--help                Show this help text
  --version                Show version
  -f,--font FONT           Base font [default: Sans]
  -b,--utf8                Output UTF-8 hex codes
  -u,--unicode             Output Unicode data
  -s,--sample-text         Use Pango sample text for language
  --list-langs             List language orthography
  -l,--lang LANG           Language code
  --all-langs              Output all orth languages

$ fontwhich Hello 🌍 World 世界

'Hello ' : Noto Sans
'🌍' : Noto Color Emoji
' World ' : Noto Sans
'世界' : Noto Sans CJK JP

$ fontwhich -f Serif "世界こんにちは😀"

'世界' : Noto Serif CJK JP
'こんにちは' : Noto Serif CJK JP
'😀' : Noto Color Emoji

$ fontwhich -l ja

Primary Sans font for 'ja': "Noto Sans CJK JP"

$ fontwhich --utf8 🌳

4 bytes;
'🌳' [f0 9f 8c b3] : Noto Color Emoji

$ fontwhich --unicode αβ१२

10 bytes; 2 pango items
'αβ' : Noto Sans
α <U+03B1>: GREEK SMALL LETTER ALPHA [Greek]
β <U+03B2>: GREEK SMALL LETTER BETA [Greek]
'१२' : Noto Sans Devanagari
१ <U+0967>: DEVANAGARI DIGIT ONE [Devanagari]
२ <U+0968>: DEVANAGARI DIGIT TWO [Devanagari]

One can use both options together:

$ fontwhich --utf8 🌸 --unicode

4 bytes;
'🌸' [f0 9f 8c b8] : Noto Color Emoji
🌸 <U+1F338>: CHERRY BLOSSOM [Common]

Building and installation

On Fedora, install system deps with cabal-rpm builddep.

C library dependencies:

  • Fedora: cairo-gobject-devel gobject-introspection-devel pango-devel
  • Ubuntu: libcairo2-dev libgirepository1.0-dev libpango1.0-dev

Then:

$ cabal install

or

$ stack install

There is a copr repo: https://copr.fedorainfracloud.org/coprs/petersen/fontwhich/

Misc

Initial code assisted with Gemini 3.1.

The tool is related conceptually to the C project https://github.com/sudipshil9862/whichfont.

"fontwhich" as in "sandwich" but with fonts.

Collaborate

The code is distributed under GPLv3+.

Repository: https://github.com/juhp/fontwhich.

Metadata

Version

0.3

Platforms (80)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    uefi
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-uefi
  • aarch64-windows
  • aarch64_be-none
  • arc-linux
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-linux
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • sh4-linux
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-uefi
  • x86_64-windows