unibdf2hex: preserve line width
authorMischa POSLAWSKY <perl@shiar.org>
Thu, 16 Jul 2015 06:20:24 +0000 (08:20 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Thu, 16 Jul 2015 08:10:38 +0000 (10:10 +0200)
src/unibdf2hex.c

index bbd4dc1def37ab1848d714d488dfc51b0efb5a4b..17fd83ddc3317a7313e19919f750da472ff660cc 100644 (file)
@@ -42,13 +42,19 @@ main()
 
    int descent=2; /* font descent wrt baseline */
    int startrow;  /* row to start glyph        */
-   int rowlen=4;  /* number of digits per row  */
+   int rowlen;    /* number of digits per row  */
    unsigned rowout;
 
    while (fgets (inbuf, MAXBUF - 1, stdin)) {
       if (strncmp (inbuf, "ENCODING ", 9)) continue;
       sscanf (&inbuf[9], "%d", &thispoint); /* get code point */
 
+      while (fgets (inbuf, MAXBUF - 1, stdin)) {
+         if (!strncmp (inbuf, "DWIDTH ", 7)) break;
+      }
+      sscanf (&inbuf[7], "%d", &rowlen);
+      rowlen >>= 2;
+
       /* Read bounding box values from BBX line */
       while (fgets (inbuf, MAXBUF - 1, stdin)) {
         if (!strncmp (inbuf, "BBX ", 4)) break;
@@ -74,8 +80,7 @@ main()
       while (fgets (inbuf, MAXBUF - 1, stdin)) {
          if (!strncmp (inbuf, "END", 3)) break;
          sscanf (inbuf, "%X", &rowout);
-         /* Now force glyph to a 16x16 grid even if they'd fit in 8x16 */
-         if (bbxx <= 8) rowout <<= 8;  /* shift left for 16x16 glyph */
+         if (rowlen >= 4 && bbxx <= 8) rowout <<= 8;  /* force 8x16 input to 16x16 grid */
          rowout >>= bbxxoff;
          fprintf (stdout, "%0*X", rowlen, rowout);
          rownum++;