Skip to content

sudipshil9862/whichfont

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

74 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

whichfont

Querying Fontconfig

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.

Note for Fedora users: whichfont is available in Fedora repositories! 🎉

You can install it directly using:

sudo dnf install whichfont

Then run it like this:

whichfont --language ja

If you cloned from GitHub, use ./.builddir/whichfont or ./run.sh.

Installation

To get started, install the dependencies (Meson, Ninja, Fontconfig headers). On Fedora:

sudo dnf install meson ninja-build fontconfig-devel

Building

Use Meson and Ninja to build the project. Meson generates build files and Ninja builds the project.

Automatic:

./build.sh

Manual:

meson setup .builddir
ninja -C .builddir

The first command will create a .builddir/ directory to store build files. On subsequent builds, you can skip the Meson setup step.

Usage

Once built, you can use the tool as follows:

./.builddir/whichfont <INPUT> [:: PARAMS]

Or use the convenience script:

./run.sh <your_input> [:: PARAMS]

Input formats supported

  • UTF-8 characters
  • Unicode in forms like U+0985, 0x0985, 0985
  • Mixed input like অah😀, RED, A, abc def

Examples:

./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

Options

-a, --all

Show all matching fonts in descending order of priority.

./run.sh -a कें

-s, --sort

Return the best sorted list of matching fonts.

./run.sh -s অah😀

-f, --font

Specify the font name (defaults to sans-serif).

./run.sh -f "Noto Sans Bengali" 0985

-l, --language

Check if a valid font is installed for the given language code.

Examples:

  • 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()

-L, --list-languages

Display all supported language codes from the internal database.

./run.sh --list-languages

::PARAMS

Parameters 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

Examples:

./run.sh -f "Noto Sans" abc def :: family style weight ./run.sh abc def :: family weight lang

-h, --help

Display usage instructions.

./run.sh --help

Tests

Run all test cases:

./tests.sh

Results 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!

About

Querying fontconfig for certain code point

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •