From 3cfe4a1a06928314882b8b6ff2b71c1bf17aa352 Mon Sep 17 00:00:00 2001 From: Fini Jastrow Date: Tue, 3 Jan 2023 09:58:10 +0100 Subject: [PATCH] font-patcher: Fix monospaced glyph collection detection [why] When only one symbol glyph is examined we conclude that it comes from a monospaced glyph set. This might be correct or not, but when we can not positively say it is monospaced we should not handle it as monospaced. [how] We require at least TWO glyphs with the same width (and no glyph with a different width) until we set the 'advance' bounding box property. Which says that this particular glyph subset is monospaced. Signed-off-by: Fini Jastrow --- font-patcher | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/font-patcher b/font-patcher index 0d49b9c44..bcadff598 100755 --- a/font-patcher +++ b/font-patcher @@ -1316,11 +1316,14 @@ def get_multiglyph_boundingBox(glyphs, destGlyph = None): bbox[2] = gbb[2] if bbox[2] is None or bbox[2] < gbb[2] else bbox[2] bbox[3] = gbb[3] if bbox[3] is None or bbox[3] < gbb[3] else bbox[3] if not bbox[4]: - bbox[4] = gadvance + bbox[4] = -gadvance # Negative for one/first glyph else: - if bbox[4] != gadvance: + if abs(bbox[4]) != gadvance: bbox[4] = -1 # Marker for not-monospaced + else: + bbox[4] = gadvance # Positive for 2 or more glyphs if bbox[4] and bbox[4] < 0: + # Not monospaced when only one glyph is used or multiple glyphs with different advance widths bbox[4] = None return { 'xmin' : bbox[0],