NAME

PostScript::Font - module to fetch data from PostScript fonts

SYNOPSIS

  my $info = new PostScript::Font (filename, options);
  print STDOUT ("Name = ", $info->FontName, "\n");

DESCRIPTION

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.

CONSTRUCTOR

new ( FILENAME [ , OPTIONS ] )

The constructor will read the file and parse its contents.

OPTIONS

error => [ 'die' | 'warn' | 'ignore' ]

DEPRECATED. Please use 'eval { ... }' to intercept errors.

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.

format => [ 'ascii' | 'pfa' | 'binary' | 'pfb' ]

The format in which the font data is stored. Default is 'ascii', suitable to be downloaded to a PostScript printer.

verbose => value

Prints verbose info if value is true.

trace => value

Prints tracing info if value is true.

debug => value

Prints debugging info if value is true. Implies 'trace' and 'verbose'.

INSTANCE METHODS

Each of these methods can return undef if the corresponding information could not be found in the file.

FileName

The name of the file, e.g. 'tir_____.pfb'.

FontName

The name of the font, e.g. 'Times-Roman'.

FamilyName

The family name of the font, e.g. 'Times'.

Version

The version of the font, e.g. '001.007'.

ItalicAngle

The italicity of the font, e.g. 0 (normal upright fonts) or -16 (italic font).

isFixedPitch

Indicates if this font has fixed pitch.

Weight

This font weight.

FontType

The font type, e.g. '1' for a Type 1 PostScript font, or 't' for a True Type font.

True Type fonts will be converted to Type 42 internally, but still have 't' as FontType.

FontMatrix

The font matrix as a reference to an anonymous array with the 6 values. To find the font scale, use

    int(1/$font->FontMatrix->[0])
FontBBox

The font bounding box as a reference to an anonymous array with the 4 values.

DataFormat

The format in which the data is kept internally. See the format option.

FontData

The complete contents of the file, normalised to Unix-style line endings. It is in the format as returned by the DataFormat method.

Encoding

This is either one of the strings '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.

EncodingVector

Like encoding, but always returns a reference to the encoding array. In other words, the standard encodings are returned as arrays as well.

FontGlyphs

This returns a reference to an array holding all the names of the glyphs this font defines, in the order the definitions occur in the font data.

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.

CLASS METHODS

StandardEncoding

Returns a reference to an array that contains all the glyphs names for Adobe's Standard Encoding.

If this is the only thing you want from this module, use PostScript::StandardEncoding instead.

ISOLatin1Encoding

Returns a reference to an array that contains all the glyphs names for ISO-8859-1 (ISO Latin-1) encoding.

If this is the only thing you want from this module, use PostScript::ISOLatin1Encoding instead.

EXTERNAL PROGRAMS

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.

KNOWN BUGS

Invoking external programs (like t1disasm) is guaranteed to work on Unix only.

SEE ALSO

http://partners.adobe.com/asn/developer/PDFS/TN/T1_SPEC.PDF

The specification of the Type 1 font format.

http://partners.adobe.com/asn/developer/PDFS/TN/5012.Type42_Spec.pdf

The specification of the Type 42 font format.

http://fonts.apple.com/TTRefMan/index.html

The True Type reference manual.

http://partners.adobe.com/asn/developer/PDFS/TN/5004.AFM_Spec.pdf

The specification of the Adobe font metrics file format.

AUTHOR

Johan Vromans, Squirrel Consultancy <jvromans@squirrel.nl>

COPYRIGHT and DISCLAIMER

This program is Copyright 2014,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.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 718:

You forgot a '=back' before '=head1'