summaryrefslogtreecommitdiffstats
path: root/psftoc.pl
blob: 0038bdf89512a88a706d26ade12f4040b10931e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/perl
#
# Convert PSF input to a C structure
#

eval { use bytes; };

read(STDIN, $hdr, 4);

($magic, $mode, $size) = unpack("vCC", $hdr);

die "$0: Not a PSF1 file on input\n" if ( $magic != 0x0436 );

print "unsigned char grv_font[256][$size] = {\n";

for ( $i = 0 ; $i < 256 ; $i++ ) {
    print "  ";
    for ( $j = 0 ; $j < $size ; $j++ ) {
	read(STDIN, $byte, 1);
	printf "%s0x%02x", ($j == 0 ? '{' : ','), unpack("C",$byte);
    }
    print "},\n";
}
print "};\n";