Answer the question
In order to leave comments, you need to log in
Where do the negative values come from in the output of the imagettfbbox() function?
Hello colleagues!
I don't understand where the negative values come from in the output of the imagettfbbox() function. I know that the countdown is from the beginning of the baseline, but for some reason the higher the angle, the smaller the Y value. Why is that? And why is the lower left corner not equal to 0?
For example, why does the following code produce such a result?
<?php
//$im = imagecreatefromjpeg("photo.jpg");
$bbox = imagettfbbox(30, 0, 'C:/Windows/Fonts/Arial.ttf', "Наша дружная компания");
foreach ($bbox as $key => $value) {
echo "$key = $value <br>";
}
?>
0 = 3
1 = 8
2 = 460
3 = 8
4 = 460
5 = -29
6 = 3
7 = -29
Answer the question
In order to leave comments, you need to log in
Everything is very simple. In GD, coordinates are usually measured from the upper left corner of the image.
In this case, X grows from left to right, and Y from top to bottom.
And in the case of imagettfbbox, the starting point (0,0) is the lower left corner, which is quite true for a textbox. And measuring up from this point, we move along Y in a negative direction.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question