Clone variable mark anchor before building (#3330)

* Copy mark anchor before OTifying

* Add test for variable mark anchor
This commit is contained in:
Simon Cozens 2023-11-13 16:43:55 +00:00 committed by GitHub
parent 3b90398696
commit 4c60c5f3ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 141 additions and 1 deletions

View File

@ -36,6 +36,7 @@ from fontTools.varLib.builder import buildVarDevTable
from fontTools.varLib.featureVars import addFeatureVariationsRaw
from fontTools.varLib.models import normalizeValue, piecewiseLinearMap
from collections import defaultdict
import copy
import itertools
from io import StringIO
import logging
@ -1516,7 +1517,7 @@ class Builder(object):
for mark in markClassDef.glyphs.glyphSet():
if mark not in lookupBuilder.marks:
otMarkAnchor = self.makeOpenTypeAnchor(
location, markClassDef.anchor
location, copy.deepcopy(markClassDef.anchor)
)
lookupBuilder.marks[mark] = (markClass.name, otMarkAnchor)
else:

View File

@ -81,6 +81,7 @@ class BuilderTest(unittest.TestCase):
MultipleLookupsPerGlyph MultipleLookupsPerGlyph2 GSUB_6_formats
GSUB_5_formats delete_glyph STAT_test STAT_test_elidedFallbackNameID
variable_scalar_valuerecord variable_scalar_anchor variable_conditionset
variable_mark_anchor
""".split()
VARFONT_AXES = [

View File

@ -0,0 +1,10 @@
markClass macron <anchor 0 (wght=200:150 wght=900:152)> @MC_top;
lookup one {
pos base a
<anchor 0 0> mark @MC_top;
} one;
lookup two {
pos base a
<anchor 0 0> mark @MC_top;
} two;

View File

@ -0,0 +1,128 @@
<?xml version="1.0" encoding="UTF-8"?>
<ttFont>
<GDEF>
<Version value="0x00010003"/>
<GlyphClassDef>
<ClassDef glyph="a" class="1"/>
<ClassDef glyph="macron" class="3"/>
</GlyphClassDef>
<VarStore Format="1">
<Format value="1"/>
<VarRegionList>
<!-- RegionAxisCount=2 -->
<!-- RegionCount=1 -->
<Region index="0">
<VarRegionAxis index="0">
<StartCoord value="0.0"/>
<PeakCoord value="0.875"/>
<EndCoord value="0.875"/>
</VarRegionAxis>
<VarRegionAxis index="1">
<StartCoord value="0.0"/>
<PeakCoord value="0.0"/>
<EndCoord value="0.0"/>
</VarRegionAxis>
</Region>
</VarRegionList>
<!-- VarDataCount=1 -->
<VarData index="0">
<!-- ItemCount=1 -->
<NumShorts value="0"/>
<!-- VarRegionCount=1 -->
<VarRegionIndex index="0" value="0"/>
<Item index="0" value="[2]"/>
</VarData>
</VarStore>
</GDEF>
<GPOS>
<Version value="0x00010000"/>
<ScriptList>
<!-- ScriptCount=0 -->
</ScriptList>
<FeatureList>
<!-- FeatureCount=0 -->
</FeatureList>
<LookupList>
<!-- LookupCount=2 -->
<Lookup index="0">
<LookupType value="4"/>
<LookupFlag value="0"/>
<!-- SubTableCount=1 -->
<MarkBasePos index="0" Format="1">
<MarkCoverage>
<Glyph value="macron"/>
</MarkCoverage>
<BaseCoverage>
<Glyph value="a"/>
</BaseCoverage>
<!-- ClassCount=1 -->
<MarkArray>
<!-- MarkCount=1 -->
<MarkRecord index="0">
<Class value="0"/>
<MarkAnchor Format="3">
<XCoordinate value="0"/>
<YCoordinate value="150"/>
<YDeviceTable>
<StartSize value="0"/>
<EndSize value="0"/>
<DeltaFormat value="32768"/>
</YDeviceTable>
</MarkAnchor>
</MarkRecord>
</MarkArray>
<BaseArray>
<!-- BaseCount=1 -->
<BaseRecord index="0">
<BaseAnchor index="0" Format="1">
<XCoordinate value="0"/>
<YCoordinate value="0"/>
</BaseAnchor>
</BaseRecord>
</BaseArray>
</MarkBasePos>
</Lookup>
<Lookup index="1">
<LookupType value="4"/>
<LookupFlag value="0"/>
<!-- SubTableCount=1 -->
<MarkBasePos index="0" Format="1">
<MarkCoverage>
<Glyph value="macron"/>
</MarkCoverage>
<BaseCoverage>
<Glyph value="a"/>
</BaseCoverage>
<!-- ClassCount=1 -->
<MarkArray>
<!-- MarkCount=1 -->
<MarkRecord index="0">
<Class value="0"/>
<MarkAnchor Format="3">
<XCoordinate value="0"/>
<YCoordinate value="150"/>
<YDeviceTable>
<StartSize value="0"/>
<EndSize value="0"/>
<DeltaFormat value="32768"/>
</YDeviceTable>
</MarkAnchor>
</MarkRecord>
</MarkArray>
<BaseArray>
<!-- BaseCount=1 -->
<BaseRecord index="0">
<BaseAnchor index="0" Format="1">
<XCoordinate value="0"/>
<YCoordinate value="0"/>
</BaseAnchor>
</BaseRecord>
</BaseArray>
</MarkBasePos>
</Lookup>
</LookupList>
</GPOS>
</ttFont>