RoninStretch Posted August 30, 2007 Share Posted August 30, 2007 I'm trying to find out how to center the text I write on images using GD. Im using imagettftext to write on the image. Which i give a point size for the font. But imagettfbbox want's a pixel width of the font. :s anyone? Quote Link to comment Share on other sites More sharing options...
Jessica Posted August 30, 2007 Share Posted August 30, 2007 What exactly are you trying to do? Did you look at the comments on the imagettfbbox page? There are a ton of helpful functions posted. Quote Link to comment Share on other sites More sharing options...
RoninStretch Posted August 30, 2007 Author Share Posted August 30, 2007 I looked yeah but i'm quite new and the advanced coding techniques they use make most of it illegible. What i'm trying to do is just center my text. So $imageX = 100; // pixels $fontwidth = 5; // pixels per character $textlength = 10; // 10 characters $textlengthpx = $fontwidth * $textlength; $topleft = ($imageX - $textlengthpx) / 2; or somethin... I just need to know how to get the pixel width of a ttf font. Quote Link to comment Share on other sites More sharing options...
Barand Posted August 30, 2007 Share Posted August 30, 2007 But imagettfbbox want's a pixel width of the font. :s No, it wants the point size (how big do want it?) that you are using with the font then returns the x,y coordinates of the corners of a rectangle that would contain the text Quote Link to comment Share on other sites More sharing options...
RoninStretch Posted August 30, 2007 Author Share Posted August 30, 2007 if you guys say so i'll give it a bash.. but the manual says "size - The font size in pixels " Quote Link to comment Share on other sites More sharing options...
RoninStretch Posted August 30, 2007 Author Share Posted August 30, 2007 Yeah got it.. Thanks guys. Stupid Php Manual. 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.