googlefonts / ufo2ft

A bridge from UFOs to FontTools objects (and therefore, OTFs and TTFs).
MIT License
152 stars 43 forks source link

Variable font compilation: if one master has kerning, all other masters must have, too #350

Open madig opened 4 years ago

madig commented 4 years ago

If one master of many does not have at least one non-zero pair, no kern feature is generated for it and varLib will fail to merge the GPOS tables due to a feature list mismatch. Example of three masters where one does not have a kerning.plist:

File "c:\userslocal\nikolaus.waxweiler\development\optimistic-display\venv\lib\site-packages\fontTools\varLib\merger.py", line 99, in mergeThings     
    assert allEqualTo(out, lst), (out, lst)
AssertionError: ((2, [2, 2, 1]), 'int', '.FeatureCount', 'FeatureList', '.FeatureList', 'GPOS', '.table', 'table_G_P_O_S_')
anthrotype commented 4 years ago

varLib expects that the masters to either have a GPOS table that is mergeable (same features, same number of lookups as the default) or it doesn't have one at all (in which case that sparse master is ignored). Maybe the font designer can insert a dummy kern value of 0 in the master that has empty kerning, so that ufo2ft will write a kern feature (that does nothing) for it.

The 0-value class kern pairs are currently ignored when collecting the kerning pairs from kerning.plist: https://github.com/googlefonts/ufo2ft/blob/2712e023567d6cc407bc1569da5fb3867d8fb970/Lib/ufo2ft/featureWriters/kernFeatureWriter.py#L328-L330

Maybe instead of skipping 0-value kern pairs we should write them as they are but only print a warning.