Jump to content

Recommended Posts

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;

Link to comment
https://forums.phpfreaks.com/topic/189732-gd-library-imagettftext-funtion-help/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.