chiark / gitweb /
Fix left and right edge hints at non-default widths
authorBen Harris <bjh21@bjh21.me.uk>
Tue, 19 Nov 2024 23:27:05 +0000 (23:27 +0000)
committerBen Harris <bjh21@bjh21.me.uk>
Tue, 19 Nov 2024 23:40:00 +0000 (23:40 +0000)
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...

bedstead.c

index 12985b3c5fe87b371e9c67cf20fb7706c3cac063..115c3b381c631be67f051013d66e685ad2da206c 100644 (file)
@@ -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;
        }