Skip to content

Commit faf7503

Browse files
committed
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 <ulf.fini.jastrow@desy.de>
1 parent 0d26d0a commit faf7503

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

font-patcher

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -767,6 +767,11 @@ class font_patcher:
767767
0xf0de: {'align': 'c', 'valign': '', 'stretch': 'pa', 'params': {}}
768768
}
769769

770+
SYM_ATTR_BRAILLE = {
771+
# 'pa' == preserve aspect ratio
772+
'default': {'align': 'c', 'valign': 'c', 'stretch': 'pa', 'params': {'overlap': -0.05}}
773+
}
774+
770775
CUSTOM_ATTR = {
771776
# 'pa' == preserve aspect ratio
772777
'default': {'align': 'c', 'valign': '', 'stretch': '', 'params': {}}
@@ -835,7 +840,7 @@ class font_patcher:
835840
{'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
836841
{'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
837842
{'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},
838-
{'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},
843+
{'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},
839844
{'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}
840845
]
841846

@@ -1070,7 +1075,7 @@ class font_patcher:
10701075
# Use the dimensions from the newly pasted and stretched glyph
10711076
if overlap >= 0:
10721077
sym_dim = get_glyph_dimensions(self.sourceFont[currentSourceFontGlyph])
1073-
else
1078+
else:
10741079
sym_dim = get_glyph_dimensions(self.sourceFont[currentSourceFontGlyph], scaleGlyph, scale_ratio_x, scale_ratio_y)
10751080
y_align_distance = 0
10761081
if sym_attr['valign'] == 'c':

0 commit comments

Comments
 (0)