|
Font::BDF::Reader - Module for reading in BDF files |
Font::BDF::Reader - Module for reading in BDF files
use Font::BDF::Reader; my $BDF = Font::BDF::Reader->new( $bdf_filename );
my @starchars = $BDF->get_all_STARTCHAR;
sub font_to_png {
...
}
foreach my $starchar (@starchars) {
my $png_data = font_to_png( $BDF->get_font_info_by_STARTCHAR( $starchar ) );
my $png_file = "$bdf_base.$starchar.png";
my $FH = IO::File->new( ">$png_file" )
|| die "Error opening file for write: '$png_file'";
binmode $FH;
print $FH $png_data;
}
This module supports importing data from BDF files. A BDF file is an ASCII file that defines a font. The fonts are bitmap fonts, and are easily converted to other formats.
This module imports data from a BDF file. Have a look at the BDF file spec at http://partners.adobe.com/asn/developer/PDFS/TN/5005.BDF_Spec.pdf.
die() if it can't find
or open BDF_FILE.
open_bdf_file() has been called. It reads in the BDF metadata,
using read_bdf_metadata(), and then reads in ALL of the characters in
the BDF file using read_bdf_chars(). Will die() if the BDF file has not
been opened yet.
open_bdf_file() has been called.
'SIZE' => '48 100 100',
'STARTFONT' => '2.1',
'FONT_ASCENT' => '46',
'FONT' => '-watanabe-fixed-medium-r-normal--48-450-75-75-c-480-jisx0208.1983-0',
'COMMENT' => undef,
'ENDPROPERTIES' => undef,
'STARTPROPERTIES' => '4',
'DEFAULT_CHAR' => '41377',
'COPYRIGHT' => '"Public Domain"',
'CHARS' => '8890',
'FONTBOUNDINGBOX' => '48 48 0 -2',
'FONT_DESCENT' => '2'
This procedure also keeps track of the number of characters read, issuing a warning if the number of characters does not equal the expected number of characters as specified in the metadata section.
The following is an example of font information returned by this routine: { 'BITMAP' => [ '000000000000', <SNIP, SNIP> '000000000000' ], 'ENCODING' => [ '8481' ], 'DWIDTH' => [ '48', '0' ], 'BBX' => [ '48', '48', '0', '-2' ], 'SWIDTH' => [ '150', '0' ], 'STARTCHAR' => '2121' }
This is basically the most direct conversion from the BDF file to a Perl hash.
Nothing.
See the script bdf2png for example usage of this module.
The specifications for the BDF format can be found here: http://partners.adobe.com/asn/developer/PDFS/TN/5005.BDF_Spec.pdf.
Desmond Lee, <dclee@shaw.ca
Copyright 2003 by Desmond Lee
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
|
Font::BDF::Reader - Module for reading in BDF files |