Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
Thread: PHP imagettftext not working
03-02-2011, 01:17 PM #1
- Join Date
- Apr 2009
- Thanked 0 Times in 0 Posts
PHP imagettftext not working
On my Linux based server imagettftext not working.
Here is my code,
//ImageTTFText($image, $size, 0, $x, $y, $text_color, '/path/to/font.ttf', 'THIS TEXT WILL BE SHOWN');
// Set the content-type
// Create the image
$im = imagecreatetruecolor(400, 30);
// Create some colors
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 399, 29, $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($im, 20, 0, 10, 20, $white, $font, $text);
// Using imagepng() results in clearer text compared with imagejpeg()
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.
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.
Last edited by jayminkey; 03-02-2011 at 01:38 PM.
03-02-2011, 11:35 PM #2
- Join Date
- Feb 2010
- UK, North West
- Thanked 5 Times in 5 Posts
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.