From: Ben Harris Date: Wed, 1 Jan 2025 23:53:51 +0000 (+0000) Subject: Extend compatcheck 'GSUB' checks to handle renamed glyphs X-Git-Tag: bedstead-3.251~49 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~bjharris/git?a=commitdiff_plain;h=1be09350ccafd8b25b7c7935072fcecd2883ab90;p=bedstead.git Extend compatcheck 'GSUB' checks to handle renamed glyphs We do this by pulling out the CFF charstring for old and new glyph names from the new font and seeing if they're the same. --- diff --git a/compatcheck b/compatcheck index c119693..a1acf61 100755 --- a/compatcheck +++ b/compatcheck @@ -34,9 +34,12 @@ # depend on the behaviour of particular inputs to these lookups, and # that they should thus be consistent within major versions. Unlike # for most features above, we'd like to check that the semantics of -# the chosen glyphs haven't changed. For now, we do that by checking -# glyph names. The only feature currently handled by this is 'aalt' -# (Access All Alternates). +# the chosen glyphs haven't changed. This is made tricky by the fact +# the Bedstead 3.251 changed some glyph names while keeping the same +# semantics, and also changed the shape of some glyphs. Our approach +# is to look up both old and new glyph names in the new font and check +# that they have the same outline there. The only feature currently +# handled by this is 'aalt' (Access All Alternates). from argparse import ArgumentParser from fontTools import ttLib @@ -116,11 +119,15 @@ def feat_to_dict(gsub, tag): for st in lookup.SubTable: return st.alternates +def charstring(glyphname): + return ttnew['CFF '].cff[0].CharStrings[glyphname].bytecode + for feat in ['aalt']: oldalt = feat_to_dict(ttold['GSUB'], feat) newalt = feat_to_dict(ttnew['GSUB'], feat) for k in sorted(set(oldalt.keys()) & set(newalt.keys())): - if newalt[k][:len(oldalt[k])] != oldalt[k]: + if ([charstring(x) for x in newalt[k][:len(oldalt[k])]] != + [charstring(x) for x in oldalt[k]]): fail(f"new '{feat}' lookup for {k} is not a prefix of old one") if failed: