added -z option from Steve Stone
authorMark Horton <mark@ucbvax.Berkeley.EDU>
Sat, 30 May 1981 16:14:07 +0000 (08:14 -0800)
committerMark Horton <mark@ucbvax.Berkeley.EDU>
Sat, 30 May 1981 16:14:07 +0000 (08:14 -0800)
SCCS-vsn: old/vpr/vtools/vfontinfo.c 4.3

usr/src/old/vpr/vtools/vfontinfo.c

index b562b4d..08a99fb 100644 (file)
@@ -1,10 +1,9 @@
-static char *sccsid = "@(#)vfontinfo.c 4.2 (Berkeley) 81/02/28";
+static char *sccsid = "@(#)vfontinfo.c 4.1 (Berkeley) 10/1/80";
 /* Font Information for VCat-style fonts
 /* Font Information for VCat-style fonts
- *      AJH  4/79
+ *      Andy Hertzfeld  4/79
  *
  *     Modified to print Ascii chars 1/80 by Mark Horton
  *
  *     Modified to print Ascii chars 1/80 by Mark Horton
- *     Modified to use ,'| 1/81 by Mark Horton using an idea
- *             from Eric Scott of CalTech.
+ *     Zoom option added 5/81 by Steve Stone with tables from Mark Horton.
  */
 #include <stdio.h>
 #include <ctype.h>
  */
 #include <stdio.h>
 #include <ctype.h>
@@ -22,6 +21,7 @@ char  *charswanted = defascii;
 int    verbose;
 char   charbits[4000];
 int    H, W, WB;
 int    verbose;
 char   charbits[4000];
 int    H, W, WB;
+int    zoom = -1;
 
 main(argc,argv)
 int argc;
 
 main(argc,argv)
 int argc;
@@ -30,11 +30,14 @@ char **argv;
 {
        int FID,i,j;
 
 {
        int FID,i,j;
 
-       if (argc > 1 && argv[1][0] == '-') {
+       while (argc > 1 && argv[1][0] == '-') {
                switch(argv[1][1]) {
                case 'v':
                        verbose++;
                        break;
                switch(argv[1][1]) {
                case 'v':
                        verbose++;
                        break;
+               case 'z':
+                       zoom = argv[1][2] - '0';
+                       break;
                default:
                        printf("Bad flag: %s\n", argv[1]);
                }
                default:
                        printf("Bad flag: %s\n", argv[1]);
                }
@@ -71,17 +74,14 @@ char **argv;
        printf("raster size %d, ",FontHeader.size);
        printf("max width %d, max height %d, xtend %d\n",
                FontHeader.maxx, FontHeader.maxy,FontHeader.xtend);
        printf("raster size %d, ",FontHeader.size);
        printf("max width %d, max height %d, xtend %d\n",
                FontHeader.maxx, FontHeader.maxy,FontHeader.xtend);
-       if (!verbose)
-               printf("\n ASCII     offset    size  left    right   up     down    width \n");
+       printf("\n ASCII     offset    size  left    right   up     down    width \n");
 
        for (i=0; i<256; i++) {
                j = charswanted[i];
                if (i>0 && j==0)
                        break;
                if (disptable[j].nbytes != 0) {
 
        for (i=0; i<256; i++) {
                j = charswanted[i];
                if (i>0 && j==0)
                        break;
                if (disptable[j].nbytes != 0) {
-                       printf(!verbose ?
-                               "  %3o %2s     %4d   %4d   %4d   %4d   %4d   %4d   %5d\n" :
-                               "  %3o %2s  a=%d, n=%d, l=%d, r=%d, u=%d, d=%d, w=%d\n",
+                       printf("  %3o %2s     %4d   %4d   %4d   %4d   %4d   %4d   %5d\n",
                                j, rdchar(j),
                                disptable[j].addr,
                                disptable[j].nbytes,
                                j, rdchar(j),
                                disptable[j].addr,
                                disptable[j].nbytes,
@@ -99,19 +99,22 @@ char **argv;
                                H = (disptable[j].up) + (disptable[j].down);
                                W = (disptable[j].left) + (disptable[j].right);
                                WB = (W+7)/8;
                                H = (disptable[j].up) + (disptable[j].down);
                                W = (disptable[j].left) + (disptable[j].right);
                                WB = (W+7)/8;
-                               for (k=0; k<H; k+=2) {
-                                       for (last=W-1; last >= 0; last--)
-                                               if (fbit(k, last))
-                                                       break;
-                                       for (l=0; l<=last; l++) {
-                                               printf("%c", " ',|"[fbit(k,l)+2*fbit(k+1,l)]);
+                               if (zoom < 0) {
+                                       for (k=0; k<H; k++) {
+                                               for (last=W-1; last >= 0; last--)
+                                                       if (fbit(k, last))
+                                                               break;
+                                               for (l=0; l<=W-1; l++) {
+                                                       printf("%c", fbit(k,l)?'M':' ');
+                                               }
+                                               printf("\n");
                                        }
                                        printf("\n");
                                        }
                                        printf("\n");
-                               }
-                               printf("\n");
+                               } else
+                                       shozoom();
                        }
                }
                        }
                }
-       };
+       }
 }
 
 error(string)
 }
 
 error(string)
@@ -138,10 +141,137 @@ int row, col;
 {
        int thisbyte, thisbit, ret;
 
 {
        int thisbyte, thisbit, ret;
 
-       if (row >= H)
-               return 0;
+       if (row>=H || col>=W) return(0);
        thisbyte = charbits[row*WB + (col>>3)] & 0xff;
        thisbit = 0x80 >> (col&7);
        ret = thisbyte & thisbit;
        return (ret != 0);
 }
        thisbyte = charbits[row*WB + (col>>3)] & 0xff;
        thisbit = 0x80 >> (col&7);
        ret = thisbyte & thisbit;
        return (ret != 0);
 }
+
+
+/*
+The implementation would work like this:
+       zoom level      method
+       0               2 chars/pixel, 1 is "[]", 0 is "  ".
+       1               2 pixels/char 2x1, using " " "," "'" "|"
+       2               8 pixels/char 4x2, using 16x16 table
+       3               32 pixels/char 8x4, mapped into (2)
+       4 and up        similar, mapped into (2)
+
+The 16x16 table maps a 4x2 pattern into a printing ascii character which
+most closely approximates that pattern, e.g. the pattern
+       |'
+       ''
+would be represented by the character "[".  I have such a table worked out.
+
+Grainer zoom levels would take the rule of reducing it into a smaller bitmap,
+or-ing the bits together.  (e.g. level 3 would take a 2x2 chunk and map it
+into a single pixel: 0 if all 4 are 0, 1 otherwise.)  These pixels would be
+displayed as in 2.
+*/
+
+/*
+ * graphtab: a table for rudimentary graphics on ordinary terminals.
+ * For each 4x2 bit pattern of the form:
+ *     ae
+ *     bf
+ *     cg
+ *     dh
+ * form the 4 bit quantities abcd and efgh and get table entry
+ *     graphtab[abcd][efgh]
+ * to display in that character position.
+ *
+ * General philosophies: the dh bits are intended for descenders where
+ * possible.  Characters with radically different appearance on different
+ * terminals (e.g. _ and ^) are avoided.
+ *
+ * Version 1.0, March 1981, Mark Horton.
+ */
+
+char tab1[4] = {
+       ' ', ',', '\'', '|'
+};
+
+char graphtab[16][16] = {
+' ', '.', '.', ',', '.', ';', ':', 'j', '\'', ':', ':', ';', '\'', ';', '!', '|',
+'.', '.', ':', ',', ';', ';', ';', 'j', '/', ';', ';', ';', 'j', 'j', 'j', 'j',
+'.', ',', '~', ',', 'r', '<', 'j', 'q', '/', ';', 'I', ';', '/', '|', 'I', '|',
+',', ',', 'r', 'x', '/', '/', '/', 'd', '/', '/', '/', 'd', '/', '/', '/', 'd',
+'.', ':', '\\', ';', '-', '=', 'v', 'q', '\'', ':', '<', '|', '\'', ':', '+', '+',
+';', ';', '>', ';', '=', '=', 'g', 'g', '\'', ':', 'S', 'S', '/', '/', '/', '+',
+':', '\\', '\\', '\\', 'r', '<', 'w', 'q', '/', '<', '6', '4', '/', '/', 'd', '+',
+'l', 'L', '+', 'b', 'y', '[', 'p', 'g', '/', '<', '/', '6', '/', '/', '/', '+',
+'`', ':', ':', ';', '`', '\\', '\\', '\\', '"', ':', ':', ';', '`', '\\', 'Y', 'T',
+';', ';', ';', ';', '`', '2', '>', '\\', ':', '=', ';', ';', '?', '?', ']', ']',
+':', ';', ';', ';', '>', '2', '>', '\\', 'F', ';', 'O', ';', '7', '?', ']', '7',
+';', ';', ';', ';', '?', '2', '>', 'b', ';', ';', ';', ';', '?', '?', ']', '#',
+'\'', '\\', '\\', '\\', '`', '\\', '\\', '\\', '\'', '\'', '<', '5', '"', '"', 'v', 'q',
+';', '\\', '\\', '\\', '`', '=', '\\', '\\', '\'', '\'', '5', '5', '"', '?', 'g', 'g',
+'I', 'L', 'L', 'L', 'D', '\\', 'b', 'f', 'F', '[', '[', '[', 'P', '?', '#', 'M',
+'|', '|', '|', '|', '|', '#', '+', '#', 'T', '[', 'F', 'F', 'P', '?', 'P', 'M'
+};
+
+
+shozoom()
+{
+       register i;
+
+       if (zoom == 0) 
+               sho0();
+       else if (zoom == 1)
+               sho1();
+       else if (zoom == 2)
+               sho2();
+}
+
+sho0()
+{
+       register k,l;
+
+       for (k=0; k<H; k++) {
+               for (l=0; l<W; l++)
+                       printf("%s", fbit(k,l)?"[]": "  ");
+               printf("\n");
+       }
+       printf("\n");
+}
+
+sho1()
+{
+       register i,k,l;
+
+       k = 0;
+       while (k < H) {
+               for(l=0;l<W;l++) {
+                       i = fbit(k,l)*2 + fbit(k+1,l);
+                       printf("%c",tab1[i]);
+                       l++;
+               }
+               printf("\n");
+               k += 2;
+       }
+       printf("\n");
+}
+
+sho2()
+{
+       register i,j,k,l;
+
+       k = 0;
+       while (k < H) {
+               l = 0;
+               while (l<W) {
+                       i = fbit(k,l)*8 + fbit(k+1,l)*4 + 
+                           fbit(k+2,l)*2 + fbit(k+3,l);
+                       l++;
+                       j = fbit(k,l)*8 + fbit(k+1,l)*4 + 
+                           fbit(k+2,l)*2 + fbit(k+3,l);
+
+                       printf("%c",graphtab[i][j]);
+                       l++;
+               }
+               printf("\n");
+               k += 4;
+       }
+       printf("\n");
+}