Forum Moderators: coopster

Message Too Old, No Replies

Imagettftext and baseline deviation

         

ocon

12:54 am on May 21, 2015 (gmt 0)

10+ Year Member Top Contributors Of The Month



I'm creating an image using GD and Image Functions.

In the image is a string of dynamic text using imagettftext and a ttf font.

My problem is positioning the text. Imagettftext uses the font baseline but I need to position the font using the very left edge of the string, and the very bottom of the string.

If I can calculate the shift I can adjust imagettftext accordingly but I can't figure out how to calculate how much to the left or right of the baseline the string is, and how much below or above the baseline the string goes.

I know I'm able to calculate the overall width and height of the text using imagettfbbox, and that has been very useful, but I'm not able to get how much of a shift is in the string.

whitespace

3:49 pm on May 28, 2015 (gmt 0)

10+ Year Member Top Contributors Of The Month



Did you get anywhere with this?

...left or right of the baseline


Left or Right? I would have thought you can only be "above" or "below" the baseline?

Are you using a variable font and size?

My only thought is to try and precalculate this? If the font/size is variable then maybe write some code that scans the position of the lowercase "p" within a defined area. You know that the "bowl" of the "p" sits on the baseline and the tail descends below it. (?)