static char sccsid
[] = "@(#)fcvt.c 4.1 (Berkeley) %G%";
* Convert from the SAIL font format to the Unix font format.
* Usage: fcvt sailfile unixfile
int sws
; /* sail word size in 36 bit words */
struct dispatch disptable
[256];
077, 0177, 0377, 0777, 01777, 03777,
07777, 017777, 037777, 077777, 0177777,0377777,0777777
int infd
= open(argv
[1], 0);
int outfd
= creat(argv
[2], 0666);
int base
, nb
, ncol
, nleft
, r
, i
;
/* Sail counters and things */
int height
, maxwidth
, baseline
;
int charwidth
, rastwidth
, charcode
, wordcount
;
int leftkern
, rowsfromtop
, datarowcount
;
/* Unix counters and things */
int packed
; /* true if sail packed format for this glyph */
if (infd
< 0 || outfd
< 0) {
printf("Usage: fcvt sailfile unixfile\n");
n
= read(infd
, b
, sizeof b
);
printf("Font larger than %d bytes - recompile me\n", n
);
/* size gets done later */
/* I don't know what xtnd would map to */
lseek(outfd
, (long) sizeof vheader
+ sizeof disptable
, 0);
rastwidth
= (left(base
) >> 9) & 0777;
charcode
= left(base
) & 0777;
printf("bad char code %o(%c) != %o(%c)\n", charcode
, charcode
, c
, c
);
if (base
+wordcount
> sws
) {
printf("Bad range %o-%o > %o glyph %o\n", base
, base
+wordcount
, sws
, c
);
leftkern
= (left(base
+1) >> 9) & 0777;
rowsfromtop
= left(base
+1) & 0777;
datarowcount
= right(base
+1);
rastcols
= (rastwidth
+ 35) / 36 * 36;
/* Unix disptable stuff */
disptable
[c
].addr
= curaddr
;
nb
= rastrows
* ((rastcols
+ 7) >> 3);
disptable
[c
].nbytes
= nb
;
disptable
[c
].left
= leftkern
;
disptable
[c
].right
= rastcols
- leftkern
;
disptable
[c
].up
= baseline
- rowsfromtop
;
disptable
[c
].down
= rastrows
- disptable
[c
].up
;
disptable
[c
].width
= charwidth
;
packed
= (datarowcount
> wordcount
);
nperword
= 36 / rastwidth
;
/* Now get the raster rows themselves */
nleft
= ((rastwidth
-1) % 36 + 1);
for (r
=0; r
<rastrows
; r
++) {
lh
= left(base
); rh
= right(base
++);
/* compensate for garbage in SAIL fonts */
lh
&= ~rightbits
[18-nleft
];
rh
&= ~rightbits
[36-nleft
];
u
[p
-1] |= (lh
>>14) & 017;
u
[p
++] = ((lh
&077)<<2) | ((rh
>>16)&03);
u
[p
++] = ((lh
&03)<<6) | (rh
>>12);
u
[p
++] = (rh
& 017) << 4;
put(r
% nperword
, rastwidth
, left(base
+r
/nperword
), right(base
+r
/nperword
), u
+p
);
p
+= 5; /* 5 8 bit bytes per 36 bit word */
write(outfd
, &vheader
, sizeof vheader
);
write(outfd
, disptable
, sizeof disptable
);
* put a pdp-10 style variable size byte into 8 bit Unix bytes starting
* at location dest. The byte is bytesize bits, and is the bytenumth byte
* in the 36 bit word (lh,,rh).
put(bytenum
, bytesize
, lh
, rh
, dest
)
for (i
=0; i
<bytenum
; i
++) {
lh
|= (rh
>> 18-bytesize
) & rightbits
[bytesize
];
lh
&= ~rightbits
[18-bytesize
];
/* We now have the byte we want left justified in lh */
/* lh is now the byte we want, left justified in 32 bit word */
for (i
=0; i
<bytesize
; i
+= 8) {
*dest
++ = (lh
>> 24) & 0377;
* Return the left half (18 bits) of pdp-10 word p.
retval
= (b
[lp
++] & 0017) << 14;
retval
|= (b
[lp
++] & 0377) << 6;
retval
|= (b
[lp
] >> 2) & 63;
retval
= (b
[lp
++] & 0377) << 10;
retval
|= (b
[lp
++] & 0377) << 2;
retval
|= (b
[lp
] >> 6) & 3;
* Return the right half of 36 bit word #p.
retval
= (b
[lp
++] & 0003) << 16;
retval
|= (b
[lp
++] & 0377) << 8;
retval
|= (b
[lp
] & 0377);
retval
= (b
[lp
++] & 0077) << 12;
retval
|= (b
[lp
++] & 0377) << 4;
retval
|= (b
[lp
] >> 4) & 017;