By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,713 Members | 1,326 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,713 IT Pros & Developers. It's quick & easy.

imagettftext and "\t" problem

P: n/a
Im using imagettftext to write some text on my image. I'm on Win XP and using
the plain arial.ttf font that I copied from win dir
my typical line would be
imagettftext($im, 33, 0, 20, 500, $black, 'arial.ttf', $text);

everything is perfect except the tab "\t" sign
if I set $text = "something\tsomething" the tab gets displayed but it also
displays some rectangle like "this char is in wrong encoding" or something like
that. Basically I get two chars out of "\t" the tab and that rectangle. Using
"\n" is normal - it just splits my text in 2 lines. But I'm very confused with
this "\t" issue :-( Is there another way to make tabs?

thanks gordan
Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Gordan wrote:
Im using imagettftext to write some text on my image. I'm on Win XP and using
the plain arial.ttf font that I copied from win dir
my typical line would be
imagettftext($im, 33, 0, 20, 500, $black, 'arial.ttf', $text);

everything is perfect except the tab "\t" sign
if I set $text = "something\tsomething" the tab gets displayed but it also
displays some rectangle like "this char is in wrong encoding" or something like
that. Basically I get two chars out of "\t" the tab and that rectangle. Using
"\n" is normal - it just splits my text in 2 lines. But I'm very confused with
this "\t" issue :-( Is there another way to make tabs?

thanks gordan


\t is an escape character. So in order to display the '\' you have to
escape the '\' :)

like this :
$text = "something\\tsomething"
Jul 17 '05 #2

P: n/a
Im using imagettftext to write some text on my image.
everything is perfect except the tab "\t" sign


I guess this function is designed to handle carriage returns but has no
understanding of tabs, so you'll have to add your own logic depending
on what you want to achieve in the final image.

For instance if you're trying to lay out text in columns in the image,
you can split the text on "\t" and draw each part separately starting
at a different offset from the left.

---
Steve

Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.