|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2017-12-08 19:04 UTC] momchil at bojinov dot info
Description: ------------ Hello, I have a small repo here: https://github.com/bozhinov/pChart2.0-for-PHP7 I tested all of the code with PHP 7.1.11 x64 TS on a Windows 10 x64 machine and all was fine I then updated the php distribution to 7.1.12 x64 TS and started getting warnings: arning: imagettftext(): Could not find/open font in X:\SVN\External\pChart-dev\pChart\pDraw.php on line 1117 I can solve it by calling the function with realpath($ttfpath) instead The process monitor says that it finds the font OK but then starts looking at the Windows fonts folder and fails because these fonts are not there Please fix Momchil Test script: --------------- To induce it, download the release 2.2.0 please PHP distribution in the root folder and call any of the examples e.g. php.exe examples\example.cache.php Expected result: ---------------- Nothing Actual result: -------------- Warning: imagettfbbox(): Could not find/open font in X:\SVN\External\pChart-dev\pChart\pDraw.php on line 4878 Warning: imagettftext(): Could not find/open font in X:\SVN\External\pChart-dev\pChart\pDraw.php on line 1117 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 17:00:01 2025 UTC |
(My english is not well) I have expierenced this issue today, and I found a workaround. Description: ------------ My OS is Windows 10 *Chinese Traditional* and Web Server is IIS, when I changed PHP version from v7.0.29 to v7.1.23, I got this warning: Warning: imageftbbox(): Could not find/open font in D:\projects\中文路徑\vendor\dapphp\securimage\securimage.php on line 1952 If I switch back to PHP v7.0, no error happened. My font real path ($ttfpath) is 'D:\projects\中文路徑\vendor\dapphp\securimage\AHGBold.ttf'. I tried 'realpath($ttfpath)' but not working, finally I found a key point 'character encoding'. So, I tried: $ttfpath = 'D:\projects\中文路徑\vendor\dapphp\securimage\AHGBold.ttf'; $ttfpath = mb_convert_encoding($ttfpath, 'big5', 'utf-8'); It is working, no error happened. Conclusion: ------------ If: 'OS is Windows' && 'PHP 7.1+' && 'filepath contain non ASCII characters' Try: convert filepath string encoding before you pass to GD imageftbbox() and imagettftext(). Note: Maybe GD Library called a Windows File system API but that don't accept UTF8 encoding?