mirror of
https://github.com/ryanoasis/nerd-fonts.git
synced 2024-09-12 09:41:47 +02:00
font-patcher: Rename ScaleGlyph to ScaleRules
[why] We have still a confusing naming. There are two different things that are called 'ScaleGlyph': - The setting in the patch set - The reference glyph for old style scaling [how] Rename the patch set member to ScaleRules, as this is what in contained. Also rename variable names accordingly. Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
This commit is contained in:
parent
6bfad7872e
commit
e4e6887d9e
1 changed files with 53 additions and 53 deletions
106
font-patcher
106
font-patcher
|
@ -299,7 +299,7 @@ class font_patcher:
|
|||
SrcStart = patch['SrcStart']
|
||||
if not SrcStart:
|
||||
SrcStart = patch['SymStart']
|
||||
self.copy_glyphs(SrcStart, symfont, patch['SymStart'], patch['SymEnd'], patch['Exact'], patch['ScaleGlyph'], patch['Name'], patch['Attributes'])
|
||||
self.copy_glyphs(SrcStart, symfont, patch['SymStart'], patch['SymEnd'], patch['Exact'], patch['ScaleRules'], patch['Name'], patch['Attributes'])
|
||||
|
||||
if symfont:
|
||||
symfont.close()
|
||||
|
@ -742,7 +742,7 @@ class font_patcher:
|
|||
# Most glyphs we want to maximize during the scale. However, there are some
|
||||
# that need to be small or stay relative in size to each other.
|
||||
# The following list are those glyphs. A tuple represents a range.
|
||||
# See prepareScaleGlyph() for an explanation how this needs to look like.
|
||||
# See prepareScaleRules() for an explanation how this needs to look like.
|
||||
# The codepoints mentioned here are symbol-font-codepoints.
|
||||
DEVI_SCALE_LIST = {'ScaleGlyph': 0xE60E, # Android logo
|
||||
'GlyphsToScale': [
|
||||
|
@ -789,28 +789,28 @@ class font_patcher:
|
|||
# Define the character ranges
|
||||
# Symbol font ranges
|
||||
self.patch_set = [
|
||||
{'Enabled': True, 'Name': "Seti-UI + Custom", 'Filename': "original-source.otf", 'Exact': False, 'SymStart': 0xE4FA, 'SymEnd': 0xE5AA, 'SrcStart': 0xE5FA, 'ScaleGlyph': None, 'Attributes': SYM_ATTR_DEFAULT},
|
||||
{'Enabled': True, 'Name': "Devicons", 'Filename': "devicons.ttf", 'Exact': False, 'SymStart': 0xE600, 'SymEnd': 0xE6C5, 'SrcStart': 0xE700, 'ScaleGlyph': DEVI_SCALE_LIST, 'Attributes': SYM_ATTR_DEFAULT},
|
||||
{'Enabled': self.args.powerline, 'Name': "Powerline Symbols", 'Filename': "powerline-symbols/PowerlineSymbols.otf", 'Exact': True, 'SymStart': 0xE0A0, 'SymEnd': 0xE0A2, 'SrcStart': None, 'ScaleGlyph': None, 'Attributes': SYM_ATTR_POWERLINE},
|
||||
{'Enabled': self.args.powerline, 'Name': "Powerline Symbols", 'Filename': "powerline-symbols/PowerlineSymbols.otf", 'Exact': True, 'SymStart': 0xE0B0, 'SymEnd': 0xE0B3, 'SrcStart': None, 'ScaleGlyph': None, 'Attributes': SYM_ATTR_POWERLINE},
|
||||
{'Enabled': self.args.powerlineextra, 'Name': "Powerline Extra Symbols", 'Filename': "PowerlineExtraSymbols.otf", 'Exact': True, 'SymStart': 0xE0A3, 'SymEnd': 0xE0A3, 'SrcStart': None, 'ScaleGlyph': None, 'Attributes': SYM_ATTR_POWERLINE},
|
||||
{'Enabled': self.args.powerlineextra, 'Name': "Powerline Extra Symbols", 'Filename': "PowerlineExtraSymbols.otf", 'Exact': True, 'SymStart': 0xE0B4, 'SymEnd': 0xE0C8, 'SrcStart': None, 'ScaleGlyph': None, 'Attributes': SYM_ATTR_POWERLINE},
|
||||
{'Enabled': self.args.powerlineextra, 'Name': "Powerline Extra Symbols", 'Filename': "PowerlineExtraSymbols.otf", 'Exact': True, 'SymStart': 0xE0CA, 'SymEnd': 0xE0CA, 'SrcStart': None, 'ScaleGlyph': None, 'Attributes': SYM_ATTR_POWERLINE},
|
||||
{'Enabled': self.args.powerlineextra, 'Name': "Powerline Extra Symbols", 'Filename': "PowerlineExtraSymbols.otf", 'Exact': True, 'SymStart': 0xE0CC, 'SymEnd': 0xE0D4, 'SrcStart': None, 'ScaleGlyph': None, 'Attributes': SYM_ATTR_POWERLINE},
|
||||
{'Enabled': self.args.pomicons, 'Name': "Pomicons", 'Filename': "Pomicons.otf", 'Exact': True, 'SymStart': 0xE000, 'SymEnd': 0xE00A, 'SrcStart': None, 'ScaleGlyph': None, 'Attributes': SYM_ATTR_DEFAULT},
|
||||
{'Enabled': self.args.fontawesome, 'Name': "Font Awesome", 'Filename': "font-awesome/FontAwesome.otf", 'Exact': True, 'SymStart': 0xF000, 'SymEnd': 0xF2E0, 'SrcStart': None, 'ScaleGlyph': FONTA_SCALE_LIST, 'Attributes': SYM_ATTR_FONTA},
|
||||
{'Enabled': self.args.fontawesomeextension, 'Name': "Font Awesome Extension", 'Filename': "font-awesome-extension.ttf", 'Exact': False, 'SymStart': 0xE000, 'SymEnd': 0xE0A9, 'SrcStart': 0xE200, 'ScaleGlyph': None, 'Attributes': SYM_ATTR_DEFAULT}, # Maximize
|
||||
{'Enabled': self.args.powersymbols, 'Name': "Power Symbols", 'Filename': "Unicode_IEC_symbol_font.otf", 'Exact': True, 'SymStart': 0x23FB, 'SymEnd': 0x23FE, 'SrcStart': None, 'ScaleGlyph': None, 'Attributes': SYM_ATTR_DEFAULT}, # Power, Power On/Off, Power On, Sleep
|
||||
{'Enabled': self.args.powersymbols, 'Name': "Power Symbols", 'Filename': "Unicode_IEC_symbol_font.otf", 'Exact': True, 'SymStart': 0x2B58, 'SymEnd': 0x2B58, 'SrcStart': None, 'ScaleGlyph': None, 'Attributes': SYM_ATTR_DEFAULT}, # Heavy Circle (aka Power Off)
|
||||
{'Enabled': self.args.material, 'Name': "Material", 'Filename': "materialdesignicons-webfont.ttf", 'Exact': False, 'SymStart': 0xF001, 'SymEnd': 0xF847, 'SrcStart': 0xF500, 'ScaleGlyph': None, 'Attributes': SYM_ATTR_DEFAULT},
|
||||
{'Enabled': self.args.weather, 'Name': "Weather Icons", 'Filename': "weather-icons/weathericons-regular-webfont.ttf", 'Exact': False, 'SymStart': 0xF000, 'SymEnd': 0xF0EB, 'SrcStart': 0xE300, 'ScaleGlyph': WEATH_SCALE_LIST, 'Attributes': SYM_ATTR_DEFAULT},
|
||||
{'Enabled': self.args.fontlogos, 'Name': "Font Logos", 'Filename': "font-logos.ttf", 'Exact': True, 'SymStart': 0xF300, 'SymEnd': 0xF32F, 'SrcStart': None, 'ScaleGlyph': None, 'Attributes': SYM_ATTR_DEFAULT},
|
||||
{'Enabled': self.args.octicons, 'Name': "Octicons", 'Filename': "octicons.ttf", 'Exact': False, 'SymStart': 0xF000, 'SymEnd': 0xF105, 'SrcStart': 0xF400, 'ScaleGlyph': OCTI_SCALE_LIST, 'Attributes': SYM_ATTR_DEFAULT}, # Magnifying glass
|
||||
{'Enabled': self.args.octicons, 'Name': "Octicons", 'Filename': "octicons.ttf", 'Exact': True, 'SymStart': 0x2665, 'SymEnd': 0x2665, 'SrcStart': None, 'ScaleGlyph': OCTI_SCALE_LIST, 'Attributes': SYM_ATTR_DEFAULT}, # Heart
|
||||
{'Enabled': self.args.octicons, 'Name': "Octicons", 'Filename': "octicons.ttf", 'Exact': True, 'SymStart': 0X26A1, 'SymEnd': 0X26A1, 'SrcStart': None, 'ScaleGlyph': OCTI_SCALE_LIST, 'Attributes': SYM_ATTR_DEFAULT}, # Zap
|
||||
{'Enabled': self.args.octicons, 'Name': "Octicons", 'Filename': "octicons.ttf", 'Exact': False, 'SymStart': 0xF27C, 'SymEnd': 0xF27C, 'SrcStart': 0xF4A9, 'ScaleGlyph': OCTI_SCALE_LIST, 'Attributes': SYM_ATTR_DEFAULT}, # Desktop
|
||||
{'Enabled': self.args.codicons, 'Name': "Codicons", 'Filename': "codicons/codicon.ttf", 'Exact': True, 'SymStart': 0xEA60, 'SymEnd': 0xEBEB, 'SrcStart': None, 'ScaleGlyph': None, 'Attributes': SYM_ATTR_DEFAULT},
|
||||
{'Enabled': self.args.custom, 'Name': "Custom", 'Filename': self.args.custom, 'Exact': True, 'SymStart': 0x0000, 'SymEnd': 0x0000, 'SrcStart': None, 'ScaleGlyph': None, 'Attributes': CUSTOM_ATTR}
|
||||
{'Enabled': True, 'Name': "Seti-UI + Custom", 'Filename': "original-source.otf", 'Exact': False, 'SymStart': 0xE4FA, 'SymEnd': 0xE5AA, 'SrcStart': 0xE5FA, 'ScaleRules': None, 'Attributes': SYM_ATTR_DEFAULT},
|
||||
{'Enabled': True, 'Name': "Devicons", 'Filename': "devicons.ttf", 'Exact': False, 'SymStart': 0xE600, 'SymEnd': 0xE6C5, 'SrcStart': 0xE700, 'ScaleRules': DEVI_SCALE_LIST, 'Attributes': SYM_ATTR_DEFAULT},
|
||||
{'Enabled': self.args.powerline, 'Name': "Powerline Symbols", 'Filename': "powerline-symbols/PowerlineSymbols.otf", 'Exact': True, 'SymStart': 0xE0A0, 'SymEnd': 0xE0A2, 'SrcStart': None, 'ScaleRules': None, 'Attributes': SYM_ATTR_POWERLINE},
|
||||
{'Enabled': self.args.powerline, 'Name': "Powerline Symbols", 'Filename': "powerline-symbols/PowerlineSymbols.otf", 'Exact': True, 'SymStart': 0xE0B0, 'SymEnd': 0xE0B3, 'SrcStart': None, 'ScaleRules': None, 'Attributes': SYM_ATTR_POWERLINE},
|
||||
{'Enabled': self.args.powerlineextra, 'Name': "Powerline Extra Symbols", 'Filename': "PowerlineExtraSymbols.otf", 'Exact': True, 'SymStart': 0xE0A3, 'SymEnd': 0xE0A3, 'SrcStart': None, 'ScaleRules': None, 'Attributes': SYM_ATTR_POWERLINE},
|
||||
{'Enabled': self.args.powerlineextra, 'Name': "Powerline Extra Symbols", 'Filename': "PowerlineExtraSymbols.otf", 'Exact': True, 'SymStart': 0xE0B4, 'SymEnd': 0xE0C8, 'SrcStart': None, 'ScaleRules': None, 'Attributes': SYM_ATTR_POWERLINE},
|
||||
{'Enabled': self.args.powerlineextra, 'Name': "Powerline Extra Symbols", 'Filename': "PowerlineExtraSymbols.otf", 'Exact': True, 'SymStart': 0xE0CA, 'SymEnd': 0xE0CA, 'SrcStart': None, 'ScaleRules': None, 'Attributes': SYM_ATTR_POWERLINE},
|
||||
{'Enabled': self.args.powerlineextra, 'Name': "Powerline Extra Symbols", 'Filename': "PowerlineExtraSymbols.otf", 'Exact': True, 'SymStart': 0xE0CC, 'SymEnd': 0xE0D4, 'SrcStart': None, 'ScaleRules': None, 'Attributes': SYM_ATTR_POWERLINE},
|
||||
{'Enabled': self.args.pomicons, 'Name': "Pomicons", 'Filename': "Pomicons.otf", 'Exact': True, 'SymStart': 0xE000, 'SymEnd': 0xE00A, 'SrcStart': None, 'ScaleRules': None, 'Attributes': SYM_ATTR_DEFAULT},
|
||||
{'Enabled': self.args.fontawesome, 'Name': "Font Awesome", 'Filename': "font-awesome/FontAwesome.otf", 'Exact': True, 'SymStart': 0xF000, 'SymEnd': 0xF2E0, 'SrcStart': None, 'ScaleRules': FONTA_SCALE_LIST, 'Attributes': SYM_ATTR_FONTA},
|
||||
{'Enabled': self.args.fontawesomeextension, 'Name': "Font Awesome Extension", 'Filename': "font-awesome-extension.ttf", 'Exact': False, 'SymStart': 0xE000, 'SymEnd': 0xE0A9, 'SrcStart': 0xE200, 'ScaleRules': None, 'Attributes': SYM_ATTR_DEFAULT}, # Maximize
|
||||
{'Enabled': self.args.powersymbols, 'Name': "Power Symbols", 'Filename': "Unicode_IEC_symbol_font.otf", 'Exact': True, 'SymStart': 0x23FB, 'SymEnd': 0x23FE, 'SrcStart': None, 'ScaleRules': None, 'Attributes': SYM_ATTR_DEFAULT}, # Power, Power On/Off, Power On, Sleep
|
||||
{'Enabled': self.args.powersymbols, 'Name': "Power Symbols", 'Filename': "Unicode_IEC_symbol_font.otf", 'Exact': True, 'SymStart': 0x2B58, 'SymEnd': 0x2B58, 'SrcStart': None, 'ScaleRules': None, 'Attributes': SYM_ATTR_DEFAULT}, # Heavy Circle (aka Power Off)
|
||||
{'Enabled': self.args.material, 'Name': "Material", 'Filename': "materialdesignicons-webfont.ttf", 'Exact': False, 'SymStart': 0xF001, 'SymEnd': 0xF847, 'SrcStart': 0xF500, 'ScaleRules': None, 'Attributes': SYM_ATTR_DEFAULT},
|
||||
{'Enabled': self.args.weather, 'Name': "Weather Icons", 'Filename': "weather-icons/weathericons-regular-webfont.ttf", 'Exact': False, 'SymStart': 0xF000, 'SymEnd': 0xF0EB, 'SrcStart': 0xE300, 'ScaleRules': WEATH_SCALE_LIST, 'Attributes': SYM_ATTR_DEFAULT},
|
||||
{'Enabled': self.args.fontlogos, 'Name': "Font Logos", 'Filename': "font-logos.ttf", 'Exact': True, 'SymStart': 0xF300, 'SymEnd': 0xF32F, 'SrcStart': None, 'ScaleRules': None, 'Attributes': SYM_ATTR_DEFAULT},
|
||||
{'Enabled': self.args.octicons, 'Name': "Octicons", 'Filename': "octicons.ttf", 'Exact': False, 'SymStart': 0xF000, 'SymEnd': 0xF105, 'SrcStart': 0xF400, 'ScaleRules': OCTI_SCALE_LIST, 'Attributes': SYM_ATTR_DEFAULT}, # Magnifying glass
|
||||
{'Enabled': self.args.octicons, 'Name': "Octicons", 'Filename': "octicons.ttf", 'Exact': True, 'SymStart': 0x2665, 'SymEnd': 0x2665, 'SrcStart': None, 'ScaleRules': OCTI_SCALE_LIST, 'Attributes': SYM_ATTR_DEFAULT}, # Heart
|
||||
{'Enabled': self.args.octicons, 'Name': "Octicons", 'Filename': "octicons.ttf", 'Exact': True, 'SymStart': 0X26A1, 'SymEnd': 0X26A1, 'SrcStart': None, 'ScaleRules': OCTI_SCALE_LIST, 'Attributes': SYM_ATTR_DEFAULT}, # Zap
|
||||
{'Enabled': self.args.octicons, 'Name': "Octicons", 'Filename': "octicons.ttf", 'Exact': False, 'SymStart': 0xF27C, 'SymEnd': 0xF27C, 'SrcStart': 0xF4A9, 'ScaleRules': OCTI_SCALE_LIST, 'Attributes': SYM_ATTR_DEFAULT}, # Desktop
|
||||
{'Enabled': self.args.codicons, 'Name': "Codicons", 'Filename': "codicons/codicon.ttf", 'Exact': True, 'SymStart': 0xEA60, 'SymEnd': 0xEBEB, 'SrcStart': None, 'ScaleRules': None, 'Attributes': SYM_ATTR_DEFAULT},
|
||||
{'Enabled': self.args.custom, 'Name': "Custom", 'Filename': self.args.custom, 'Exact': True, 'SymStart': 0x0000, 'SymEnd': 0x0000, 'SrcStart': None, 'ScaleRules': None, 'Attributes': CUSTOM_ATTR}
|
||||
]
|
||||
|
||||
def setup_line_dimensions(self):
|
||||
|
@ -921,7 +921,7 @@ class font_patcher:
|
|||
return scale_ratio
|
||||
|
||||
|
||||
def copy_glyphs(self, sourceFontStart, symbolFont, symbolFontStart, symbolFontEnd, exactEncoding, scaleGlyph, setName, attributes):
|
||||
def copy_glyphs(self, sourceFontStart, symbolFont, symbolFontStart, symbolFontEnd, exactEncoding, scaleRules, setName, attributes):
|
||||
""" Copies symbol glyphs into self.sourceFont """
|
||||
progressText = ''
|
||||
careful = False
|
||||
|
@ -1001,7 +1001,7 @@ class font_patcher:
|
|||
self.sourceFont[currentSourceFontGlyph].removePosSub("*")
|
||||
|
||||
# This will destroy any content currently in currentSourceFontGlyph, so do it first
|
||||
scale_glyph_data = self.get_glyph_scale(sym_glyph.encoding, scaleGlyph, symbolFont, currentSourceFontGlyph) if scaleGlyph is not None else None
|
||||
glyph_scale_data = self.get_glyph_scale(sym_glyph.encoding, scaleRules, symbolFont, currentSourceFontGlyph) if scaleRules is not None else None
|
||||
|
||||
# Select and copy symbol from its encoding point
|
||||
# We need to do this select after the careful check, this way we don't
|
||||
|
@ -1028,9 +1028,9 @@ class font_patcher:
|
|||
# to fit in both the x and y directions
|
||||
if sym_attr['stretch'] == 'pa':
|
||||
scale_ratio_x = None
|
||||
if scale_glyph_data:
|
||||
if glyph_scale_data:
|
||||
# We want to preserve the relative size of each glyph in a glyph group
|
||||
scale_ratio_x = scale_glyph_data[0]
|
||||
scale_ratio_x = glyph_scale_data[0]
|
||||
if scale_ratio_x is None:
|
||||
# In the remaining cases, each glyph is sized independently to each other
|
||||
scale_ratio_x = self.get_scale_factor(sym_dim)
|
||||
|
@ -1039,8 +1039,8 @@ class font_patcher:
|
|||
if 'x' in sym_attr['stretch']:
|
||||
# Stretch the glyph horizontally to fit the entire available width
|
||||
scale_ratio_x = None
|
||||
if scale_glyph_data is not None and scale_glyph_data[1] is not None:
|
||||
scale_ratio_x = self.font_dim['width'] / scale_glyph_data[1]['width']
|
||||
if glyph_scale_data is not None and glyph_scale_data[1] is not None:
|
||||
scale_ratio_x = self.font_dim['width'] / glyph_scale_data[1]['width']
|
||||
if scale_ratio_x is None:
|
||||
scale_ratio_x = self.font_dim['width'] / sym_dim['width']
|
||||
# end if single width
|
||||
|
@ -1054,8 +1054,8 @@ class font_patcher:
|
|||
# Stretch the glyph vertically to total line height (good for powerline separators)
|
||||
# Currently stretching vertically for both monospace and double-width
|
||||
scale_ratio_y = None
|
||||
if scale_glyph_data is not None and scale_glyph_data[1] is not None:
|
||||
scale_ratio_y = self.font_dim['height'] / scale_glyph_data[1]['height']
|
||||
if glyph_scale_data is not None and glyph_scale_data[1] is not None:
|
||||
scale_ratio_y = self.font_dim['height'] / glyph_scale_data[1]['height']
|
||||
if scale_ratio_y is None:
|
||||
scale_ratio_y = self.font_dim['height'] / sym_dim['height']
|
||||
|
||||
|
@ -1071,8 +1071,8 @@ class font_patcher:
|
|||
# Use the dimensions from the newly pasted and stretched glyph to avoid any rounding errors
|
||||
sym_dim = get_glyph_dimensions(self.sourceFont[currentSourceFontGlyph])
|
||||
# Use combined bounding box?
|
||||
if scale_glyph_data is not None and scale_glyph_data[1] is not None:
|
||||
scaleglyph_dim = scale_bounding_box(scale_glyph_data[1], scale_ratio_x, scale_ratio_y)
|
||||
if glyph_scale_data is not None and glyph_scale_data[1] is not None:
|
||||
scaleglyph_dim = scale_bounding_box(glyph_scale_data[1], scale_ratio_x, scale_ratio_y)
|
||||
if scaleglyph_dim['advance'] is None:
|
||||
# On monospaced symbol collections use their advance with, otherwise align horizontally individually
|
||||
scaleglyph_dim['xmin'] = sym_dim['xmin']
|
||||
|
@ -1196,8 +1196,8 @@ class font_patcher:
|
|||
except:
|
||||
pass
|
||||
|
||||
def prepareScaleGlyph(self, scaleGlyph, symbolFont, destGlyph):
|
||||
""" Prepare raw ScaleGlyph data for use """
|
||||
def prepareScaleRules(self, scaleRules, symbolFont, destGlyph):
|
||||
""" Prepare raw ScaleRules data for use """
|
||||
# The GlyphData is a dict with these (possible) entries:
|
||||
# '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)
|
||||
|
@ -1218,40 +1218,40 @@ class font_patcher:
|
|||
# Note that this allows only one group for the whle symbol font, and that the scaling factor is defined by
|
||||
# a specific character, which needs to be manually selected (on each symbol font update).
|
||||
# Previous entries are automatically rewritten to the new style.
|
||||
if 'scales' in scaleGlyph:
|
||||
if 'scales' in scaleRules:
|
||||
# Already prepared... must not happen, ignore call
|
||||
return
|
||||
if 'ScaleGlyph' in scaleGlyph:
|
||||
if 'ScaleGlyph' in scaleRules:
|
||||
# old method. Rewrite to new.
|
||||
flat_list = []
|
||||
for i in scaleGlyph['GlyphsToScale']:
|
||||
for i in scaleRules['GlyphsToScale']:
|
||||
if isinstance(i, tuple):
|
||||
flat_list += list(range(i[0], i[1] + 1))
|
||||
else:
|
||||
flat_list.append(i)
|
||||
scaleGlyph['ScaleGroups'] = [ flat_list ]
|
||||
sym_dim = get_glyph_dimensions(symbolFont[scaleGlyph['ScaleGlyph']])
|
||||
scaleRules['ScaleGroups'] = [ flat_list ]
|
||||
sym_dim = get_glyph_dimensions(symbolFont[scaleRules['ScaleGlyph']])
|
||||
scale = self.get_scale_factor(sym_dim)
|
||||
scaleGlyph['scales'] = [ scale ]
|
||||
scaleRules['scales'] = [ scale ]
|
||||
# The 'old' style keeps just the scale, not the positioning
|
||||
scaleGlyph['bbdims'] = [ None ]
|
||||
scaleRules['bbdims'] = [ None ]
|
||||
else:
|
||||
scaleGlyph['scales'] = []
|
||||
scaleGlyph['bbdims'] = []
|
||||
for group in scaleGlyph['ScaleGroups']:
|
||||
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)
|
||||
scaleGlyph['scales'].append(scale)
|
||||
scaleGlyph['bbdims'].append(sym_dim)
|
||||
scaleRules['scales'].append(scale)
|
||||
scaleRules['bbdims'].append(sym_dim)
|
||||
|
||||
def get_glyph_scale(self, symbol_unicode, scaleGlyph, symbolFont, dest_unicode):
|
||||
""" Determines whether or not to use scaled glyphs for glyphs in passed glyph_list """
|
||||
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 """
|
||||
# Potentially destorys the contents of self.sourceFont[dest_unicode]
|
||||
if not 'scales' in scaleGlyph:
|
||||
if not 'scales' in scaleRules:
|
||||
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['ScaleGroups'], scaleGlyph['scales'], scaleGlyph['bbdims']):
|
||||
self.prepareScaleRules(scaleRules, symbolFont, self.sourceFont[dest_unicode])
|
||||
for glyph_list, scale, box in zip(scaleRules['ScaleGroups'], scaleRules['scales'], scaleRules['bbdims']):
|
||||
if symbol_unicode in glyph_list:
|
||||
return (scale, box)
|
||||
return None
|
||||
|
|
Loading…
Reference in a new issue