nrGrammar
nrGrammar copied to clipboard
Add webfont and script to subset a font.
How about this for #34?
- A python script (python 3.6+, but easy to backport) using the fontTools package to subset multiple fontfiles until all the codepoints can be displayed. Configured by a json file.
- Also
@font-face
rule and HanaMinA subsetted webfont.
Hanazono font was chosen because for Han Nom:
- couldn't find a license
- I don't know if it matters but it's a Vietnamese font, as far as I know Hanazono is Japanese
Do you want anything different?
make_woff.py --help
usage: ./make_woff.py conffile
conffile is in JSON format. Example with explanatory comments (don't include
these comments in the JSON file):
{
// List of files or globs relative to the config file's dir.
"dataFiles": [
"../data/pages/en-GB/**/*.txt"
],
// List of individual code points and ranges (list with start an end).
"excludeCodepoints": [
[0, 127]
],
// The order of fonts are important, fonts will be checked for every code
// point until one has a glyph. First element is the input, second is the
// output.
"fonts": [
["HanaMinA.ttf", "../HanaMinA.woff"],
["HanaMinB.ttf", "../HanaMinB.woff"]
],
// Missing characters will be written to this file in utf-8. relative to
// config file's location
"missingOutput": "missing.txt",
// if true, only print which fonts are used and missing characters
"justCheck": false
}
Having both PHP and Python as build tools might cause some problems when it comes to adding CI to this, but that can be a later concern. I've left a few comments but overall this looks fine to me. Thank you for helping get this implemented.
Unless slicing for sections are needed, I think I'm done.