CLI tool to render images of each primary font of a font family from Google Fonts.
- The tool uses the
hb-viewCLI tool to render samples at the desired PPM. - The tool creates sample text randomly for non-Latin fonts (using the dominant script of the font, determined by the largest codepoint coverage), and for fonts that support the Latin script, it uses a predefined sample text plus one randomly-generated word. For non-Latin fonts, the samples may be nonsensical and produce odd character combinations for connecting scripts.
- The PNG images are accessible via URL like
https://twardoch.github.io/googlefonts-images/img/17/roboto.png - Each image base name corresponds to the folder name of the family in the Google Fonts repo, like
https://github.com/google/fonts/tree/main/apache/robotoin the above example. - Only the "main" font from each family folder is rendered. The "main" font gets determined by its shortest path name.
Needs macOS, perhaps also works on Linux.
- Install Homebrew on macOS.
- Run
brew install harfbuzzor installharfbuzzon Linux. - Run
brew install pythonor install Python 3.9 or newer on Linux. - Run
python3 -m pip install -r requirements.txt
usage: ./build_images.py [-h] -f folder [-i folder] [-p int]
Takes a folder of Google Fonts and builds images
optional arguments:
-h, --help show this help message and exit
-f folder, --fonts folder
Folder with the local copy of https://github.com/google/fonts
-i folder, --images folder
Folder in which the images will be written.
-p int, --ppm int PPM size at which the images will be rendered.