From: Ben Harris Date: Sat, 30 Aug 2025 13:01:56 +0000 (+0100) Subject: Try to generate more-symmetric stem hints X-Git-Tag: bedstead-3.261~108 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~bjharris/git?a=commitdiff_plain;h=912f9e1ff3fb02b1694ba707eadba43ebf5ab827;p=bedstead.git 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. --- 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; } } }