diff --git a/font-patcher b/font-patcher index d33ae5f1f..ab3ae588e 100755 --- a/font-patcher +++ b/font-patcher @@ -1107,6 +1107,8 @@ class font_patcher: # Prepare symbol glyph dimensions sym_dim = get_glyph_dimensions(self.sourceFont[currentSourceFontGlyph]) if glyph_scale_data is not None: + if glyph_scale_data[1] is not None: + sym_dim = glyph_scale_data[1] # Use combined bounding box # This is roughly alike get_scale_factors(glyph_scale_data[1], 'pa') # Except we do not have glyph_scale_data[1] always... (scale_ratio_x, scale_ratio_y) = (glyph_scale_data[0], glyph_scale_data[0]) @@ -1114,23 +1116,18 @@ class font_patcher: (scale_ratio_x, scale_ratio_y) = self.get_scale_factors(sym_dim, sym_attr['stretch']) overlap = sym_attr['params'].get('overlap') + if overlap: + scale_ratio_x *= 1.0 + (self.font_dim['width'] / (sym_dim['width'] * scale_ratio_x)) * overlap + scale_ratio_y *= 1.0 + (self.font_dim['width'] / (sym_dim['width'] * scale_ratio_y)) * overlap + + # Size in x to size in y ratio limit (to prevent over-wide glyphs) + xy_ratio_max = sym_attr['params'].get('xy-ratio') + if (xy_ratio_max): + xy_ratio = sym_dim['width'] * scale_ratio_x / (sym_dim['height'] * scale_ratio_y) + if xy_ratio > xy_ratio_max: + scale_ratio_x = scale_ratio_x * xy_ratio_max / xy_ratio if scale_ratio_x != 1.0 or scale_ratio_y != 1.0: - if glyph_scale_data is not None and glyph_scale_data[1] is not None: - dim = glyph_scale_data[1] - else: - dim = sym_dim - if overlap: - scale_ratio_x *= 1.0 + (self.font_dim['width'] / (dim['width'] * scale_ratio_x)) * overlap - scale_ratio_y *= 1.0 + (self.font_dim['width'] / (dim['width'] * scale_ratio_y)) * overlap - - # Size in x to size in y ratio limit (to prevent over-wide glyphs) - xy_ratio_max = sym_attr['params'].get('xy-ratio') - if (xy_ratio_max): - xy_ratio = dim['width'] * scale_ratio_x / (dim['height'] * scale_ratio_y) - if xy_ratio > xy_ratio_max: - scale_ratio_x = scale_ratio_x * xy_ratio_max / xy_ratio - self.sourceFont[currentSourceFontGlyph].transform(psMat.scale(scale_ratio_x, scale_ratio_y)) # We pasted and scaled now we want to align/move