i'm using GD library 2.0.34 with php 5.2.6 to create image with text. when i use imagettftext function to apply ttf file, then GD generates blank image. but same code is working fine with imagestring function. Please can somebody tell me where is problem. here is code
$len = strlen($str);
$font = "fonts/".$fontFile;
// draw each character individually
for ($i = 0; $i < $len; $i++)
{
// calculate angle along arc
$a = ($aStart * ($len - 1 - $i) + $aEnd * $i) / ($len - 1);
// draw individual character
imagefilledrectangle($imgChar, 0, 0, $xFont, $yFont,$transparent2);
imagettftext($imgChar, $nFont, 0, 0, 0, $textColor, $font,$str[$i]); // not working
// imagestring($imgChar, $nFont, 0, 0, $str[$i], $textColor); //working fine
// rotate character
$imgTemp = imagerotate($imgChar, (int)$a + 90 * ($bCCW ? 1 : -1), $transparent2);
$xTemp = imagesx($imgTemp);
$yTemp = imagesy($imgTemp);
// copy to main image
imagecopy($img, $imgTemp,
$iCentre + $iRadius * cos(deg2rad($a)) - ($xTemp / 2),
$iCentre - $iRadius * sin(deg2rad($a)) - ($yTemp / 2),
0, 0, $xTemp, $yTemp);
}
return $img;
GD library imagettftext funtion help
Moderator: General Moderators
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: GD library imagettftext funtion help
Just a guess, but it probably can't find the font file:
Code: Select all
$font = realpath("fonts/".$fontFile);mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
GD library imagettftext funtion help
i tried with the static path like "fonts/arial.ttf" but in vain. i'm passing font file name in variable $fontFile.AbraCadaver wrote:Just a guess, but it probably can't find the font file:
Code: Select all
$font = realpath("fonts/".$fontFile);