Munter / subfont

Command line tool to optimize your webfont loading. Aggressive subsetting based on your font use, self-hosting of Google fonts and preloading
MIT License
1.56k stars 29 forks source link

Support full instancing of variable fonts #169

Closed papandreou closed 1 year ago

papandreou commented 1 year ago

Create full instances of variable fonts when every variation axis only has one value. Uses the hb_subset_input_pin_axis_location api that landed in Harfbuzz 6 (via https://github.com/papandreou/subset-font/pull/21).

It's behind an experimental --instance flag for now, as it relies on us tracing font-variation-settings correctly and getting a bunch of stuff related to the standard variation axes right.

Makes for some nice extra savings:

$ subfont -o foo testdata/subsetFonts/variable-font-that-can-be-fully-instanced/index.html 
[...]
testdata/subsetFonts/variable-font-that-can-be-fully-instanced/index.html: 1 font (1 variant) in use, 1.65 MB total. Created subsets: 18.5 kB total
  RobotoVariable:
    normal : 10/827 codepoints used, 1.65 MB (ttf) => 18.5 kB (woff2)
$ subfont --instance -o foo testdata/subsetFonts/variable-font-that-can-be-fully-instanced/index.html 
[...]
testdata/subsetFonts/variable-font-that-can-be-fully-instanced/index.html: 1 font (1 variant) in use, 1.65 MB total. Created subsets: 1.24 kB total
  RobotoVariable:
    normal : 10/827 codepoints used, fully instanced, 1.65 MB (ttf) => 1.24 kB (woff2)

We can add support for partial instancing when the support lands in Harfbuzz.

coveralls commented 1 year ago

Pull Request Test Coverage Report for Build 4644256980


Changes Missing Coverage Covered Lines Changed/Added Lines %
lib/subfont.js 1 2 50.0%
lib/subsetFonts.js 37 39 94.87%
<!-- Total: 38 41 92.68% -->
Totals Coverage Status
Change from base Build 4633529333: -0.1%
Covered Lines: 1145
Relevant Lines: 1213

💛 - Coveralls