From 1e3f57092f025f38b2135ccaada62247092a0d74 Mon Sep 17 00:00:00 2001 From: Cosimo Lupo Date: Thu, 17 Oct 2024 18:03:13 +0200 Subject: [PATCH] [ttx_diff] ensure only the GPOS lookups get xpath'ed for pruning right now the xpath ends up selecting and removing GSUB lookups of type 2, 4, 5 and 6 as well, even though we only intended to prune the GPOS ones. see https://www.w3schools.com/xml/xpath_syntax.asp --- resources/scripts/ttx_diff.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/resources/scripts/ttx_diff.py b/resources/scripts/ttx_diff.py index 66b311d1..81c0b7d0 100755 --- a/resources/scripts/ttx_diff.py +++ b/resources/scripts/ttx_diff.py @@ -412,7 +412,10 @@ def remove_mark_and_kern_lookups(ttx): gpos = ttx.find("GPOS") if gpos is None: return - for lookup in gpos.xpath("//Lookup"): + # './/Lookup' xpath selects all the 'Lookup' elements that are descendants of + # the current 'GPOS' node - no matter where they are under it. + # Most importantly, this _excludes_ GSUB lookups, which shouldn't be pruned. + for lookup in gpos.xpath(".//Lookup"): lookup_type_el = lookup.find("LookupType") lookup_type = int(lookup_type_el.attrib["value"]) is_extension = lookup_type == 9