View on
MetaCPAN is shutting down
For details read Perl NOC. After June 25th this page will redirect to
Johan Vromans > PostScript-Font > PostScript::PrinterFontMetrics



Annotate this POD


Open  2
View/Report Bugs
Module Version: 0.08   Source  


PostScript::PrinterFontMetrics - module to fetch data from Printer Font Metrics files


  my $info = new PostScript::PrinterFontMetrics (filename, options);
  print STDOUT ("Name = ", $info->FontName, "\n");
  print STDOUT ("Width of LAV = ", $info->kstringwidth("LAV", 10), "\n");


This package allows printer font metric files for PostScript files (so called .pfm files) to be read and (partly) parsed. PFM files contain information that overlaps with that contained in AFM files and can be used with the font files to generate missing AFM files.



The constructor will read the file and parse its contents.


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.

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'.


Note: Most of the info from the PFM file can be obtained by calling a method of the same name, e.g. dfMaxWidth and etmCapHeight. Fields that overlap with fields in the AFM file are also available using the AFM name, e.g. etmCapHeight can be referred to as CapHeight, and PostScriptName as FontName.

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


The name of the file, e.g. 'tir_____.pfm'. This is not derived from the metrics data, but the name of the file as passed to the new method.


The complete contents of the file -- note though that PFM files are binary files.


Returns a reference to a hash with the character widths for each glyph.


Returns a reference to an array with the glyph names for each encoded character.


Returns a reference to a hash with the kerning data for glyph pairs. It is indexed by two glyph names (two strings separated by a comma, e.g. $kd->{"A","B"}).

This module also inherits methods from PostScript::FontMetrics.


PFM files contain information that overlaps with AFM files, including character widths and kerning pairs.

The PFM file specification is available in the Microsoft Windows Device Development Kit (DDK) (for Windows 3.1), however I have been unable to locate this document. Details of the structure of PFM were gleaned from an Adobe technical note and by examining sample PFM files.


Building PFM Files for PostScript-Language CJK Fonts describes the structure of PFM files for CJK files, but the information appears to be applicable for western fonts too.


Andrew Ford, Ford & Mason Ltd <>

This module draws heavily on the PostScript::FontMetrics module by Johan Vromans.


This program is Copyright 2001 by Andrew Ford and Ford & Mason Ltd. 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.

syntax highlighting: