From 0b04391b771b91fd537c5ef05da0e67bc5e87d42 Mon Sep 17 00:00:00 2001 From: Fini Jastrow Date: Wed, 8 Feb 2023 11:27:44 +0100 Subject: [PATCH] font-patcher: Fix center alignment of ScaleGroup [why] When a ScaleGroup's combinded bounding box is wider than the target font cell the actual X position of a glyph in the group depends on it's own bonding box and not of the combinded bounding box. When doing center or right alignment. [how] 'Overwide' ScaleGroup glyphs are correctly placed and shifted in position, but that would mean a negative left side bearing (i.e. glyph extends to the left into previous 'cell'). We do not want that and it is later corrected for all glyphs. But that is done on an individual glyph level and it is just left aligned for its concrete bounding box (i.e. left side bearing is set to zero). The dilemma here is that you can not really center a (combinded) glyph within a cell, when * the cell is smaller than the glyph * a left bearing is not allowd So we change the algorithm here that 'center' and 'right' alignment mean: * Center the glyph in the target font cell * But if that would create a left side 'overhang' (bearing) just left align (move it as far left as possible without creating a negative bearing) The only glyphs affected by this change are the very wide weather icons, and here escpecially the moon phases F096 and following (target codepoints E38E ..). Signed-off-by: Fini Jastrow --- font-patcher | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/font-patcher b/font-patcher index bed81062a..9cb42b768 100755 --- a/font-patcher +++ b/font-patcher @@ -6,7 +6,7 @@ from __future__ import absolute_import, print_function, unicode_literals # Change the script version when you edit this script: -script_version = "3.5.9" +script_version = "3.5.10" version = "2.3.3" projectName = "Nerd Fonts" @@ -1302,14 +1302,13 @@ class font_patcher: x_align_distance += self.font_dim['width'] - sym_dim['width'] if not self.args.single and '2' in sym_attr['stretch']: x_align_distance += self.font_dim['width'] + # If symbol glyph is wider than target font cell, just left-align + x_align_distance = max(-sym_dim['xmin'], x_align_distance) if overlap: overlap_width = self.font_dim['width'] * overlap if sym_attr['align'] == 'l': x_align_distance -= overlap_width - if sym_attr['align'] == 'r' and not self.args.nonmono: - # Nonmono is 'left aligned' per definition, translation does not help here - x_align_distance += overlap_width align_matrix = psMat.translate(x_align_distance, y_align_distance) self.sourceFont[currentSourceFontGlyph].transform(align_matrix)