static char *sccsid
= "@(#)vfontinfo.c 4.4 (Berkeley) 5/30/81";
/* Font Information for VCat-style fonts
* Modified to print Ascii chars 1/80 by Mark Horton
* Zoom option added 5/81 by Steve Stone with tables from Mark Horton.
* Message option added 5/31 by Mark Horton
struct header FontHeader
;
struct dispatch disptable
[256] ;
char *charswanted
= defascii
;
int curline
, curcol
; /* cursor, numbered from lower left corner */
int minline
=24, maxline
=0, maxcol
=0;
while (argc
> 1 && argv
[1][0] == '-') {
printf("Bad flag: %s\n", argv
[1]);
fprintf(stderr
,"Usage: %s filename", argv
[0]);
sprintf(IName
,"/usr/lib/vfont/%s",argv
[1]);
if ((FID
= open(argv
[1],0)) < 0)
if ((FID
= open(IName
,0)) < 0) {
printf("Can't find %s\n",argv
[1]);
if (read(FID
,&FontHeader
,sizeof FontHeader
) != sizeof FontHeader
)
error("Bad header in Font file.");
if (read(FID
,&disptable
[0],sizeof disptable
) != sizeof disptable
)
error("Bad dispatch table in Font file");
fbase
= sizeof FontHeader
+ sizeof disptable
;
if (FontHeader
.magic
!= 0436)
printf("Magic number %o wrong\n", FontHeader
.magic
);
printf("Font %s, ",argv
[1]);
printf("raster size %d, ",FontHeader
.size
);
printf("max width %d, max height %d, xtend %d\n",
FontHeader
.maxx
, FontHeader
.maxy
,FontHeader
.xtend
);
printf("\n ASCII offset size left right up down width \n");
if (disptable
[j
].nbytes
!= 0) {
printf(" %3o %2s %4d %4d %4d %4d %4d %4d %5d\n",
if (verbose
|| msgflag
) {
int len
= disptable
[j
].nbytes
;
lseek(FID
, fbase
+disptable
[j
].addr
, 0);
read(FID
, charbits
, len
);
H
= (disptable
[j
].up
) + (disptable
[j
].down
);
W
= (disptable
[j
].left
) + (disptable
[j
].right
);
* Old 1 for 1 code. The aspect ratio
* is awful, so we don't use it.
for (last
=W
-1; last
>= 0; last
--)
printf("%c", fbit(k
,l
)?'M':' ');
else if (zoom
== 2) k
/= 2;
for (i
=maxline
; i
>=minline
; i
--) {
printf("\nvfontinfo: %s\n",string
);
ret
[0] = isprint(c
) ? ' ' : '^';
ret
[1] = isprint(c
) ? c
: c
^0100;
int thisbyte
, thisbit
, ret
;
if (row
<0 || row
>=H
|| col
>=W
) return(0);
thisbyte
= charbits
[row
*WB
+ (col
>>3)] & 0xff;
thisbit
= 0x80 >> (col
&7);
ret
= thisbyte
& thisbit
;
The implementation would work like this:
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
* graphtab: a table for rudimentary graphics on ordinary terminals.
* For each 4x2 bit pattern of the form:
* form the 4 bit quantities abcd and efgh and get table entry
* 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 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'
printf("%s", fbit(k
,l
)?"[]": " ");
i
= fbit(k
,l
)*2 + fbit(k
+1,l
);
int line
= curline
+ (base
+3)/4;
i
= fbit(k
,l
)*8 + fbit(k
+1,l
)*4 +
fbit(k
+2,l
)*2 + fbit(k
+3,l
);
j
= fbit(k
,l
)*8 + fbit(k
+1,l
)*4 +
fbit(k
+2,l
)*2 + fbit(k
+3,l
);
if (graphtab
[i
][j
] != ' ') {
if (line
> maxline
) maxline
= line
;
if (line
< minline
) minline
= line
;
if (col
> maxcol
) maxcol
= col
;
msgout
[line
][col
] = graphtab
[i
][j
];
printf("%c",graphtab
[i
][j
]);