mirror of
https://bjh21.me.uk/bedstead/.git
synced 2026-07-10 05:53:05 -04:00
Counter-mask support in select_hints()
It detects evenly-spaced runs of at least three stems, which is a surprisingly fiddly thing to code.
This commit is contained in:
parent
52c2ad5e93
commit
cf28bd71ef
17
bedstead.c
17
bedstead.c
@ -3810,7 +3810,7 @@ emit_path(void)
|
||||
|
||||
/* An "A" edge is top or left, a "Z" edge is bottom or right. */
|
||||
enum hint_type {
|
||||
hint_none, hint_stem, hint_aedge, hint_zedge
|
||||
hint_none, hint_stem, hint_counter_stem, hint_aedge, hint_zedge
|
||||
};
|
||||
|
||||
static void
|
||||
@ -3837,6 +3837,17 @@ select_hints(int nstems, int stems[nstems],
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Look for evenly spaced stems to attach counter masks to. */
|
||||
for (int step = 2; step < (nstems + 1) / 2; step++)
|
||||
for (int i = 0; i < nstems - 2 * step; i++)
|
||||
if (hints[i] && hints[i+step] && hints[i+step*2]) {
|
||||
for (int j = i; j < nstems; j += step)
|
||||
if (hints[j])
|
||||
hints[j] = hint_counter_stem;
|
||||
else break;
|
||||
goto counters_done;
|
||||
}
|
||||
counters_done:
|
||||
/*
|
||||
* Now look for edge hints, preferring ones closer to the edge
|
||||
* of the character.
|
||||
@ -3850,7 +3861,7 @@ select_hints(int nstems, int stems[nstems],
|
||||
(i == nstems - 1 || hints[i+1] == hint_none))
|
||||
hints[i] = hint_zedge;
|
||||
printf("<!-- HINTS ");
|
||||
for (int i = 0; i < nstems; i++) printf("%c", ".|[]"[hints[i]]);
|
||||
for (int i = 0; i < nstems; i++) printf("%c", ".|I[]"[hints[i]]);
|
||||
printf(" -->");
|
||||
}
|
||||
|
||||
@ -3867,6 +3878,7 @@ emit_hints(int vstems[XSIZE], int ledges[XSIZE], int redges[XSIZE],
|
||||
for (i = 0; i < YSIZE; i++) {
|
||||
switch (hhints[YSIZE - 1 - i]) {
|
||||
case hint_stem:
|
||||
case hint_counter_stem:
|
||||
start = i * YPIX_S;
|
||||
size = YPIX_S;
|
||||
break;
|
||||
@ -3894,6 +3906,7 @@ emit_hints(int vstems[XSIZE], int ledges[XSIZE], int redges[XSIZE],
|
||||
for (i = 0; i < XSIZE; i++) {
|
||||
switch (vhints[i]) {
|
||||
case hint_stem:
|
||||
case hint_counter_stem:
|
||||
start = i * XPIX_S - weight->weight;
|
||||
size = XPIX_S + weight->weight;
|
||||
break;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user