Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re: Centering Text with GD::Image

by tangent (Vicar)
on Nov 03, 2021 at 19:40 UTC ( #11138403=note: print w/replies, xml ) Need Help??

in reply to Centering Text with GD::Image

You can get the bounds of the text box using the stringFT() method, but you will need to load up a truetype font first - see the "Character and String Drawing" section in the GD docs.

Replies are listed 'Best First'.
Re^2: Centering Text with GD::Image
by djlerman (Sexton) on Nov 03, 2021 at 21:37 UTC
    Will this not work with the built in fonts? I am using gdGiantFont.
      According to GD#Font-Utilities, gdGiantFont is a fixed width (monospace) 9x15 font, so unless I'm very much mistaken, it's just 9*nChars to get the width, and the height is a fixed 15 per line of text.

      edit and it's got the width and height methods to tell you those numbers in the code.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2022-01-17 17:29 GMT
Find Nodes?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:

    Results (51 votes). Check out past polls.