NAME
Font::TFM -- read information from TeX font metric files
SYNOPSIS
use Font::TFM;
### $Font::TFM::TEXFONTSDIR = 'your directories';
### to change the default
my $cmr = new Font::TFM 'cmr10'
or die "Error reading font: $Font::TFM::errstr\n";
print 'Designsize: ', $cmr->designsize(), "\n";
print $cmr->width('A'), ', ', $cmr->kern('Wo'), "\n";
should print
Designsize: 10
491521.25, -54613.75
DESCRIPTION
To read the information from TFM (TeX font metrics) file, you first create the object of Font::TFM class in memory. You do this by calling method Font::TFM::new with font name and it creates a new TFM object in memory, loading all the necessary information from the .tfm
file. Second (optional) parameter means scale of the font. You can also use Font::TFM::new_at and as the second parameter put requested size in pt:
my $cmr10_12 = new_at Font::TFM 'cmr10', 12;
The methods new and new_at search for the .tfm
files in the directories listed colon separated in a variable $Font::TFM::TEXFONTSDIR, and also in all of their subdirectories. By default, they use files ls-R
(this name can be changed in the $Font::TFM::LSFILENAME variable) to speed up the search. This feature can be disabled by setting variable $Font::TFM::TEXFONTSUSELS to 0. Suffix .tfm
is appended if necessary.
If the file is not found (or there is some other problem), new returns undef
and sets error message to $Font::TFM::errstr.
After the file was loaded, you can use the following methods of the object to query information about the font's properties and about the characters, etc.
- designsize, fontsize
-
Returns the design size and the actual size of the font in pt.
$cmr->designsize; returns 10 $cmr->fontsize; 10 $cmr10_12->fontsize; 12
- width, height, depth, italic
-
Returns the requested dimension for a specified character of the font.
$cmr->height("A") 447828.75 $cmr10_12->height("A") 537394.5 $cmr->italic("I") 0 $cmr10_12->italic("f") 61167.75
- kern, lig, ligpassover
-
For a two-letter string returns kern between them, ligature formed and number of characters to pass over after the ligature, respectivelly.
$cmr->lig("fi") \014 $cmr->lig("ff") \013 $cmr->lig("\013i") \016 $cmr10_12->kern("AV") -87381.75
- expand
-
One string parameter undergoes ligature expansion and then kernings are inserted. Returns array containing of string, kern, string, ...
$cmr->expand("AV--fix") "A", -72818.125, "V{\014x"
- word_dimensions
-
Returns the width, height and depth of a word. Does the lig/kern expansion, so the result is the real space it will take on output.
$cmr->word_dimensions("AV--fix") 1947881.875, 455111.25, 0 $cmr->word_dimensions("pm") 910225, 282168.75, 127431.25
- word_width, word_height, word_depth
-
Calls
word_dimensions
and returns appropriate element. No caching is done, so it is better to callword_dimensions
yourself if you will need more than one dimension of one word. - param
-
Returns parameter of the font, indexed from 1.
- slant, x_height, em_width, quad
- space, space_stretch, space_shrink, extra_space
-
Returns the parameter of the font, by name.
$cmr->slant() 0 $cmsl10->slant() 0.166671752929688 $cmr->x_height() 282168.75 $cmr->height("x") 282168.75 $cmr->em_width() 655361.875 $cmr->quad() 655361.875 $cmr->space() 218453.75 $cmr->space_stretch() 109226.875 $cmtt10->space() 344061.25 $cmtt10->space_stretch() 0
- name
-
Returns the name of the font.
Dimensions are multiplied by $Font::TFM::MULTIPLY * actual size of the font. Value of $Font::TFM::MULTIPLY defaults to 65536, so the dimensions can be used directly when writing the .dvi
file.
Variable $Font::TFM::DEBUG may be set to 1 to get the processing messages on the standard error output.
The module is subclassable. You can define you own module that would provide alternate way of finding and opening the file. Just make new module and defined your own method open_tfm in it.
VERSION
0.110
SEE ALSO
TeX::DVI(3), TeX::DVI::Parse(3), perl(1).
AUTHOR
(c) 1996--2001 Jan Pazdziora, adelton@fi.muni.cz, http://www.fi.muni.cz/~adelton/ at Faculty of Informatics, Masaryk University, Brno, Czech Republic