1 /* outpsfheader - auxiliary fn - not to be installed */
2 /* assumes a little-endian machine */
6 #include <stdlib.h> /* exit */
10 static void __attribute__((noreturn))
13 fprintf(stderr, "call: outpsfheader psftype fontsize charsize hastable\n");
17 int main(int argc, char **argv)
19 int psftype, fontsize, charsize, hastable;
23 psftype = atoi(argv[1]);
24 fontsize = atoi(argv[2]);
25 charsize = atoi(argv[3]);
26 hastable = atoi(argv[4]);
29 struct psf1_header h1;
31 if (fontsize != 256 && fontsize != 512)
33 h1.magic[0] = PSF1_MAGIC0;
34 h1.magic[1] = PSF1_MAGIC1;
35 h1.mode = (fontsize == 256) ? 0 : PSF1_MODE512;
37 h1.mode |= PSF1_MODEHASTAB;
38 h1.charsize = charsize;
39 if (fwrite(&h1, sizeof(h1), 1, stdout) != 1) {
40 fprintf(stderr, "write error\n");
43 } else if (psftype == 2) {
44 struct psf2_header h2;
46 h2.magic[0] = PSF2_MAGIC0;
47 h2.magic[1] = PSF2_MAGIC1;
48 h2.magic[2] = PSF2_MAGIC2;
49 h2.magic[3] = PSF2_MAGIC3;
51 h2.headersize = sizeof(h2);
52 h2.flags = (hastable ? PSF2_HAS_UNICODE_TABLE : 0);
54 h2.charsize = charsize;
57 if (fwrite(&h2, sizeof(h2), 1, stdout) != 1) {
58 fprintf(stderr, "write error\n");