|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2008-06-04 14:24 UTC] heyond at yahoo dot com dot cn
Description: ------------ I try to create a font image from ttf file, but I encounted a error : Warning: imagettftext() [function.imagettftext]: Unable to find a CharMap that I can handle in D:\www\mvc\ttf2.php on line 49 only few ttf file like this, I guess the freetypes version too lower. Reproduce code: --------------- imagettftext($im, $fontsize, 0, $x, $y, $fgcolor, $fontfile, 'abc'); Expected result: ---------------- a binary image. Actual result: -------------- Warning: imagettftext() [function.imagettftext]: Unable to find a CharMap that I can handle in D:\www\guomo.com\ttf.php on line 33 ??JFIF?>CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), default quality ?C $.' ",#(7),01444'9=82<.342?C 2!!22222222222222222222222222222222222222222222222222?(J"? ??}!1AQa"q2???#B??R??$3br? %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz????????????????????????????????????????????????????????????????????????? ??w!1AQaq"2?B???? #3R?br?$4??&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz????????????????????????????????????????????????????????????????????????? ??J(??͂????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 19:00:01 2025 UTC |
The completed script is: <?php define('BG1', 'DDD4BB'); header("Content-type: image/jpeg"); $word = 'abc';//$word = '????' $wordnum = 6; $word = iconv('GBK', 'UTF-8', $word); //$fontfile = './data/fonts/1.ttf';//http://www.guomo.com/data/fonts/1.ttf This file '1.ttf' is normal $fontfile = './data/fonts/174.ttf';//http://www.guomo.com/data/fonts/174.ttf This file '174.ttf' is abnormal $width = 30 $height = 40; $fontsize = 20; $x = 0; $y = $fontsize + 10; $im = imagecreate($wordnum * $width, $height); $bgcolor = imagecolorallocate($im, hexdec(substr(BG1, 0, 2)), hexdec(substr(BG1, 2, 2)), hexdec(substr(BG1, 4, 2))); $fgcolor = imagecolorallocate($im, 0, 0, 0); imagefill($im, 0, 0, $bgcolor); imagettftext($im, $fontsize, 0, $x, $y, $fgcolor, $fontfile, $word); imagejpeg($im); imagedestroy($im); exit; ?>