From 946c1d09ddf0a3d5f71f0ce3edb3da2bf2fceedb Mon Sep 17 00:00:00 2001 From: Fini Jastrow Date: Wed, 21 Dec 2022 18:35:27 +0100 Subject: [PATCH] font-patcher: Preserve symbol advance with variable width font [why] Very slender symbols added to a proportional patch end up being at least one mono-width wide, which mixes proportional and monospaces metrics. [how] When we create a proportional font we should a) not try to align them in a (non existing) monocpace cell b) insert the symbols with their own (advance) width Signed-off-by: Fini Jastrow --- font-patcher | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/font-patcher b/font-patcher index d8ff337f1..c89c14237 100755 --- a/font-patcher +++ b/font-patcher @@ -1085,7 +1085,9 @@ class font_patcher: # Handle glyph l/r/c alignment x_align_distance = 0 - if sym_attr['align']: + if self.args.nonmono: + pass + elif sym_attr['align']: # First find the baseline x-alignment (left alignment amount) x_align_distance = self.font_dim['xmin'] - sym_dim['xmin'] if sym_attr['align'] == 'c': @@ -1117,9 +1119,13 @@ class font_patcher: # It should come after setting the glyph bearings self.set_glyph_width_mono(self.sourceFont[currentSourceFontGlyph]) - # Re-remove negative bearings for target font with variable advance width + # Target font with variable advance width get the icons with their native advance + # or at least width if self.args.nonmono: - self.remove_glyph_neg_bearings(self.sourceFont[currentSourceFontGlyph]) + if sym_dim['advance']: + self.sourceFont[currentSourceFontGlyph].width = int(sym_dim['advance']) + else: + self.sourceFont[currentSourceFontGlyph].width = int(sym_dim['width']) # Check if the inserted glyph is scaled correctly for monospace if self.args.single: