PostScript::Font - module to fetch data from PostScript fonts |
PostScript::Font - module to fetch data from PostScript fonts
my $info = new PostScript::Font (filename, options); print STDOUT ("Name = ", $info->FontName, "\n");
This package reads PostScript font files and stores the information in memory.
Most font file formats that are in use are recognised, especially the Type 1 and Type 42 font formats. Other formats that usually parse okay are Type 5 and Type 3, although Type 3 can sometimes fail depending on how weird the font information is stored.
The input font file can be encoded in ASCII (so-called .pfa
format), or binary (so-called .pfb
format).
If you have Martin Hosken's Font::TTF package installed, PostScript::Font can also handle True Type fonts. They are converted internally to Type 42 format.
How errors must be handled. Default is to call die().
In any case, new()
returns a undefined result.
Setting 'error' to 'ignore' may cause surprising results.
'ascii'
, suitable to be downloaded to a PostScript printer.
Each of these methods can return undef
if the corresponding
information could not be found in the file.
True Type fonts will be converted to Type 42 internally, but still have 't' as FontType.
int(1/$font->FontMatrix->[0])
'StandardEncoding'
or
'ISOLatin1Encoding'
, or a reference to an array that holds the
encoding. In this case, the array will contain a glyph name (a string)
for each element that is encoded.
NOTE: Getting the encoding information can fail if the way it was stored in the font is not recognized by the parser. This is most likely to happen with manually constructed fonts.
NOTE: Getting the glyphs information can fail if the way it was stored in the font is not recognized by the parser. This is most likely to happen with manually constructed fonts.
Extracting the glyphs can be slow. It can be speeded up by using the
external program t1disasm. This program will be used automatically,
if it can be found in the execution PATH
. Alternatively, you can
set the variable $PostScript::Font::t1disasm
to point to the
t1disasm program. This does not apply to type 42 fonts, since these
fonts do not require disassembly to get at the glyph list.
If this is the only thing you want from this module, use
PostScript::StandardEncoding
instead.
If this is the only thing you want from this module, use
PostScript::ISOLatin1Encoding
instead.
t1disasm can be used to speed up the fetching of the list of font glyphs from Type 1 fonts. It is called as follows:
t1disasm filename
This invocation will write the disassembled version of the Type 1 font to standard output. t1disasm is part of the t1utils package that can be found at http://www.lcdf.org/~eddietwo/type/ and several other places.
Invoking external programs (like t1disasm) is guaranteed to work on Unix only.
Johan Vromans, Squirrel Consultancy <jvromans@squirrel.nl>
This program is Copyright 2000,1998 by Squirrel Consultancy. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the terms of either: a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or b) the ``Artistic License'' which comes with Perl.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See either the GNU General Public License or the Artistic License for more details.
PostScript::Font - module to fetch data from PostScript fonts |