featureVars: populate counts on OT tables

this is done automatically upon compiling; however it's good to do it here
as well, in case one wants to pass the updated font directly to other modules
like 'subset' which requires these fields to be present -- without having
to first compile and decompile.
This commit is contained in:
Cosimo Lupo 2019-05-30 12:29:23 +01:00
parent 36f2775d6c
commit afc194db19
No known key found for this signature in database
GPG Key ID: 20D4A261E4A0E642

View File

@ -283,6 +283,7 @@ def addFeatureVariationsRaw(font, conditionalSubstitutions):
rvrnFeature = buildFeatureRecord('rvrn', [])
gsub.FeatureList.FeatureRecord.append(rvrnFeature)
gsub.FeatureList.FeatureCount = len(gsub.FeatureList.FeatureRecord)
sortFeatureList(gsub)
rvrnFeatureIndex = gsub.FeatureList.FeatureRecord.index(rvrnFeature)
@ -346,6 +347,7 @@ def buildGSUB():
srec.Script.DefaultLangSys = langrec.LangSys
gsub.ScriptList.ScriptRecord.append(srec)
gsub.ScriptList.ScriptCount = 1
gsub.FeatureVariations = None
return fontTable
@ -380,6 +382,7 @@ def buildSubstitutionLookups(gsub, allSubstitutions):
lookup = buildLookup([buildSingleSubstSubtable(substMap)])
gsub.LookupList.Lookup.append(lookup)
assert gsub.LookupList.Lookup[lookupMap[subst]] is lookup
gsub.LookupList.LookupCount = len(gsub.LookupList.Lookup)
return lookupMap
@ -397,6 +400,7 @@ def buildFeatureRecord(featureTag, lookupListIndices):
fr.FeatureTag = featureTag
fr.Feature = ot.Feature()
fr.Feature.LookupListIndex = lookupListIndices
fr.Feature.populateDefaults()
return fr