- Added lower-case characters to terminal font

- Added font image (PNG) for easy font editing, and script to convert to font.bin needed by emulator
This commit is contained in:
Simon Owen 2008-09-05 10:51:32 +00:00
parent 4b1bf5d034
commit 64db2eff61
3 changed files with 64 additions and 0 deletions

BIN
font.bin

Binary file not shown.

64
font.pl Normal file
View File

@ -0,0 +1,64 @@
#!/usr/bin/perl -w
#
# Convert PNG image to raw font binary for Apple 1 emulator
#
# Makes lots of assumptions about the input image!
use Compress::Zlib;
# Input image and output data file
my $input = 'font.png';
my $output = 'font.bin';
# Our characters are 6 pixels wide
$chrw = 6;
# Slurp the entire PNG image
open INPUT, "<$input" and binmode INPUT or die "$input: $!\n";
read INPUT, $data='', -s $input;
close INPUT;
# Find and extract the image dimensions
$data =~ /IHDR(.{8})/s;
($w,$h) = unpack "N2", $1;
# Extract and expand the compressed image data
($data) = $data =~ /IDAT(.*).{8}IEND/s;
$data = Compress::Zlib::uncompress($data);
# Remove the type byte from the start of each line
$w_2 = $w/2;
$data =~ s/.(.{$w_2})/$1/sg;
@data = ();
# Unpack the pixel nibbles
foreach (unpack "C*", $data) {
push @data, $_>>4, $_&1;
}
open OUTPUT, ">$output" and binmode OUTPUT or die "$output: $!\n";
# Process all characters
foreach $chr (0..$w/$chrw-1)
{
# Process the image line by line
foreach $y (0..$h-1)
{
# Locate the pixel data for the current character
my $x = $chr*$chrw + $w*$y;
my $b = 0;
# Pack the 1bpp data into a single byte
foreach (@data[$x..$x+$chrw-1]) {
$b = ($b << 1) | $_;
}
# Left-align within the byte and output it
print OUTPUT chr($b << (8-$chrw));
}
}
close OUTPUT;

BIN
font.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 699 B