dsaba Posted March 26, 2007 Share Posted March 26, 2007 I want to write a text string from right to left instead of from left to right with the imagettftext (); function I read in teh manual that the angle variable controls this, it says that 0 angle means left to right, so I tried 180, 360 but nothing happens What angle do I need to put it to get it to write it right to left I am writing a hebrew text string with a font.ttf that supports hebrew characters <?php $white = imagecolorallocate($background, 255, 255, 255); $fontfile = "davidtr.ttf"; $string = "מחלדגכ"; imagettftext($background, 12, 360, 3, 17, $white, $fontfile, $string); ?> -thanks for the help! Quote Link to comment Share on other sites More sharing options...
dsaba Posted March 26, 2007 Author Share Posted March 26, 2007 ok i tried using hebrev() but that only works for displaying the text, when writing it to the image nothing happens so really what is going is that the hebrew text is being written backwards on the image, so in that case i'm okay with writing the hebrew text backwards in teh first place so is there a function in php to take a string and turn it backwards? for example: i want to change "hello" to "olleh" Quote Link to comment Share on other sites More sharing options...
dsaba Posted March 26, 2007 Author Share Posted March 26, 2007 ok I discovered this function strrev() so here is my new code: $white = imagecolorallocate($background, 255, 255, 255); $fontfile = "davidtr.ttf"; $string = strrev("עברית"); //imagettftext($image, $font_size, 0, $x, $y, $text_color, $this->font , $code) or die('Error in imagettftext function'); imagettftext($background, 12, 0, 3, 17, $white, $fontfile, $string); now the text is screwed up on the image some letters are white boxes I read that white boxes mean that the font does not support these characters, however i wrote the same string with the same font earlier and there were no white boxes for characters so obviously something is fuckin' up the string when I run it through the strrev() function how do I fix this? Quote Link to comment Share on other sites More sharing options...
dsaba Posted March 26, 2007 Author Share Posted March 26, 2007 the problem was that strrev() had problems reversing UTF-8 encoded text strings (like hebrew) so i used this function to reverse it (taken from comments off php.net) function utf8_strrev($str){ preg_match_all('/./us', $str, $ar); return join('',array_reverse($ar[0])); } I don't quite understand everythign the function does, but hey it works! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.