mirror of
https://github.com/ryanoasis/nerd-fonts.git
synced 2024-09-12 09:41:47 +02:00
font-patcher: Rename new GlyphsToScale
[why] We now have the 'old' and the 'new' GlyphsToScale things, which behave differently, but they have the same name. That can lead to confusion. At least I am always confused when I look at the code after a month or so. [how] Call the 'new' method 'ScaleGroup' instead. The 'new' feature (which includes creating a combined bounding box and synchronized shifting) 'ScaleGroup'. The 'old' feature (which scales all glyphs as if they would have the size of one reference glyph; shifting is individual) still consists of 'ScaleGlyph' and 'GlyphsToScale'. Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
This commit is contained in:
parent
2ba5dec363
commit
6bfad7872e
1 changed files with 13 additions and 13 deletions
26
font-patcher
26
font-patcher
|
@ -748,7 +748,7 @@ class font_patcher:
|
|||
'GlyphsToScale': [
|
||||
(0xe6bd, 0xe6c3) # very small things
|
||||
]}
|
||||
FONTA_SCALE_LIST = {'GlyphsToScale': [
|
||||
FONTA_SCALE_LIST = {'ScaleGroups': [
|
||||
[0xf005, 0xf006, 0xf089], # star, star empty, half star
|
||||
range(0xf026, 0xf028 + 1), # volume off, down, up
|
||||
range(0xf02b, 0xf02c + 1), # tag, tags
|
||||
|
@ -778,7 +778,7 @@ class font_patcher:
|
|||
0xf078, 0xf0a2, 0xf0a3, 0xf0a4, # chevrons
|
||||
0xf0ca, # dash
|
||||
]}
|
||||
WEATH_SCALE_LIST = {'GlyphsToScale': [
|
||||
WEATH_SCALE_LIST = {'ScaleGroups': [
|
||||
range(0xf095, 0xf0b0 + 1), # moon phases
|
||||
range(0xf0b7, 0xf0c3 + 1), # wind strengths
|
||||
range(0xf053, 0xf055 + 1), # thermometer
|
||||
|
@ -1199,16 +1199,16 @@ class font_patcher:
|
|||
def prepareScaleGlyph(self, scaleGlyph, symbolFont, destGlyph):
|
||||
""" Prepare raw ScaleGlyph data for use """
|
||||
# The GlyphData is a dict with these (possible) entries:
|
||||
# 'GlyphsToScale': List of ((lists of glyph codes) or (ranges of glyph codes)) that shall be scaled
|
||||
# 'scales': List of associated scale factors, one for each entry in 'GlyphsToScale' (generated by this function)
|
||||
# 'bbdims': List of associated sym_dim dicts, one for each entry in 'GlyphsToScale' (generated by this function)
|
||||
# Each sym_dim dict describes the combined bounding box of all glyphs in GlyphsToScale
|
||||
# 'ScaleGroups': List of ((lists of glyph codes) or (ranges of glyph codes)) that shall be scaled
|
||||
# 'scales': List of associated scale factors, one for each entry in 'ScaleGroups' (generated by this function)
|
||||
# 'bbdims': List of associated sym_dim dicts, one for each entry in 'ScaleGroups' (generated by this function)
|
||||
# Each sym_dim dict describes the combined bounding box of all glyphs in one ScaleGroups group
|
||||
# Example:
|
||||
# { 'GlyphsToScale': [ range(1, 3), [ 7, 10 ], ],
|
||||
# 'scales': [ 1.23, 1.33, ],
|
||||
# 'bbdims': [ dim_dict1, dim_dict2, ] }
|
||||
# { 'ScaleGroups': [ range(1, 3), [ 7, 10 ], ],
|
||||
# 'scales': [ 1.23, 1.33, ],
|
||||
# 'bbdims': [ dim_dict1, dim_dict2, ] }
|
||||
#
|
||||
# Each item in 'GlyphsToScale' (a range or an explicit list) forms a group of glyphs that shall be
|
||||
# Each item in 'ScaleGroups' (a range or an explicit list) forms a group of glyphs that shall be
|
||||
# as rescaled all with the same and maximum possible (for the included glyphs) factor.
|
||||
# If the 'bbdims' is present they all shall be shifted in the same way.
|
||||
#
|
||||
|
@ -1229,7 +1229,7 @@ class font_patcher:
|
|||
flat_list += list(range(i[0], i[1] + 1))
|
||||
else:
|
||||
flat_list.append(i)
|
||||
scaleGlyph['GlyphsToScale'] = [ flat_list ]
|
||||
scaleGlyph['ScaleGroups'] = [ flat_list ]
|
||||
sym_dim = get_glyph_dimensions(symbolFont[scaleGlyph['ScaleGlyph']])
|
||||
scale = self.get_scale_factor(sym_dim)
|
||||
scaleGlyph['scales'] = [ scale ]
|
||||
|
@ -1238,7 +1238,7 @@ class font_patcher:
|
|||
else:
|
||||
scaleGlyph['scales'] = []
|
||||
scaleGlyph['bbdims'] = []
|
||||
for group in scaleGlyph['GlyphsToScale']:
|
||||
for group in scaleGlyph['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)
|
||||
scaleGlyph['scales'].append(scale)
|
||||
|
@ -1251,7 +1251,7 @@ class font_patcher:
|
|||
if not dest_unicode in self.sourceFont:
|
||||
self.sourceFont.createChar(dest_unicode)
|
||||
self.prepareScaleGlyph(scaleGlyph, symbolFont, self.sourceFont[dest_unicode])
|
||||
for glyph_list, scale, box in zip(scaleGlyph['GlyphsToScale'], scaleGlyph['scales'], scaleGlyph['bbdims']):
|
||||
for glyph_list, scale, box in zip(scaleGlyph['ScaleGroups'], scaleGlyph['scales'], scaleGlyph['bbdims']):
|
||||
if symbol_unicode in glyph_list:
|
||||
return (scale, box)
|
||||
return None
|
||||
|
|
Loading…
Reference in a new issue