I introduce how to create font file subset in command line.
This time, I used NodeJS and Python. (NodeJS seems to use Python libraries so I think we can do the same thing only with Python.)
- NodeJS (v12.6.0)
- Python (3.6.8)
Check the character code for the characters which are input into the subset
Get the character codes in hexadecimal number format.
Check in Python (3.6)
hex(ord('0')) # => '0x30' hex(ord('9')) # => '0x39'
Check in Ruby (2.5.1)
'0'.ord.to_s(16) # => "30" '9'.ord.to_s(16) # => "39"
$ pip install fonttools brotli
$ npm install -g glyphhanger
$ glyphhanger --whitelist="U+30-39" --subset something.ttf --formats=woff2
--whitelist indicates the characters to be in the subset, which are designated in the format
woff2 format file will be created.
As a result,
something-subset.woff2 was created.
--formats can receive multiple formats, as