From 1df21b61271a8dc4aa2daad77a37c141b930de37 Mon Sep 17 00:00:00 2001 From: Fini Jastrow Date: Thu, 2 Jun 2022 13:58:38 +0200 Subject: [PATCH] font-patcher: Preserve padding around Braille glyphs [why] Usually we scale symbols so that they are maximized within one 'cell' of the font. If we do this for the Braille glyphs the bottom dots from un upper line will (almost) touch the top dots of the next line. This is not useful. [how] We add padding around the Braille glyphs, to get about the same distance to the cell borders as the different dots in one glyph have to the other (~10 %, 5% on each side). This also activated the previous commit's shift-fix-code that is only active on padded glyphs. Signed-off-by: Fini Jastrow --- font-patcher | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/font-patcher b/font-patcher index 515a81ad03..55a753ae68 100755 --- a/font-patcher +++ b/font-patcher @@ -550,6 +550,11 @@ class font_patcher: 0xf0de: {'align': 'c', 'valign': '', 'stretch': 'pa', 'params': ''} } + SYM_ATTR_BRAILLE = { + # 'pa' == preserve aspect ratio + 'default': {'align': 'c', 'valign': 'c', 'stretch': 'pa', 'params': {'overlap': -0.05}} + } + CUSTOM_ATTR = { # 'pa' == preserve aspect ratio 'default': {'align': 'c', 'valign': '', 'stretch': '', 'params': ''} @@ -618,7 +623,7 @@ class font_patcher: {'Enabled': self.args.octicons, 'Name': "Octicons", 'Filename': "octicons.ttf", 'Exact': self.octiconsExactEncodingPosition, 'SymStart': 0X26A1, 'SymEnd': 0X26A1, 'SrcStart': None, 'SrcEnd': None, 'ScaleGlyph': OCTI_SCALE_LIST, 'Attributes': SYM_ATTR_DEFAULT}, # Zap {'Enabled': self.args.octicons, 'Name': "Octicons", 'Filename': "octicons.ttf", 'Exact': self.octiconsExactEncodingPosition, 'SymStart': 0xF27C, 'SymEnd': 0xF27C, 'SrcStart': 0xF4A9, 'SrcEnd': 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, 'SrcEnd': None, 'ScaleGlyph': None, 'Attributes': SYM_ATTR_DEFAULT}, - {'Enabled': self.args.braille, 'Name': "Braille", 'Filename': "UBraille.ttf", 'Exact': True, 'SymStart': 0x2800, 'SymEnd': 0x28FF, 'SrcStart': None, 'SrcEnd': None, 'ScaleGlyph': BRAILLE_SCALE_LIST,'Attributes': SYM_ATTR_DEFAULT}, + {'Enabled': self.args.braille, 'Name': "Braille", 'Filename': "UBraille.ttf", 'Exact': True, 'SymStart': 0x2800, 'SymEnd': 0x28FF, 'SrcStart': None, 'SrcEnd': None, 'ScaleGlyph': BRAILLE_SCALE_LIST,'Attributes': SYM_ATTR_BRAILLE}, {'Enabled': self.args.custom, 'Name': "Custom", 'Filename': self.args.custom, 'Exact': True, 'SymStart': 0x0000, 'SymEnd': 0x0000, 'SrcStart': 0x0000, 'SrcEnd': 0x0000, 'ScaleGlyph': None, 'Attributes': CUSTOM_ATTR} ] @@ -823,7 +828,7 @@ class font_patcher: # Use the dimensions from the newly pasted and stretched glyph if overlap >= 0: sym_dim = get_glyph_dimensions(self.sourceFont[currentSourceFontGlyph]) - else + else: sym_dim = get_glyph_dimensions(self.sourceFont[currentSourceFontGlyph], scaleGlyph, scale_ratio_x, scale_ratio_y) y_align_distance = 0 if sym_attr['valign'] == 'c':