mirror of
https://bjh21.me.uk/bedstead/.git
synced 2026-07-10 05:53:05 -04:00
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.
This commit is contained in:
parent
1459c8cf93
commit
30d226f30f
16
bedstead.c
16
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;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user