Introducing a new project that simplifies the process of determining the font used to render a specific code point. Unlike the fc-match :charset=... command, which only works for Unicode, this tool can handle input in various formats, such as UTF-8 characters, Unicode. This versatility makes it a valuable tool for users who work with different character encodings.
You can install it directly using:
sudo dnf install whichfontThen run it like this:
whichfont --language jaTo get started, install the dependencies (Meson, Ninja, Fontconfig headers). On Fedora:
sudo dnf install meson ninja-build fontconfig-develUse Meson and Ninja to build the project. Meson generates build files and Ninja builds the project.
./build.shmeson setup .builddir
ninja -C .builddirThe first command will create a .builddir/ directory to store build files. On subsequent builds, you can skip the Meson setup step.
Once built, you can use the tool as follows:
./.builddir/whichfont <INPUT> [:: PARAMS]Or use the convenience script:
./run.sh <your_input> [:: PARAMS]- UTF-8 characters
- Unicode in forms like
U+0985,0x0985,0985 - Mixed input like
অah😀,RED,A,abc def
./run.sh abc
./run.sh -f "Noto Sans" abc def
./run.sh -f "Noto Sans" abc def :: family style weight
./run.sh abc def :: family familylang
./run.sh --language ja
Show all matching fonts in descending order of priority.
./run.sh -a केंReturn the best sorted list of matching fonts.
./run.sh -s অah😀Specify the font name (defaults to sans-serif).
./run.sh -f "Noto Sans Bengali" 0985Check if a valid font is installed for the given language code.
-
Valid language code with font installed:
./run.sh --language ja
Output:
Noto Sans CJK JP -
Valid language code but no font installed:
./run.sh --language ccp
Output:
No font installed for (ccp) language -
Invalid language code:
./run.sh --language xyz
Output:
Invalid language code used
This feature checks:
- If the language code is valid (based on a known list)
- If any font matches that language
- If the font truly declares support via
FcLangSetContains()
Display all supported language codes from the internal database.
./run.sh --list-languagesParameters provided after :: are treated as Fontconfig attributes. You can specify attributes like family, style, weight, lang, etc. If you wanna give other parameters then follow this page: https://www.freedesktop.org/software/fontconfig/fontconfig-devel/x19.html
./run.sh -f "Noto Sans" abc def :: family style weight
./run.sh abc def :: family weight lang
Display usage instructions.
./run.sh --helpRun all test cases:
./tests.shResults are saved in test_results.txt for review.
Whether you're a developer or a designer, this tool can help you save time and ensure consistency in your work. Give it a try and see how it can simplify your font management tasks!