mirror of
https://bjh21.me.uk/bedstead/.git
synced 2026-08-09 01:40:28 -04:00
Re-work weight-adjustment code to work in two passes
It now records how it wants to move each point and them actually moves the points in a second pass. This avoids a problem where moving one point would cause the loop not to correctly recognise the types of adjacent points in the path. This in particular affected glyphs with sharp upper corners (like &) with weights >= 50.
This commit is contained in:
parent
77cb8d9d8f
commit
726fa5a495
19
bedstead.c
19
bedstead.c
@ -2750,27 +2750,36 @@ adjust_weight()
|
||||
{
|
||||
int i;
|
||||
point *p;
|
||||
struct vec moves[MAXPOINTS];
|
||||
|
||||
for (i = 0; i < nextpoint; i++) {
|
||||
p = &points[i];
|
||||
if (p->next == NULL) continue;
|
||||
assert(p->prev != NULL);
|
||||
moves[i].x = moves[i].y = 0;
|
||||
/* Move left-edge points horizontally */
|
||||
if (p->prev->v.y <= p->v.y && p->v.y <= p->next->v.y)
|
||||
p->v.x -= weight->weight;
|
||||
moves[i].x -= weight->weight;
|
||||
/* Move top inner corner points along NE/SW diagonal */
|
||||
if (p->prev->v.y < p->v.y && p->v.y > p->next->v.y &&
|
||||
p->prev->v.x > p->v.x && p->v.x > p->next->v.x) {
|
||||
p->v.x -= weight->weight/2;
|
||||
p->v.y -= weight->weight/2;
|
||||
moves[i].x -= weight->weight/2;
|
||||
moves[i].y -= weight->weight/2;
|
||||
}
|
||||
/* Move bottom inner corner points along NW/SE diagonal */
|
||||
if (p->prev->v.y > p->v.y && p->v.y < p->next->v.y &&
|
||||
p->prev->v.x < p->v.x && p->v.x < p->next->v.x) {
|
||||
p->v.x -= weight->weight/2;
|
||||
p->v.y += weight->weight/2;
|
||||
moves[i].x -= weight->weight/2;
|
||||
moves[i].y += weight->weight/2;
|
||||
}
|
||||
}
|
||||
for (i = 0; i < nextpoint; i++) {
|
||||
p = &points[i];
|
||||
if (p->next == NULL) continue;
|
||||
assert(p->prev != NULL);
|
||||
p->v.x += moves[i].x;
|
||||
p->v.y += moves[i].y;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user