Roman Fedorov Posted July 13, 2010 Share Posted July 13, 2010 First of all, Hello all! I have this problem: I want to create an image sized perfectly to contain a specific text, so i use imagettfbbox function to find the width of the image, and then use imagettf starting from x=0 to draw the text. So for example something like print_r(imagettfbbox(50, 0, "./comic.ttf", "Hello")); On my server it returns Array ( [ 0] => -1 [1] => -1 [2] => 149 [3] => -1 [4] => 149 [5] => -56 [6] => -1 [7] => -56 ) So i consider the width of the text 149+1= 150, the problem is that 150 is actually the width of the text but only if you consider it from most left colored pixel to most right colored pixel. Cos when i make imagettftext starting from x=0 there is anyway a small offset to the right of some pixels before text starting, so the width i calculated is not enough, and it "cust out" my text. I tried the same line of code on other server and it gives me Array ( [ 0] => 2 [1] => 3 [2] => 159 [3] => 3 [4] => 159 [5] => -54 [6] => 2 [7] => -54 ) So in this case the width is 159-2=157 and this is exactly the width neccessary to contain my whole text, ofsets included! Any ideas on what my server is doing wrong, and how to fix it? (Font files are the same) Thank you Here is some info if you need it: My server (working wrong i suppose): PHP Version 5.2.10 GD Support enabled GD Version bundled (2.0.34 compatible) FreeType Support enabled FreeType Linkage with freetype FreeType Version 2.1.9 T1Lib Support enabled GIF Read Support enabled GIF Create Support enabled JPG Support enabled PNG Support enabled WBMP Support enabled XBM Support enabled And the other server (working cool): PHP Version 5.2.4-2ubuntu5.10 gd GD Support enabled GD Version 2.0 or higher FreeType Support enabled FreeType Linkage with freetype FreeType Version 2.3.5 T1Lib Support enabled GIF Read Support enabled GIF Create Support enabled JPG Support enabled PNG Support enabled WBMP Support enabled 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.