J
J
JackShcherbakov2018-03-26 05:17:08
PHP
JackShcherbakov, 2018-03-26 05:17:08

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>";
}
?>

Conclusion:
0 = 3 
1 = 8 
2 = 460 
3 = 8 
4 = 460 
5 = -29 
6 = 3 
7 = -29

This means the following, but why so?
5ab858238c0b3775183601.jpeg
I would like to thank everyone in advance who will help.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sanovskiy, 2018-03-26
@Sanovskiy

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 question

Ask a Question

731 491 924 answers to any question