From 912f9e1ff3fb02b1694ba707eadba43ebf5ab827 Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Sat, 30 Aug 2025 14:01:56 +0100 Subject: [PATCH] Try to generate more-symmetric stem hints When generating hints for a symmetric glyph like 'v', it's helpful if the hits are symmetric because that means that the hinted bitmap is also likely to be symmetric. This is particularly visible on Microsoft Windows where the version of 'v' before this patch ended up horribly distorted when rendered at 20 ppem in Bedstead Condensed. To try to avoid such horrors, we now select hints starting at the outside edges of the character and working inwards, instead of going from left to right or top to bottom. This means that where hints conflict, we'll tend to choose the ones towards the outside edge of the character, rather than towards the top or left. This changes the hinting for 50 glyphs, but all in ways that look superficially reasonable. For more complicated characters we probably still want to think about hint substitution, but that still scares me. --- bedstead.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/bedstead.c b/bedstead.c index 35e3b40..952825e 100644 --- a/bedstead.c +++ b/bedstead.c @@ -4389,12 +4389,14 @@ select_hints(int nstems, int stems[nstems], for (;most > 0; most--) { /* Prefer long stems. */ for (int i = 0; i < nstems; i++) { - if (stems[i] == most) { - hints[i] = hint_stem; - stems[i] = 0; + /* Prefer outer stems. */ + int ii = i % 2 ? nstems - 1 - i / 2 : i / 2; + if (stems[ii] == most) { + hints[ii] = hint_stem; + stems[ii] = 0; /* Disallow overlapping stems. */ - if (i >= 1) stems[i-1] = 0; - if (i < nstems - 1) stems [i+1] = 0; + if (ii >= 1) stems[ii-1] = 0; + if (ii < nstems - 1) stems [ii+1] = 0; } } } -- 2.30.2