@@ -1168,18 +1168,20 @@ def _gatherAnchorsForLookup(gpos, lookupIndex):
1168
1168
if (lookup .LookupType == 9 ):
1169
1169
subtable = subtable .ExtSubTable
1170
1170
subtableAnchors = _handleAnchorLookupType4Format1 (subtable )
1171
- allAnchorGroups . append ( subtableAnchors )
1171
+ allAnchorGroups = allAnchorGroups + subtableAnchors
1172
1172
return allAnchorGroups
1173
1173
1174
1174
1175
1175
def _handleAnchorLookupType4Format1 (subtable ):
1176
1176
"""
1177
1177
Extract anchors from a Lookup Type 4 Format 1.
1178
+ Returns a list of anchor group data dicts in the following format:
1179
+ {
1180
+ "baseAnchors": {"A": {"x": 672, "y": 1600}, "B": {"x": 624, "y": 1600}},
1181
+ "markAnchors": {'gravecomb': {'x': -400, 'y': 1500}, 'acutecomb': {'x': -630, 'y': 1500}},
1182
+ }
1178
1183
"""
1179
- anchors = {
1180
- "baseAnchors" : {},
1181
- "markAnchors" : {},
1182
- }
1184
+ anchors = []
1183
1185
1184
1186
if subtable .LookupType not in (4 , 6 ):
1185
1187
print (f" Skipping Anchor lookup subtable with unsupported LookupType { subtable .LookupType } ." )
@@ -1191,12 +1193,26 @@ def _handleAnchorLookupType4Format1(subtable):
1191
1193
markCoverage = subtable .MarkCoverage .glyphs if subtableIsType4 else subtable .Mark1Coverage .glyphs
1192
1194
1193
1195
for baseRecordIndex , baseRecord in enumerate (subtable .BaseArray .BaseRecord if subtableIsType4 else subtable .Mark2Array .Mark2Record ):
1194
- baseAnchor = baseRecord .BaseAnchor [0 ] if subtableIsType4 else baseRecord .Mark2Anchor [0 ]
1195
- anchors ["baseAnchors" ].update ({baseCoverage [baseRecordIndex ]: {"x" : baseAnchor .XCoordinate , "y" : baseAnchor .YCoordinate }})
1196
+ for baseAnchorIndex , baseAnchor in enumerate (baseRecord .BaseAnchor if subtableIsType4 else baseRecord .Mark2Anchor ):
1197
+ for i in range (len (anchors ), baseAnchorIndex + 1 ):
1198
+ anchors .append ({
1199
+ "baseAnchors" : {},
1200
+ "markAnchors" : {},
1201
+ })
1202
+ if baseAnchor :
1203
+ anchors [baseAnchorIndex ]["baseAnchors" ].update ({baseCoverage [baseRecordIndex ]: {"x" : baseAnchor .XCoordinate , "y" : baseAnchor .YCoordinate }})
1196
1204
1197
1205
for markRecordIndex , markRecord in enumerate (subtable .MarkArray .MarkRecord if subtableIsType4 else subtable .Mark1Array .MarkRecord ):
1206
+ for i in range (len (anchors ), markRecord .Class + 1 ):
1207
+ anchors .append ({
1208
+ "baseAnchors" : {},
1209
+ "markAnchors" : {},
1210
+ })
1198
1211
markAnchor = markRecord .MarkAnchor
1199
- anchors ["markAnchors" ].update ({markCoverage [markRecordIndex ]: {"x" : markAnchor .XCoordinate , "y" : markAnchor .YCoordinate }})
1212
+ if (markAnchor .Format != 1 ):
1213
+ print (f" Unexpected markAnchor format { markAnchor .Format } ." )
1214
+ continue
1215
+ anchors [markRecord .Class ]["markAnchors" ].update ({markCoverage [markRecordIndex ]: {"x" : markAnchor .XCoordinate , "y" : markAnchor .YCoordinate }})
1200
1216
1201
1217
return anchors
1202
1218
0 commit comments