From: Ben Harris Date: Tue, 19 Nov 2024 23:27:05 +0000 (+0000) Subject: Fix left and right edge hints at non-default widths X-Git-Tag: bedstead-3.246~11 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~bjharris/git?a=commitdiff_plain;h=d4d05a4a73169b7ad3d836f334c7381dae33e0b5;p=bedstead-debian.git Fix left and right edge hints at non-default widths The magic numbers -21 and -20 shouldn't be scaled when the width of the characters changes. The easiest way to fix this is to switch to calculating the hints in actual font units. Only now of course that will get bold fonts wrong... --- diff --git a/bedstead.c b/bedstead.c index 12985b3..115c3b3 100644 --- a/bedstead.c +++ b/bedstead.c @@ -3867,9 +3867,10 @@ static void emit_hints(int vstems[XSIZE], int ledges[XSIZE], int redges[XSIZE], int hstems[YSIZE], int tedges[YSIZE], int bedges[YSIZE]) { - int i, start, size, cur; + int i; + double start, size, cur; enum hint_type vhints[XSIZE], hhints[YSIZE]; - bool printed, need_cntrmask; + bool printed, need_cntrmask = false; select_hints(YSIZE, hstems, tedges, bedges, hhints); cur = DESCENT * YPIX; printed = false; @@ -3878,22 +3879,20 @@ emit_hints(int vstems[XSIZE], int ledges[XSIZE], int redges[XSIZE], case hint_counter_stem: need_cntrmask = true; /* FALLTHROUGH */ case hint_stem: - start = i * YPIX_S; - size = YPIX_S; + start = i * YPIX; + size = YPIX; break; case hint_aedge: /* Top edge. */ - start = (i + 1) * YPIX_S; + start = (i + 1) * YPIX; size = -20; break; case hint_zedge: /* Bottom edge. */ - start = i * YPIX_S + 21; + start = i * YPIX + 21; size = -21; break; default: continue; } - printf(" %g %g", - (double)((start - cur) / YSCALE), - (double)(size / YSCALE)); + printf(" %g %g", start - cur, size); cur = start + size; printed = true; } @@ -3907,22 +3906,20 @@ emit_hints(int vstems[XSIZE], int ledges[XSIZE], int redges[XSIZE], case hint_counter_stem: need_cntrmask = true; /* FALLTHROUGH */ case hint_stem: - start = i * XPIX_S - weight->weight; - size = XPIX_S + weight->weight; + start = i * XPIX - weight->weight; + size = XPIX + weight->weight; break; case hint_aedge: /* Left edge. */ - start = i * YPIX_S + 21; + start = i * XPIX + 21; size = -21; break; case hint_zedge: /* Right edge. */ - start = (i + 1) * YPIX_S; + start = (i + 1) * XPIX; size = -20; break; default: continue; } - printf(" %g %g", - (double)((start - cur) / XSCALE), - (double)(size / XSCALE)); + printf(" %g %g", start - cur, size); cur = start + size; printed = true; }