1

In PHP, I am generate an image which has stylised text added to it. The text is dynamic and can have a number of styles applied to it.

e.g The quick brown fox jumped over the lazy dog

How can I do this in PHP?

MakkyNZ
  • 2,215
  • 5
  • 33
  • 53

1 Answers1

1

In PHP there is diffferent methods to ad text with a different style/font type/ siize etc. Check out: http://php.net/manual/en/function.imagettftext.php or http://php.net/manual/en/function.imagestring.php and several other methods in

To keep record of the size of your string and manage the placement you can use http://php.net/manual/en/function.imagettfbbox.php.

Anders Finn Jørgensen
  • 1,275
  • 1
  • 17
  • 33
  • But how can I have multiple styles applied to the one string? I thought about splitting the string up into words but that would be tricky to manage the spacing between words – MakkyNZ Nov 10 '14 at 16:04
  • I Don't think you can. You must split your string into pieces with their own style and add the to the image sequential. Use imagettfbbox to keep record of where in the image your must place your next piece of string. – Anders Finn Jørgensen Nov 10 '14 at 16:06