#include #include // image of sam characters taken from xpm file unsigned char samfont[24][256] = { "............+......+.+.....+.+.....+++....++..+....+........++........+...+.........+.........................................+....+++......+......+++.....+++.......+....+++++.....++....+++++....+++.....+++........................+...........+........+++..", "............+......+.+.....+.+....+.+.....++..+...+.+........+.......+.....+......+.+.+.....+.................................+...+...+....++.....+...+...+...+.....++....+........+..........+...+...+...+...+......................+.............+......+...+.", "............+.............+++++...+.+........+....+.+.......+.......+.......+......+++......+................................+....+..++.....+.........+.......+....+.+....++++....+..........+....+...+...+...+.....++......++......+.....+++++.....+.........+.", "............+..............+.+.....+++......+......+................+.......+.....+++++...+++++...........+++++.............+.....+.+.+.....+........+......++....+..+........+...++++......+......+++.....++++.....++......++.....+.................+.......+..", "............+.............+++++.....+.+....+......+.+.+.............+.......+......+++......+.......++.....................+......++..+.....+.......+.........+...+++++.......+...+...+....+......+...+.......+.....................+.....+++++.....+.......+...", "...........................+.+......+.+...+..++...+..+...............+.....+......+.+.+.....+.......++..............++....+.......+...+.....+......+......+...+......+....+...+...+...+...+.......+...+......+......++......++.......+.............+............", "............+..............+.+.....+++....+..++....++.+...............+...+.........+................+..............++....+........+++.....+++....+++++....+++.......+.....+++.....+++....+........+++.....++.......++.......+........+...........+.........+...", "....................................................................................................+.......................................................................................................................+...................................", "...+++.....+++....++++.....+++....++++....+++++...+++++....+++....+...+....+++........+...+...+...+.......+...+...+...+....+++....++++.....+++....++++.....+++....+++++...+...+...+...+...+...+...+...+...+...+...+++++.....+++...+.......+++.......+...........", "..+...+...+...+...+...+...+...+...+...+...+.......+.......+...+...+...+.....+.........+...+..+....+.......++.++...+...+...+...+...+...+...+...+...+...+...+...+.....+.....+...+...+...+...+...+...+...+...+...+.......+.....+.....+.........+......+++..........", "..+..++...+...+...+...+...+.......+...+...+.......+.......+.......+...+.....+.........+...+.+.....+.......+.+.+...++..+...+...+...+...+...+...+...+...+...+.........+.....+...+...+...+...+...+....+.+.....+.+.......+......+......+........+.....+.+.+.........", "..+.+.+...+++++...++++....+.......+...+...++++....++++....+.......+++++.....+.........+...++......+.......+...+...+.+.+...+...+...++++....+...+...++++.....+++......+.....+...+...+...+...+...+.....+.......+.......+.......+.......+.......+.......+...........", "..+.+++...+...+...+...+...+.......+...+...+.......+.......+..++...+...+.....+.........+...+.+.....+.......+...+...+..++...+...+...+.......+.+.+...+.+.........+.....+.....+...+...+...+...+.+.+....+.+......+......+........+........+......+.......+...........", "..+.......+...+...+...+...+...+...+...+...+.......+.......+...+...+...+.....+.....+...+...+..+....+.......+...+...+...+...+...+...+.......+..+....+..+....+...+.....+.....+...+....+.+....+.+.+...+...+.....+.....+.........+.........+.....+.......+...........", "...+++....+...+...++++.....+++....++++....+++++...+........+++....+...+....+++.....+++....+...+...+++++...+...+...+...+....+++....+........++.+...+...+....+++......+......+++......+......+.+....+...+.....+.....+++++.....+++.......+...+++.......+...........", "........................................................................................................................................................................................................................................................++++++++", "....++............+...................+.............++............+.........+.......+.....+.........+...............................................................+........................................................+......+......+........+.+...++++..", "...+..+...........+...................+............+..+...........+.......................+.........+...............................................................+.......................................................+.......+.......+......+.+...+....+.", "...+.......+++....++++.....++++....++++....+++.....+.......++++...++++......+.......+.....+...+.....+.....++.+....++++.....+++....++++.....++++...+.++.....++++....++++...+...+...+...+...+...+...+...+...+...+...+++++.....+.......+.......+............+.++.+.", "..+++.........+...+...+...+.......+...+...+...+...++++....+...+...+...+.....+.......+.....+..+......+.....+.+.+...+...+...+...+...+...+...+...+...++..+...+.........+.....+...+...+...+...+...+....+.+....+...+......+.....+........+........+...........+.+..+.", "...+.......++++...+...+...+.......+...+...+++++....+......+...+...+...+.....+.......+.....+++.......+.....+.+.+...+...+...+...+...+...+...+...+...+........+++......+.....+...+...+...+...+...+.....+.....+...+.....+.......+.......+.......+............+.++.+.", "...+......+...+...+...+...+.......+...+...+........+.......++++...+...+.....+.......+.....+..+......+.....+.+.+...+...+...+...+...++++.....++++...+...........+.....+.....+...+....+.+....+.+.+....+.+.....++++....+........+.......+.......+............+....+.", "..+++++....++++...++++.....++++....++++....++++....+..........+...+...+......+......+.....+...+.....++....+.+.+...+...+....+++....+...........+...+.......++++.......++....++++.....+......+.+....+...+.......+...+++++......+......+......+..............++++..", "...........................................................+++.....................+..............................................+...........+............................................................+++.................................................."}; int main() { int x, y, n, c; unsigned char font[96][8]; FILE *outfile; // copy from the 'image' into the font for(y = 0; y<24; y++) { for(x = 0; x<32; x++) { c = 0; for(n = 0; n<8; n++) { c <<= 1; c |= (samfont[y][x*8+n]=='+'); } font[x+y/8*32][y%8] = c; } } outfile = fopen("samfont.psf", "wb"); if(!outfile) { fprintf(stderr, "failed to open samfont.psf\n"); exit(EXIT_FAILURE); } // write the psf header fputc(0x36, outfile); fputc(0x04, outfile); fputc(0x00, outfile); fputc(0x08, outfile); // blank space for missing glyphs for(n = 0; n<32*8; n++) fputc(0, outfile); // write the font out for(x = 0; x<96; x++) for(n=0; n<8; n++) fputc(font[x][n], outfile); // blank space for missing glyphs for(n = 0; n<(256-96-32)*8; n++) fputc(0, outfile); fclose(outfile); return EXIT_SUCCESS; }