From e6126372829bbb47bb447a8b50f1f49c02fd9e78 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 7 Jun 2015 09:47:15 +0530 Subject: [PATCH] Font subsetting: Fix subsetting removing some needed ligatures when subsetting Arabic fonts The GSUB table works by chaining substitution tables. That is later tables in a Lookup can refer to glyphs output by earlier tables. The old code did not take this behavior into account, fix that. --- src/calibre/utils/fonts/sfnt/gsub.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/calibre/utils/fonts/sfnt/gsub.py b/src/calibre/utils/fonts/sfnt/gsub.py index ae8c6394aa..6b74e57c9c 100644 --- a/src/calibre/utils/fonts/sfnt/gsub.py +++ b/src/calibre/utils/fonts/sfnt/gsub.py @@ -171,10 +171,11 @@ class GSUBTable(UnknownTable): self.lookuplist_offset) def all_substitutions(self, glyph_ids): - ans = set() glyph_ids = frozenset(glyph_ids) + ans = set(glyph_ids) for lookup_table in self.lookup_list_table: for subtable in lookup_table: - gids = subtable.all_substitutions(glyph_ids) - ans |= gids - return ans + glyphs = subtable.all_substitutions(ans) + if glyphs: + ans |= glyphs + return ans - {glyph_ids}