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 2 of 2
  1. #1
    New Coder
    Join Date
    Apr 2009
    Location
    Ahmedabad,India
    Posts
    54
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Unhappy PHP imagettftext not working

    Hi,

    On my Linux based server imagettftext not working.

    Here is my code,
    PHP Code:

                
    //ImageTTFText($image, $size, 0, $x, $y, $text_color, '/path/to/font.ttf', 'THIS TEXT WILL BE SHOWN');
                //imagettftext(
                // Set the content-type
                
    header('Content-type: image/png');            
                
    // Create the image
                
    $im imagecreatetruecolor(40030);            
                
    // Create some colors
                
    $white imagecolorallocate($im255255255);
                
    $grey imagecolorallocate($im128128128);
                
    $black imagecolorallocate($im000);
                
    imagefilledrectangle($im0039929$white);            
                
    // The text to draw
                
    $text 'Testing';
                
    // Replace path by your own font path
                
    $font 'customfonts/FrangipaniRose.ttf';            
                
    // Add some shadow to the text
                //imagettftext($im, 20, 0, 11, 21, $grey, $font, $text);            
                // Add the text
                
    imagettftext($im2001020$white$font$text);            
                
    // Using imagepng() results in clearer text compared with imagejpeg()
                
    imagepng($im);
                
    imagedestroy($im); 
    It is showing me as some ascii characters.

    i have uploaded font using Web Base FTP tool.

    I went though different forums and according to that also try to upload font as binary file but on my server do not have facility to upload as binary file.

    FYI,
    I am using Parallels Plesk Control Panel.
    Also i have checked my GD Support
    GD Version = 2.0.34
    GIF Read Support enabled
    GIF Create Support enabled
    JPG Support enabled
    PNG Support enabled
    WBMP Support enabled
    XBM Support enabled

    Can anyone please help me in this.

    Thanks,
    Jaymin
    Last edited by jayminkey; 03-02-2011 at 01:38 PM.

  • #2
    New Coder
    Join Date
    Feb 2010
    Location
    UK, North West
    Posts
    36
    Thanks
    0
    Thanked 5 Times in 5 Posts
    Hello,
    I've never tried using custom fonts on the GD class but I have a feeling it may not be working for the following:

    A) Fonts are not installed on the linux box.
    B) Fonts may require a full absolute path passing in the function.

    Give those a try to see if it solves it.

    Regards,
    Shaun


  •  

    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
    •