Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Adjustable pdf text size in API2

by john_oshea (Priest)
on Jan 31, 2006 at 16:42 UTC ( [id://526792]=note: print w/replies, xml ) Need Help??


in reply to Adjustable pdf text size in API2

If you're using the core 14 fonts, the widths for each character are defined as part of the font's internal representation - in particular, there's a 'wx' hash which maps a width to each character. For non-core fonts, you could get at the bounding box of each character via PDF::API2::Basic::TTF::Glyph and derive the width from that.

For either approach, you'd have to take the character width, multiply by whatever text size you're actually outputting at and get a final display width for a given character from that. It'd be tedious, but I can't (at the moment) see a higher-level way of getting the widths you need.

Note: this doesn't take into account kerning pairs, which may or may not matter in your particular case.

Hope that helps.

Update: Ignore this - see GhodMode's reply for a much better answer.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://526792]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (4)
As of 2024-04-20 00:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found