Skip to content

Commit 05a9ec8

Browse files
committed
font-patcher: Fix ScaleRule evaluation
[why] In some cases only some ScaleRule glyphs are used. [how] Store mixture of integers and ranges for ScaleGlyph (as is done for ScaleGroups). Correctly evaluate mixture of integers and ranges. [note] Came up with PR #773 Signed-off-by: Fini Jastrow <[email protected]>
1 parent a56a4fa commit 05a9ec8

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

font-patcher

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1303,15 +1303,15 @@ class font_patcher:
13031303

13041304
if 'ScaleGlyph' in scaleRules:
13051305
# Rewrite to equivalent ScaleGroup
1306-
flat_list = []
1306+
group_list = []
13071307
for i in scaleRules['GlyphsToScale']:
13081308
if isinstance(i, tuple):
1309-
flat_list += list(range(i[0], i[1] + 1))
1309+
group_list.append(range(i[0], i[1] + 1))
13101310
else:
1311-
flat_list.append(i)
1311+
group_list.append(i)
13121312
sym_dim = get_glyph_dimensions(symbolFont[scaleRules['ScaleGlyph']])
13131313
scale = self.get_scale_factor(sym_dim)
1314-
scaleRules['ScaleGroups'].append(flat_list)
1314+
scaleRules['ScaleGroups'].append(group_list)
13151315
scaleRules['scales'].append(scale)
13161316
scaleRules['bbdims'].append(None) # The 'old' style keeps just the scale, not the positioning
13171317

@@ -1323,8 +1323,12 @@ class font_patcher:
13231323
self.sourceFont.createChar(dest_unicode)
13241324
self.prepareScaleRules(scaleRules, symbolFont, self.sourceFont[dest_unicode])
13251325
for glyph_list, scale, box in zip(scaleRules['ScaleGroups'], scaleRules['scales'], scaleRules['bbdims']):
1326-
if symbol_unicode in glyph_list:
1327-
return (scale, box)
1326+
for e in glyph_list:
1327+
if isinstance(e, range):
1328+
if symbol_unicode in e:
1329+
return (scale, box)
1330+
elif symbol_unicode == e:
1331+
return (scale, box)
13281332
return None
13291333

13301334

0 commit comments

Comments
 (0)