mirror of
https://github.com/ryanoasis/nerd-fonts.git
synced 2024-09-19 09:51:48 +02:00
font-patcher: Allow ScaleGroups and ScaleGlyph in one ScaleRules
[why] If a ScaleGlyph is defined that ScaleRules will just be that one rule, even if in parallel the user specified some ScaleGroups. So it is either ScaleGroups or ScaleGlyph but not both. If someone specifies both there is no warning or check. [how] Just allow both. Rewrite the ScaleGlyph to an additional (last) entry in the ScaleGroups. Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
This commit is contained in:
parent
122672b56b
commit
69ccea2ff5
1 changed files with 14 additions and 12 deletions
26
font-patcher
26
font-patcher
|
@ -1226,6 +1226,17 @@ class font_patcher:
|
||||||
if 'scales' in scaleRules:
|
if 'scales' in scaleRules:
|
||||||
# Already prepared... must not happen, ignore call
|
# Already prepared... must not happen, ignore call
|
||||||
return
|
return
|
||||||
|
|
||||||
|
scaleRules['scales'] = []
|
||||||
|
scaleRules['bbdims'] = []
|
||||||
|
if 'ScaleGroups' not in scaleRules:
|
||||||
|
scaleRules['ScaleGroups'] = []
|
||||||
|
for group in scaleRules['ScaleGroups']:
|
||||||
|
sym_dim = get_multiglyph_boundingBox([ symbolFont[g] if g in symbolFont else None for g in group ], destGlyph)
|
||||||
|
scale = self.get_scale_factor(sym_dim)
|
||||||
|
scaleRules['scales'].append(scale)
|
||||||
|
scaleRules['bbdims'].append(sym_dim)
|
||||||
|
|
||||||
if 'ScaleGlyph' in scaleRules:
|
if 'ScaleGlyph' in scaleRules:
|
||||||
# old method. Rewrite to new.
|
# old method. Rewrite to new.
|
||||||
flat_list = []
|
flat_list = []
|
||||||
|
@ -1234,20 +1245,11 @@ class font_patcher:
|
||||||
flat_list += list(range(i[0], i[1] + 1))
|
flat_list += list(range(i[0], i[1] + 1))
|
||||||
else:
|
else:
|
||||||
flat_list.append(i)
|
flat_list.append(i)
|
||||||
scaleRules['ScaleGroups'] = [ flat_list ]
|
|
||||||
sym_dim = get_glyph_dimensions(symbolFont[scaleRules['ScaleGlyph']])
|
sym_dim = get_glyph_dimensions(symbolFont[scaleRules['ScaleGlyph']])
|
||||||
scale = self.get_scale_factor(sym_dim)
|
scale = self.get_scale_factor(sym_dim)
|
||||||
scaleRules['scales'] = [ scale ]
|
scaleRules['ScaleGroups'].append(flat_list)
|
||||||
# The 'old' style keeps just the scale, not the positioning
|
scaleRules['scales'].append(scale)
|
||||||
scaleRules['bbdims'] = [ None ]
|
scaleRules['bbdims'].append(None) # The 'old' style keeps just the scale, not the positioning
|
||||||
else:
|
|
||||||
scaleRules['scales'] = []
|
|
||||||
scaleRules['bbdims'] = []
|
|
||||||
for group in scaleRules['ScaleGroups']:
|
|
||||||
sym_dim = get_multiglyph_boundingBox([ symbolFont[g] if g in symbolFont else None for g in group ], destGlyph)
|
|
||||||
scale = self.get_scale_factor(sym_dim)
|
|
||||||
scaleRules['scales'].append(scale)
|
|
||||||
scaleRules['bbdims'].append(sym_dim)
|
|
||||||
|
|
||||||
def get_glyph_scale(self, symbol_unicode, scaleRules, symbolFont, dest_unicode):
|
def get_glyph_scale(self, symbol_unicode, scaleRules, symbolFont, dest_unicode):
|
||||||
""" Determines whether or not to use scaled glyphs for glyph in passed symbol_unicode """
|
""" Determines whether or not to use scaled glyphs for glyph in passed symbol_unicode """
|
||||||
|
|
Loading…
Reference in a new issue