|
Font::TFM -- read information from TeX font metric files |
Font::TFM -- read information from TeX font metric files
use Font::TFM;
my $cmr = new Font::TFM name => '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
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 other parameters
and it creates a new TFM object in memory, loading all the necessary
information from the .tfm file.
The parameters are passed to Font::TFM::new in a form of a hash:
ls-R.
To switch this behaviour off, use value 0 or 'no' for parameter usels, or set global variable $Font::TFM::TEXFONTSUSELS to 0.
.dvi file.
If the file is not found (or there is some other problem), new
returns undef and sets error message to $Font::TFM::errstr.
Examples:
$cmr10 = new Font::TFM 'cmr10';
$cmr10 = new Font::TFM 'name' => 'cmr10';
$cmr10 = new Font::TFM 'file' => './dir/cmr10.tfm';
$cmr12_14 = new Font::TFM 'name' => 'cmr12', at => 14
or die 'Error loading font cmr12 at 14 pt: '
. $Font::TFM::errstr;
For backward compatibility, you can use Font::TFM::new with just one parameter, the font name, or with two parameters, the font name and the scale of the size, instead of the hash of parameters and values. For backward compatibility, you can use Font::TFM::new_at with two parameters, font name and point size of the font.
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.
$cmr->designsize; returns 10
$cmr->fontsize; 10
$cmr10_12->fontsize; 12
$cmr->height("A") 447828.75
$cmr10_12->height("A") 537394.5
$cmr->italic("I") 0
$cmr10_12->italic("f") 61167.75
$cmr->lig("fi") \014
$cmr->lig("ff") \013
$cmr->lig("\013i") \016
$cmr10_12->kern("AV") -87381.75
$cmr->expand("AV--fix") "A", -72818.125, "V{\014x"
$cmr->word_dimensions("AV--fix")
1947881.875, 455111.25, 0
$cmr->word_dimensions("pm") 910225, 282168.75, 127431.25
word_dimensions and returns appropriate element. No caching
is done, so it is better to call word_dimensions yourself if you
will need more than one dimension of one word.
$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
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.
0.130
TeX::DVI(3), TeX::DVI::Parse(3), perl(1).
(c) 1996--2001 Jan Pazdziora, adelton@fi.muni.cz, http://www.fi.muni.cz/~adelton/ at Faculty of Informatics, Masaryk University, Brno, Czech Republic
|
Font::TFM -- read information from TeX font metric files |