From: Ben Harris Date: Sun, 17 Nov 2024 13:43:08 +0000 (+0000) Subject: Support for edge hints in select_hints() X-Git-Tag: bedstead-3.246~22 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~bjharris/git?a=commitdiff_plain;h=347dcfd5791b2b541440f50fd813c58a775959cd;p=bedstead.git Support for edge hints in select_hints() Which demonstrated plenty of bugs in the code generating them. Currently edge hints only appear in a helpful comment. --- diff --git a/bedstead.c b/bedstead.c index b07d267..459ec2c 100644 --- a/bedstead.c +++ b/bedstead.c @@ -3837,6 +3837,21 @@ select_hints(int nstems, int stems[nstems], } } } + /* + * Now look for edge hints, preferring ones closer to the edge + * of the character. + */ + for (int i = 0; i < nstems - 1; i++) + if (aedges[i] > 0 && hints[i] == hint_none && + (i == 0 || hints[i-1] == hint_none)) + hints[i] = hint_aedge; + for (int i = nstems - 1; i >= 1; i--) + if (zedges[i] > 0 && hints[i] == hint_none && + (i == nstems - 1 || hints[i+1] == hint_none)) + hints[i] = hint_zedge; + printf(""); } static void @@ -4035,8 +4050,8 @@ dochar(struct glyph *g) #define DL GETPIX(x-1, y+1) #define DR GETPIX(x+1, y+1) - for (x = 0; x < XSIZE; x++) vstems[x] = 0; - for (y = 0; y < YSIZE; y++) hstems[y] = 0; + for (x = 0; x < XSIZE; x++) vstems[x] = ledges[x] = redges[x] = 0; + for (y = 0; y < YSIZE; y++) hstems[y] = tedges[y] = bedges[y] = 0; clearpath(); for (y = 0; y < YSIZE; y++) { for (x = 0; x < XSIZE; x++) { @@ -4058,16 +4073,14 @@ dochar(struct glyph *g) blackpixel(x, YSIZE - y - 1, bl, br, tr, tl); if (!L && !R && (U || D)) vstems[x]++; - else if (!U && !D && (L || R)) + if (!U && !D && (L || R)) hstems[y]++; - else if (UL + U + UR + L + R + DL + D + DR == 0) + if (UL + U + UR + L + R + DL + D + DR == 0) vstems[x]++, hstems[y]++; - else { /* Not a stem. Maybe an edge? */ - if (UL + U + UR == 0) tedges[y]++; - if (DL + D + DR == 0) bedges[y]++; - if (UL + L + DL == 0) ledges[x]++; - if (UR + R + DR == 0) redges[x]++; - } + if (UL + U + UR == 0) tedges[y]++; + if (DL + D + DR == 0) bedges[y]++; + if (UL + L + DL == 0) ledges[x]++; + if (UR + R + DR == 0) redges[x]++; } else { bool tl, tr, bl, br;