Skip to content

Commit

Permalink
Add GNU Unifont format hex font conversions
Browse files Browse the repository at this point in the history
  • Loading branch information
konker committed Jun 9, 2018
1 parent cf032fb commit 8b905b5
Show file tree
Hide file tree
Showing 14 changed files with 1,509 additions and 0 deletions.
32 changes: 32 additions & 0 deletions hexfont/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

all: parts latin full

parts:
./convert_h_to_hexfont.pl ../font8x8_basic.h > font8x8_basic.hex
./convert_h_to_hexfont.pl ../font8x8_box.h > font8x8_box.hex
./convert_h_to_hexfont.pl ../font8x8_block.h > font8x8_block.hex
./convert_h_to_hexfont.pl ../font8x8_control.h > font8x8_control.hex
./convert_h_to_hexfont.pl ../font8x8_ext_latin.h > font8x8_ext_latin.hex
./convert_h_to_hexfont.pl ../font8x8_greek.h > font8x8_greek.hex
./convert_h_to_hexfont.pl ../font8x8_hiragana.h > font8x8_hiragana.hex
./convert_h_to_hexfont.pl ../font8x8_misc.h > font8x8_misc.hex
./convert_h_to_hexfont.pl ../font8x8_sga.h > font8x8_sga.hex

latin:
./convert_h_to_hexfont.pl ../font8x8_basic.h > font8x8_latin.hex
./convert_h_to_hexfont.pl ../font8x8_control.h >> font8x8_latin.hex
./convert_h_to_hexfont.pl ../font8x8_ext_latin.h >> font8x8_latin.hex

full:
./convert_h_to_hexfont.pl ../font8x8_basic.h > font8x8.hex
./convert_h_to_hexfont.pl ../font8x8_control.h >> font8x8.hex
./convert_h_to_hexfont.pl ../font8x8_ext_latin.h >> font8x8.hex
./convert_h_to_hexfont.pl ../font8x8_greek.h >> font8x8.hex
./convert_h_to_hexfont.pl ../font8x8_misc.h >> font8x8.hex
./convert_h_to_hexfont.pl ../font8x8_box.h >> font8x8.hex
./convert_h_to_hexfont.pl ../font8x8_block.h >> font8x8.hex
./convert_h_to_hexfont.pl ../font8x8_hiragana.h >> font8x8.hex
./convert_h_to_hexfont.pl ../font8x8_sga.h >> font8x8.hex

clean:
rm *.hex
6 changes: 6 additions & 0 deletions hexfont/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Hexfont format conversions for the font8x8
==============================================================================

Author: Konrad Markus <[email protected]>


17 changes: 17 additions & 0 deletions hexfont/convert_h_to_hexfont.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env perl

use strict;

my $reversebytestr = sub {
my $bs = shift(@_);
return sprintf "%02X", ord pack "B*", scalar reverse sprintf("%b", hex($bs))
};

for (<>) {
if (my @matches = /\s*{\s*0x([0-9A-Fa-f]{2}),\s*0x([0-9A-Fa-f]{2}),\s*0x([0-9A-Fa-f]{2}),\s*0x([0-9A-Fa-f]{2}),\s*0x([0-9A-Fa-f]{2}),\s*0x([0-9A-Fa-f]{2}),\s*0x([0-9A-Fa-f]{2}),\s*0x([0-9A-Fa-f]{2})\s*}[^\/]*\/\/\s*U\+([0-9A-Fa-f]{4})/g) {
my $index = $matches[8];
my @bytes = @matches[0,1,2,3,4,5,6,7];
my @revbytes = map $reversebytestr->($_), @bytes;
print "$index:", join("", @revbytes), "\n";
}
}
Loading

0 comments on commit 8b905b5

Please sign in to comment.