in reply to Font size by pixels.
If you're starting out with PostScript fonts, a good idea when attempting to generate PDF; and you have the associated .afm files (more like a rarity these days), then one option is to use the old module Font::AFM, and its method stringwidth(), to calculate the physical width of a piece of text, in the font size you like.
Another option, at least when you're using one of the standard PDF fonts, is to use the PDF::API2::CoreFont module. As the docs say:
$wd = $font->width($text) Returns the width of $text as if it were at size 1.In order to get the size at other font sizes, just multiply by the font size.
|
|---|