mirror of
https://bjh21.me.uk/bedstead/.git
synced 2026-07-30 15:33:25 -04:00
Sort glyph names in compatcheck
This commit is contained in:
parent
67e3cf9324
commit
3a43d22b3d
31
compatcheck
31
compatcheck
@ -27,6 +27,16 @@
|
||||
# Vendor ID. At least some versions of GNU Emacs like to use the
|
||||
# OS/2.achVendID field to select fonts. So if that changes, Emacs
|
||||
# might not find your favourite font.
|
||||
#
|
||||
# Some 'GSUB' lookups. For some features, the OpenType specification
|
||||
# says that the various outputs of an alternate lookup should match
|
||||
# across fonts in a family. This suggests that it's reasonable to
|
||||
# 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).
|
||||
|
||||
from argparse import ArgumentParser
|
||||
from fontTools import ttLib
|
||||
@ -92,5 +102,26 @@ for oldname in ttold['name'].names:
|
||||
if ttold['OS/2'].achVendID != ttnew['OS/2'].achVendID:
|
||||
fail("Vendor ID mismatch")
|
||||
|
||||
def feat_to_dict(gsub, tag):
|
||||
# Assertions in this function trap various unhandled cases.
|
||||
feature_records = [f for f in gsub.table.FeatureList.FeatureRecord
|
||||
if f.FeatureTag == tag]
|
||||
assert(len(feature_records) == 1)
|
||||
for fr in feature_records:
|
||||
assert(len(fr.Feature.LookupListIndex) == 1)
|
||||
for llix in fr.Feature.LookupListIndex:
|
||||
lookup = gsub.table.LookupList.Lookup[llix]
|
||||
assert(lookup.LookupType == 3)
|
||||
assert(len(lookup.SubTable) == 1)
|
||||
for st in lookup.SubTable:
|
||||
return st.alternates
|
||||
|
||||
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]:
|
||||
fail(f"new '{feat}' lookup for {k} is not a prefix of old one")
|
||||
|
||||
if failed:
|
||||
exit(1)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user