Setting the font path using PHP's environment variable GDFONTPATH is not valid?

[problems encountered]

when drawing with PHP"s GD library, the font path variable is set as follows, and the image cannot be output:

putenv("GDFONTPATH=C:\Windows\Fonts");
$fontname="arial.ttf";
imagettftext($im,$font_size,0,$text_x,$text_y,$font_color,$fontname,$text);

but if you write down the path directly, everything will be fine:

$fontname="C:\Windows\Fonts\arial.ttf";
imagettftext($im,$font_size,0,$text_x,$text_y,$font_color,$fontname,$text);

[Test Environment]
operating system: Windows 10 Family Chinese version 1803
PHP version: PHP5.6.12

I searched around and saw that someone said that the GDFONTPATH environment variable was not supported by Windows. Is that true?

Php
Mar.23,2021

Don't use arial.ttf , just try arial .

Menu