From: Ben Harris Date: Sat, 16 Nov 2024 18:58:41 +0000 (+0000) Subject: Separate selecting usable hints from emitting them X-Git-Tag: bedstead-3.246~27 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~bjharris/git?a=commitdiff_plain;h=30d226f30ffff00aac58aaa44101239a0535474e;p=bedstead-debian.git Separate selecting usable hints from emitting them Now there's a select_hints() function that decides what hints should be emitted, and emit_hints() just handles putting those hints into a charstring. I hope this will make each function reasonably simple. Importantly, it means that select_hints() can be called twice, once for horizontal stems and once for vertical ones. --- diff --git a/bedstead.c b/bedstead.c index cc2a0f0..e120c75 100644 --- a/bedstead.c +++ b/bedstead.c @@ -3808,12 +3808,25 @@ emit_path(void) printf(" endchar"); } +static void +select_hints(int nstems, int stems[nstems]) +{ + + for (int i = 0; i < nstems; i++) { + if (stems[i] > 0) { + stems[i] = 1; + if (i + 1 < nstems) stems[i + 1] = 0; + } + } +} + static void emit_hints(int vstems[XSIZE], int hstems[YSIZE]) { int i, start, size, cur; bool printed; + select_hints(YSIZE, hstems); cur = DESCENT * YPIX; printed = false; size = YPIX_S; for (i = YSIZE - 1; i >= 0; i--) { @@ -3823,12 +3836,12 @@ emit_hints(int vstems[XSIZE], int hstems[YSIZE]) (double)((start - cur) / YSCALE), (double)(size / YSCALE)); cur = start + size; - i--; /* Avoid overlapping stems. */ printed = true; } } if (printed) printf(" hstem"); + select_hints(XSIZE, vstems); cur = 0; printed = false; size = XPIX_S + weight->weight; for (i = 0; i < XSIZE; i++) { @@ -3838,7 +3851,6 @@ emit_hints(int vstems[XSIZE], int hstems[YSIZE]) (double)((start - cur) / XSCALE), (double)(size / XSCALE)); cur = start + size; - i++; /* Avoid overlapping stems. */ printed = true; } }