What is the path to the fonts directory?
Some scripts you install may want to use font files on the server to generate text in images.
Here is the directory where fonts are stored on our servers:
You will probably want to use TrueType fonts, which are in a sub-directory:
The Microsoft "core" fonts (including Arial, Comic Sans, Courier New, Georgia, Impact, Times New Roman, Trebuchet, Verdana, and Webdings) are here:
And the commonly used "FreeFont" fonts are here:
Why do I get a "Could not find/open font" PHP error?
Some PHP functions, particularly imagefttext and imageftbbox, have trouble finding font files that are specified without a "full path".
For example, the following line of PHP code will not work on many PHP servers, including ours:
$font = "arial.ttf"; imagefttext($image, 10, 0, 0, 0, $black, $font, "Test");
If you try that, you'll get an error message saying something like "Warning: imagettftext() [function.imagettftext]: Could not find/open font in /var/www/html/ex/example.com/script.php".
There are several ways to fix this. You can usually just add "./" to the beginning of the font name, like this:
$font = "./arial.ttf";
Alternately, you can make PHP use the full path:
$font = "/var/www/html/ex/example.com/arial.ttf";
Either of these approaches should fix the problem.
Copyright © 2000-2023 Tiger Technologies LLC