Variable font subsetting

Apr 29, 2022
Table Of Contents

Dropping some variable features from recursive while preserving the sans to mono transition, requires fontools . Use wakamaifondue 1 1 1. The creator has a good blog . after every finalized change to verify the features.

The regular variable font with all of its features weighs about 2.4mb.

Subsetting features/variations

Using varLib.Instancer in a script like so outputs all the available features in the font.

from fontTools import ttLib
from fontTools.varLib import instancer
varfont = ttLib.TTFont("")
for a in varfont["fvar"].axes:
    print (a.axisTag)
MONO
CASL
wght
slnt
CRSV

From my effort what I found out is its probably not worth it to shave off the bottom 100 to 200 weightage since moving the default wght axis up can lead to issues and its not that heavy to begin with

Dropping CASL, slnt, CSRV and limiting wght to an uppper limit of 600 instead of the default 1000. This grabs the lowest normal values for all the dropped features for example, dropping slnt results it in being set to 0

The new resulting partial variable font with dropped features weighs about 440kb

fonttools varLib.instancer ./Recursive_VF_1.084.ttf slnt=drop CRSV=drop CASL=drop wght=300:600      

Subsetting characters and compression

Basic latin unicode characters are the only ones needed here. The other flags are pretty self-explanatory. More about unicode selection, layout-features & other methods such as --desubroutinize and --no-hinting can be found over at docs of subset . A healthy dose of caution when working to modify, kerning, heights or hinting. Make sure to see how the font renders on different browser engines and operating systems. Its very easy to mess up rendering for firefox on windows specifically for example.

fonttools subset Recursive_VF_1.084-partial.ttf --output-file="recursive-var-minimal-last.woff2" --layout-features+="lnum, tnum" --unicodes="U+0000-007A,U+2019,U+002C"

After subsetting the partial variable font with dropped unicode characters and woff2 compression the font weights about 65kb


  1. The creator has a good blog ↩︎