chiark / gitweb /
When printfing dimensions, cast them to the right type first.
authorBen Harris <bjh21@bjh21.me.uk>
Fri, 6 Apr 2018 22:07:28 +0000 (23:07 +0100)
committerBen Harris <bjh21@bjh21.me.uk>
Fri, 6 Apr 2018 22:07:28 +0000 (23:07 +0100)
That way, if floating-point numbers turn up, they won't get
interpreted as ints and cause a horrid mess.

bedstead.c

index f9f5b1958cedf317640f1c473a3967e087e1aa5d..1e66284301e55eb5002a45f3cae14e21db2046c4 100644 (file)
@@ -1671,21 +1671,21 @@ main(int argc, char **argv)
        printf("Copyright: Dedicated to the public domain\n");
        printf("Version: 001.003\n");
        printf("ItalicAngle: 0\n");
-       printf("UnderlinePosition: %d\n", -YPIX / 2);
-       printf("UnderlineWidth: %d\n", YPIX);
-       printf("OS2StrikeYPos: %d\n", 3 * YPIX);
-       printf("OS2StrikeYSize: %d\n", YPIX);
-       printf("Ascent: %d\n", 8 * YPIX);
-       printf("Descent: %d\n", 2 * YPIX);
+       printf("UnderlinePosition: %d\n", (int)(-YPIX / 2));
+       printf("UnderlineWidth: %d\n", (int)(YPIX));
+       printf("OS2StrikeYPos: %d\n", (int)(3 * YPIX));
+       printf("OS2StrikeYSize: %d\n", (int)(YPIX));
+       printf("Ascent: %d\n", (int)(8 * YPIX));
+       printf("Descent: %d\n", (int)(2 * YPIX));
        /* Sub/Superscript are three by five pixels */
-       printf("OS2SubXSize: %d\n", YSIZE * YPIX * 3 / (XSIZE - 1));
-       printf("OS2SupXSize: %d\n", YSIZE * YPIX * 3 / (XSIZE - 1));
-       printf("OS2SubYSize: %d\n", YSIZE * YPIX * 5 / (YSIZE - 3));
-       printf("OS2SupYSize: %d\n", YSIZE * YPIX * 5 / (YSIZE - 3));
+       printf("OS2SubXSize: %d\n", (int)(YSIZE * YPIX * 3 / (XSIZE - 1)));
+       printf("OS2SupXSize: %d\n", (int)(YSIZE * YPIX * 3 / (XSIZE - 1)));
+       printf("OS2SubYSize: %d\n", (int)(YSIZE * YPIX * 5 / (YSIZE - 3)));
+       printf("OS2SupYSize: %d\n", (int)(YSIZE * YPIX * 5 / (YSIZE - 3)));
        printf("OS2SubXOff: 0\n");
        printf("OS2SupXOff: 0\n");
-       printf("OS2SubYOff: %d\n", 2 * YPIX);
-       printf("OS2SupYOff: %d\n", 2 * YPIX);
+       printf("OS2SubYOff: %d\n", (int)(2 * YPIX));
+       printf("OS2SupYOff: %d\n", (int)(2 * YPIX));
        printf("FSType: 0\n");
        printf("TTFWeight: %d\n", weight->ttfweight);
        printf("TTFWidth: %d\n", width->ttfwidth);
@@ -1704,12 +1704,15 @@ main(int argc, char **argv)
                printf("StrokeWidth: 50\n");
        }
        printf("BeginPrivate: 5\n");
-       printf(" StdHW 6 [%4d]\n", YPIX);
-       printf(" StdVW 6 [%4d]\n", XPIX * (100 + weight->weight) / 100);
+       printf(" StdHW 6 [%4d]\n", (int)YPIX);
+       printf(" StdVW 6 [%4d]\n", (int)(XPIX * (100 + weight->weight) / 100));
        printf(" BlueValues 35 [0 0 %4d %4d %4d %4d %4d %4d]\n",
-              YPIX * 5, YPIX * 5, YPIX * 6, YPIX * 6, YPIX * 7, YPIX * 7);
+              (int)(YPIX * 5), (int)(YPIX * 5),
+              (int)(YPIX * 6), (int)(YPIX * 6),
+              (int)(YPIX * 7), (int)(YPIX * 7));
        printf(" OtherBlues 21 [%4d %4d %4d %4d]\n",
-              YPIX * -2, YPIX * -2, YPIX * 1, YPIX * 1);
+              (int)(YPIX * -2), (int)(YPIX * -2),
+              (int)(YPIX * 1), (int)(YPIX * 1));
        printf(" BlueFuzz 1 0\n"); 
        printf("EndPrivate\n");
        /* Force monochrome at 10 and 20 pixels, and greyscale elsewhere. */
@@ -1742,7 +1745,7 @@ main(int argc, char **argv)
                printf("Encoding: %d %d %d\n",
                    glyphs[i].unicode != -1 ? glyphs[i].unicode :
                    65536 + extraglyphs++, glyphs[i].unicode, i);
-               printf("Width: %d\n", XSIZE * XPIX);
+               printf("Width: %d\n", (int)(XSIZE * XPIX));
                printf("Flags: HW\n");
                printf("LayerCount: 2\n");
                dolookups(&glyphs[i]);
@@ -1902,7 +1905,7 @@ dopalt(struct glyph const *g)
        }
        if (dx || dh)
                printf("Position2: \"palt\" dx=%d dy=0 dh=%d dv=0\n",
-                   dx * XPIX, dh * XPIX);
+                      (int)(dx * XPIX), (int)(dh * XPIX));
 }