September 12, 2019
Using fancy characters like diacritics or emojis is often difficult in LaTeX. Indeed, fonts often lack glyphs coverage. Word processors have a fallback mechanism where, when you select a font that can’t draw a specific character, another font that does contain the needed glyph is used instead. In the worst case, when no font on your system includes a given glyph, you get a square box like this instead: □.
But there is no such fallback mechanism in LaTeX (at least not that I know of). You’re left to figure out on your own which fonts contain the glyphs you need, through trial and error. To avoid doing this manually, I wrote a small Python script that figures out which fonts installed on your system can display a given set of characters. It works on Linux, and probably on Mac OS, too.
You can download the script here. You’ll also need to install
the chardet
and fontTools
Python packages:
# pip3 install chardet
# pip3 install fontTools
Run the script without arguments to display the names of all the fonts available on your system:
$ ./seekfonts.py
Baekmuk Batang
Baekmuk Dotum
Baekmuk Gulim
Baekmuk Headline
Bandal
Bangwool
Bitstream Charter
Bitstream Charter Bold
[...]
To figure out which fonts installed on your system can draw a given set of characters, pass these characters as arguments to the script:
$ ./seekfonts.py ṛ ḷ ṃ
Cantarell Bold
Cantarell Extra Bold
Cantarell Light
Cantarell Regular
Cantarell Thin
Carlito
Carlito Bold
Carlito Bold Italic
[...]
It is also possible to pass characters in hexadecimal. This is particularly useful for combining characters or for characters that don’t display well on a terminal. For instance, to look for fonts that can display both U+0325 COMBINING RING BELOW and the character r, you can call the script like this:
$ ./seekfonts.py 0325 r
Carlito
Carlito Bold
Carlito Bold Italic
Carlito Italic
DejaVu Sans
DejaVu Sans Bold
DejaVu Sans Bold Oblique
[...]