2018-04-28 02:37:12 +00:00
|
|
|
#!/usr/bin/env perl
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
|
|
|
# Displays the glyphs from an MGTK font.
|
|
|
|
|
|
|
|
sub getbyte {
|
|
|
|
my $b;
|
|
|
|
read(STDIN, $b, 1);
|
|
|
|
return ord($b);
|
|
|
|
}
|
|
|
|
|
|
|
|
my $type = getbyte();
|
|
|
|
my $last = getbyte();
|
|
|
|
my $height = getbyte();
|
|
|
|
my $num = $last + 1;
|
|
|
|
my $cols = $type ? 2 : 1;
|
|
|
|
|
|
|
|
print "type: $type\n";
|
|
|
|
print "chars: $num\n";
|
|
|
|
print "height: $height\n";
|
|
|
|
|
|
|
|
my @chars;
|
|
|
|
for (my $i = 0; $i < $num; ++$i) {
|
|
|
|
$chars[$i] = '';
|
|
|
|
}
|
|
|
|
|
2018-05-09 03:14:59 +00:00
|
|
|
my @widths;
|
2018-04-28 02:37:12 +00:00
|
|
|
for (my $i = 0; $i < $num; ++$i) {
|
2018-05-09 03:14:59 +00:00
|
|
|
push @widths, getbyte();
|
2018-04-28 02:37:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (my $row = 0; $row < $height; ++$row) {
|
|
|
|
for (my $col = 0; $col < $cols; ++$col) {
|
|
|
|
for (my $c = 0; $c < $num; ++$c) {
|
|
|
|
my $bits = sprintf("%07b", getbyte());
|
2018-05-09 03:14:59 +00:00
|
|
|
$bits =~ tr/01/.#/;
|
2018-04-28 02:37:12 +00:00
|
|
|
$bits = reverse $bits;
|
|
|
|
|
|
|
|
$chars[$c] .= $bits;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (my $c = 0; $c < $num; ++$c) {
|
|
|
|
$chars[$c] .= "\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-09 03:14:59 +00:00
|
|
|
for (my $i = 0; $i < $num; ++$i) {
|
|
|
|
$chars[$i] =
|
|
|
|
join("\n",
|
|
|
|
map { substr($_, 0, $widths[$i]) }
|
|
|
|
split("\n", $chars[$i]));
|
|
|
|
}
|
2018-04-28 02:37:12 +00:00
|
|
|
|
|
|
|
for (my $i = 0; $i < $num; ++$i) {
|
2018-05-09 03:14:59 +00:00
|
|
|
print "== 0x".sprintf("%02x",$i)." ==\n$chars[$i]\n";
|
2018-04-28 02:37:12 +00:00
|
|
|
}
|