This is a utility for generating BASE tables for OpenType fonts.
It has two modes:
-
If the font contains CJK glyphs, it generates a BASE table as per the CJK Vertical Metrics requirements of Google Fonts.
-
Otherwise, it uses the fontheight library to analyze the highest and lowest coordinates of shaped strings in the various scripts supported by the font, and generates script specific MinMax tables to allow user agents to alter text vertical metrics based on the script in use.
autobase can be configured by passing a TOML configuration file to the -c argument. This TOML file can have the following keys:
languagesis a list of script-language combinations to be split out of the main calculation and handled separately.overridesis a dictionary of min and/or max values to be manually set for a particular script-language combination.toleranceis a number of font units within which language-specific MinMax values will be considered close enough to the script or font default to be omitted.
In both cases, script-language combinations are specified as yyy_Xxxx where yyy is a valid ISO639-1 or ISO639-3 language code and Xxxx is a valid ISO 15924 four-letter script code.
An example will make this clear. The following config file:
tolerance=10
languages=["vi_Latn"]
[override]
fi_Latn = { max = 1234 }with a font which supports Latin and Cyrillic will create:
- A default language system MinMax table for
Cyrlbased on values measured when shaping the Cyrillic word lists, unless the values are within 10 font units of the font's default (OS/2 typo ascender / descender). - A language system entry for Finnish with the max value set to 1234 and the min value automatically computed from the Finnish word list - unless the values are within 10 font units of the Latin script default.
- A language system entry for Vietnamese with max and min values automatically computed, again unless the values are within 10 font units of the Latin script default.
- A default MinMax table for
Latnbased on shaping all Latin wordlists except Finnish and Vietnamese words, unless the values are within 10 font units of the font's default.