Hack for subsetting commonly used ligatures, pending proper parsing of the GSUB table

This commit is contained in:
Kovid Goyal 2012-11-09 17:32:16 +05:30
parent bd9fd5485b
commit 891f362385

View File

@ -76,6 +76,17 @@ def subset(raw, individual_chars, ranges=()):
for r in ranges:
chars += list(xrange(ord(r[0]), ord(r[1])+1))
# Hack pending parsing of the GSUB table, manually add in a few common
# ligatures
ligatures = {'AE':'Æ', 'ae':'æ', 'OE':'Œ', 'IJ':'IJ', 'ij':'ij', 'ue':'',
'ff':'', 'fi':'', 'fl':'', 'ffi':'', 'ffl':'', 'st':''}
all_chars = set(chars)
for ichars, lig in ligatures.iteritems():
ichars = frozenset(map(ord, ichars))
if ichars.issubset(all_chars) and ord(lig) not in all_chars:
all_chars.add(ord(lig))
chars.append(ord(lig))
sfnt = Sfnt(raw)
old_sizes = sfnt.sizes()