Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jan 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation GD library imagettftext funtion help

    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;

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,471
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    With the TTF method ...
    Did you define the TTF file to use? And indicate the path and filename to that?
    Not enough of the code listed for us to determine that (if you did).

  • #3
    New to the CF scene
    Join Date
    Jan 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by mlseim View Post
    With the TTF method ...
    Did you define the TTF file to use? And indicate the path and filename to that?
    Not enough of the code listed for us to determine that (if you did).
    i tried with static ttf path but same result.

  • #4
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,471
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    Did you view the manual?
    http://php.net/manual/en/function.imagettftext.php

    It looks to me that the $image ($imgChar in your case), has to be Quote:
    An image resource, returned by one of the image creation functions, such as imagecreatetruecolor().


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •