From: W. Trevor King Date: Wed, 9 Jan 2013 18:38:51 +0000 (-0500) Subject: font-reduce.py: Add special space handling X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=b5e8f2fd73acac1831d341df74a98e65e5829ba3;p=mw2txt.git font-reduce.py: Add special space handling For some reason, FontForge doesn't like selecting spaces with `select(('ranges',),...)`. No idea why, but this works around the problem. Reported-by: David Loyall --- diff --git a/posts/font-reduce/font-reduce.py b/posts/font-reduce/font-reduce.py index f65d983..67a187f 100755 --- a/posts/font-reduce/font-reduce.py +++ b/posts/font-reduce/font-reduce.py @@ -42,12 +42,20 @@ def convert(input_file, output_file=None, ranges=[(0x20,0x7e)], i = _fontforge.open(input_file) o = _fontforge.font() mappings = [] + copy_space = False for ((istart,istop),(ostart,ostop)) in zip(ranges, targets): i.selection.select(('ranges',), istart, istop) i.copy() o.selection.select(('ranges',), ostart, ostop) o.paste() mappings.append((istart,istop,ostart,ostop)) + if istart <= 0x20 and istop >= 20: + copy_space = True # HACK: FF doesn't like spaces? + if copy_space: + i.selection.select('space') + i.copy() + o.selection.select('space') + o.paste() for attr in ['comment', 'copyright', 'encoding', 'familyname', 'fontname', 'fullname', 'sfntRevision', 'sfnt_names', 'userdata', 'version', 'woffMetadata']: