2013-07-30 30 views
2

大家好我是新來的,我的英語不好,對不起。調整圖片上阿拉伯文字的位置

我有一個imagettfstring開始位置的問題,阿拉伯語是從右到左,所以我有問題保持在自定義位置的阿拉伯語,例如從右邊50px。

試圖表明我的意思與形象: enter image description here

我想在底部的紅色文本從右側開始,如果這是可能的,文字是從左至右開始,是有辦法把黑線貼在白線上? 我希望當文本獲得更大的去與棕色箭頭方向

我使用的代碼:

<?php 
    require_once("image.php"); 
    $image = new image; 
    if (isset($_REQUEST["name"])) { 
     $image -> createFromFile(1, "gbg.png"); 
     $c = $image -> arabttfBox(45, 0, "andlso.ttf", $_REQUEST["name"]); 
     $image -> arabttfString(1, $c[0], "andlso.ttf", 45, "#F00", 0, 0 , 100); 
     $image -> arabttfString(1, $_REQUEST["name"], "andlso.ttf", 45, "#F00", 
           0, 0 , 520); 
     $image -> display(1, "png"); 
    } else { 
     $image -> create("error", 400, 100, "#333"); 
     $image -> border("error", "#000", "3"); 
     $image -> string("error", "Post a name", 5, "#F00", 10, 10, true, true); 
     $image -> display("error", "png"); 
    } 
?> 

的圖像: enter image description here

阿拉伯文文本,如果你想複製:

سمرعلي

如果你想讓我上傳字體,告訴我。

經過一番思考我已經解決了它:

list($IW, $IH) = $this -> dimensions($ID); 
list($FW, $FH) = $this -> arabttfBox($Size, $Angle, $Font, fagd($string)); 
return imagettftext($this -> image[$ID], $Size, $Angle, $IW-$FW-$X, $Y, 
        imagecolorallocate($this -> image[$ID], $R, $G, $B), 
        $Font, fagd($string)); 
+0

請你添加一些代碼? – liyakat

+0

好的,我已經添加了代碼 –

+0

我已經解決了它^^感謝 –

回答

1

解決方案:

list($IW, $IH) = $this -> dimensions($ID); 
list($FW, $FH) = $this -> arabttfBox($Size, $Angle, $Font, fagd($string)); 
return imagettftext($this -> image[$ID], $Size, $Angle, $IW-$FW-$X, $Y, 
        imagecolorallocate($this -> image[$ID], $R, $G, $B), 
        $Font, fagd($string)); 

enter image description here