diff --git a/font-patcher b/font-patcher index c6e1b50cff..e9a01bb425 100755 --- a/font-patcher +++ b/font-patcher @@ -803,7 +803,7 @@ class font_patcher: box_enabled = False # Cowardly not scaling existing glyphs, although the code would allow this # Stretch 'xz' or 'pa' (preserve aspect ratio) - # Supported params: overlap | careful | xy-ratio | dont_copy + # Supported params: overlap | careful | xy-ratio | dont_copy | ypadding # Overlap value is used horizontally but vertically limited to 0.01 # Careful does not overwrite/modify existing glyphs # The xy-ratio limits the x-scale for a given y-scale to make the ratio <= this value (to prevent over-wide glyphs) @@ -887,7 +887,7 @@ class font_patcher: 0xf0de: {'align': 'c', 'valign': '', 'stretch': 'pa', 'params': {}} } SYM_ATTR_HEAVYBRACKETS = { - 'default': {'align': 'c', 'valign': 'c', 'stretch': 'pa', 'params': {'careful': True}} + 'default': {'align': 'c', 'valign': 'c', 'stretch': 'pa', 'params': {'careful': True, 'ypadding': 0.15}} } SYM_ATTR_BOX = { 'default': {'align': 'c', 'valign': 'c', 'stretch': 'xy', 'params': {'overlap': 0.02, 'dont_copy': box_keep}}, @@ -984,6 +984,10 @@ class font_patcher: range(0xf221, 0xf22d + 1), # gender or so range(0xf255, 0xf25b + 1), # hand symbols ]} + HEAVY_SCALE_LIST = {'ScaleGlyph': 0x2771, # widest bracket, horizontally + 'GlyphsToScale': [ + (0x276c, 0x2771) # all + ]} OCTI_SCALE_LIST = {'ScaleGroups': [ [*range(0xf03d, 0xf040 + 1), 0xf019, 0xf030, 0xf04a, 0xf050, 0xf071, 0xf08c ], # arrows [0xF0E7, # Smily and ... @@ -1021,7 +1025,7 @@ class font_patcher: # Symbol font ranges self.patch_set = [ {'Enabled': True, 'Name': "Seti-UI + Custom", 'Filename': "original-source.otf", 'Exact': False, 'SymStart': 0xE4FA, 'SymEnd': 0xE5FF, 'SrcStart': 0xE5FA, 'ScaleRules': None, 'Attributes': SYM_ATTR_DEFAULT}, - {'Enabled': True, 'Name': "Heavy Angle Brackets", 'Filename': "extraglyphs.sfd", 'Exact': True, 'SymStart': 0x276C, 'SymEnd': 0x2771, 'SrcStart': None, 'ScaleRules': None, 'Attributes': SYM_ATTR_HEAVYBRACKETS}, + {'Enabled': True, 'Name': "Heavy Angle Brackets", 'Filename': "extraglyphs.sfd", 'Exact': True, 'SymStart': 0x276C, 'SymEnd': 0x2771, 'SrcStart': None, 'ScaleRules': HEAVY_SCALE_LIST, 'Attributes': SYM_ATTR_HEAVYBRACKETS}, {'Enabled': box_enabled, 'Name': "Box Drawing", 'Filename': "extraglyphs.sfd", 'Exact': True, 'SymStart': 0x2500, 'SymEnd': 0x259F, 'SrcStart': None, 'ScaleRules': BOX_SCALE_LIST, 'Attributes': SYM_ATTR_BOX}, {'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}, @@ -1387,9 +1391,16 @@ class font_patcher: (scale_ratio_x, scale_ratio_y) = self.get_scale_factors(sym_dim, sym_attr['stretch']) overlap = sym_attr['params'].get('overlap') + padding = sym_attr['params'].get('ypadding') + if overlap and padding: + logger.critical("Conflicting params: overlap and ypadding") + sys.exit(1) if overlap: scale_ratio_x *= 1.0 + (self.font_dim['width'] / (sym_dim['width'] * scale_ratio_x)) * overlap y_overlap = min(0.01, overlap) # never aggressive vertical overlap + else: + y_overlap = -padding if padding else None + if y_overlap: scale_ratio_y *= 1.0 + (self.font_dim['height'] / (sym_dim['height'] * scale_ratio_y)) * y_overlap # Size in x to size in y ratio limit (to prevent over-wide glyphs)