From ffb202d93a5f381b090f10dfbb6b1b731757d6aa Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 17 Jan 2013 12:19:19 +0530 Subject: [PATCH] Font subsetting: Fix a bug in the parsing of the GSUB table that could cause some ligatures to not be included in the subset font --- src/calibre/utils/fonts/sfnt/gsub.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/calibre/utils/fonts/sfnt/gsub.py b/src/calibre/utils/fonts/sfnt/gsub.py index 77d7db8519..aa634b59a2 100644 --- a/src/calibre/utils/fonts/sfnt/gsub.py +++ b/src/calibre/utils/fonts/sfnt/gsub.py @@ -60,14 +60,15 @@ class LigatureSubstitution(UnknownLookupSubTable): def read_ligature(self, data): lig_glyph, count = data.unpack('HH') - components = data.unpack('%dH'%count, single_special=False) + components = data.unpack('%dH'%(count-1), single_special=False) return (lig_glyph, components) def all_substitutions(self, glyph_ids): gid_index_map = self.coverage.coverage_indices(glyph_ids) ans = set() - for index in gid_index_map.itervalues(): + for start_glyph_id, index in gid_index_map.iteritems(): for glyph_id, components in self.coverage_to_lig_map[index]: + components = (start_glyph_id,) + (components) if set(components).issubset(glyph_ids): ans.add(glyph_id) return ans