Allow for merging of NULL anchors (#3248)

* A failing test for #3247

* Fix up NULL entry/exit records on merge, fixes #3247
This commit is contained in:
Simon Cozens 2023-08-07 17:12:12 +01:00 committed by GitHub
parent a8d5d45b39
commit 57fb47de3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 0 deletions

View File

@ -936,6 +936,15 @@ def merge(merger, self, lst):
self.EntryExitCount = len(self.EntryExitRecord) self.EntryExitCount = len(self.EntryExitRecord)
@AligningMerger.merger(ot.EntryExitRecord)
def merge(merger, self, lst):
if all(master.EntryAnchor is None for master in lst):
self.EntryAnchor = None
if all(master.ExitAnchor is None for master in lst):
self.ExitAnchor = None
merger.mergeObjects(self, lst)
@AligningMerger.merger(ot.Lookup) @AligningMerger.merger(ot.Lookup)
def merge(merger, self, lst): def merge(merger, self, lst):
subtables = merger.lookup_subtables = [l.SubTable for l in lst] subtables = merger.lookup_subtables = [l.SubTable for l in lst]

View File

@ -1902,32 +1902,38 @@ class SparsePositioningMergerTest:
ds.sources[0].font.newGlyph("a").unicode = ord("a") ds.sources[0].font.newGlyph("a").unicode = ord("a")
ds.sources[0].font.newGlyph("b").unicode = ord("b") ds.sources[0].font.newGlyph("b").unicode = ord("b")
ds.sources[0].font.newGlyph("c").unicode = ord("c")
ds.sources[ ds.sources[
0 0
].font.features.text = """ ].font.features.text = """
feature curs { feature curs {
position cursive a <anchor 400 20> <anchor 0 -20>; position cursive a <anchor 400 20> <anchor 0 -20>;
position cursive c <anchor NULL> <anchor 0 -20>;
} curs; } curs;
""" """
ds.sources[1].font.newGlyph("a").unicode = ord("a") ds.sources[1].font.newGlyph("a").unicode = ord("a")
ds.sources[1].font.newGlyph("b").unicode = ord("b") ds.sources[1].font.newGlyph("b").unicode = ord("b")
ds.sources[1].font.newGlyph("c").unicode = ord("c")
ds.sources[ ds.sources[
1 1
].font.features.text = """ ].font.features.text = """
feature curs { feature curs {
position cursive a <anchor 500 20> <anchor 0 -20>; position cursive a <anchor 500 20> <anchor 0 -20>;
position cursive b <anchor 50 22> <anchor 0 -10>; position cursive b <anchor 50 22> <anchor 0 -10>;
position cursive c <anchor NULL> <anchor 0 -20>;
} curs; } curs;
""" """
ds.sources[2].font.newGlyph("a").unicode = ord("a") ds.sources[2].font.newGlyph("a").unicode = ord("a")
ds.sources[2].font.newGlyph("b").unicode = ord("b") ds.sources[2].font.newGlyph("b").unicode = ord("b")
ds.sources[2].font.newGlyph("c").unicode = ord("c")
ds.sources[ ds.sources[
2 2
].font.features.text = """ ].font.features.text = """
feature curs { feature curs {
position cursive b <anchor 100 40> <anchor 0 -30>; position cursive b <anchor 100 40> <anchor 0 -30>;
position cursive c <anchor NULL> <anchor 0 -20>;
} curs; } curs;
""" """