From b5e8f2fd73acac1831d341df74a98e65e5829ba3 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Wed, 9 Jan 2013 13:38:51 -0500 Subject: [PATCH] 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 --- posts/font-reduce/font-reduce.py | 8 ++++++++ 1 file changed, 8 insertions(+) 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']: -- 2.26.2