1 /* outpsfheader - auxiliary fn - not to be installed */
2 /* assumes a little-endian machine */
4 #include <stdlib.h> /* exit */
8 static void __attribute__ ((noreturn))
10 fprintf(stderr, "call: outpsfheader psftype fontsize charsize hastable\n");
15 main(int argc, char **argv){
16 int psftype, fontsize, charsize, hastable;
20 psftype = atoi(argv[1]);
21 fontsize = atoi(argv[2]);
22 charsize = atoi(argv[3]);
23 hastable = atoi(argv[4]);
26 struct psf1_header h1;
28 if (fontsize != 256 && fontsize != 512)
30 h1.magic[0] = PSF1_MAGIC0;
31 h1.magic[1] = PSF1_MAGIC1;
32 h1.mode = (fontsize == 256) ? 0 : PSF1_MODE512;
34 h1.mode |= PSF1_MODEHASTAB;
35 h1.charsize = charsize;
36 if (fwrite(&h1, sizeof(h1), 1, stdout) != 1) {
37 fprintf(stderr, "write error\n");
40 } else if (psftype == 2) {
41 struct psf2_header h2;
43 h2.magic[0] = PSF2_MAGIC0;
44 h2.magic[1] = PSF2_MAGIC1;
45 h2.magic[2] = PSF2_MAGIC2;
46 h2.magic[3] = PSF2_MAGIC3;
48 h2.headersize = sizeof(h2);
49 h2.flags = (hastable ? PSF2_HAS_UNICODE_TABLE : 0);
51 h2.charsize = charsize;
54 if (fwrite(&h2, sizeof(h2), 1, stdout) != 1) {
55 fprintf(stderr, "write error\n");