nrGrammar icon indicating copy to clipboard operation
nrGrammar copied to clipboard

Add webfont and script to subset a font.

Open Szunti opened this issue 6 years ago • 2 comments

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:

  1. couldn't find a license
  2. 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
}

Szunti avatar Sep 22 '18 18:09 Szunti

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.

Pomax avatar Sep 23 '18 18:09 Pomax

Unless slicing for sections are needed, I think I'm done.

Szunti avatar Sep 25 '18 03:09 Szunti