When I prescribe the path to the font in the ImageTFFTEXT () function;
An ill-fated error
appears
imagettftext (); COULD NOT FIND / OPEN FONT
Code (PHP 7.2):
$ black = imagecolorallocate ($ im, 0, 0, 0);
$ font = "./arial.tff";
ImageTTFTEXT (ImageCreaTeeColor (400, 30), 20, 0, 10, 20, $ Black, $ font, "text");
How to fix it?
Answer 1, Authority 100%
from documentation :
In many cases, when the font is in the same directory as
PHP script will help the next trick.& lt;? php // Setting Variable Environment for GD Putenv ('Gdfontpath ='. Realpath ('.')); // Font name for use (Note that the extension .ttf is not specified) $ font = 'somefont';
You can try to transfer the absolute path to the font:
$ font = realpath ('./ arial.ttf');
or
$ font = __dir __. '/ arial.ttf';