Re: how to enable ttf support in php 5.2.9

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jim Lucas wrote:
> PJ wrote:
>> Is there a module to be activated or what has to be installed to have
>> ttf support in php?
>> My port on FreeBSD does not have an option for ttf support under make
>> config .
>> I'm trying to learn & understand the following:
>> In file1 : <img src="button.php?s=36&text=PHP+is+Cool" />
>> In file2 (button.php)- originally php3 :
>> <?php
>>   Header("Content-type: image/gif");
>>   if(!isset($s)) $s=11;
>
> The above should be:
>
> if ( empty($_GET['s']) ) {
>     $s = 11;
> } else {
>     $s = (int)$_GET['s'];
> }
>
>>   $size = imagettfbbox($s,0,"times.ttf",$text);
>
> and this should be
>
> $text = '';
> if ( !empty($_GET['text']) )
>     $text = your_custom_input_cleaner_function($_GET['text']);
>
> $size = imagettfbbox($s,0,"times.ttf",$text);
>
>>   $dx = abs($size[2]-$size[0]);
>>   $dy = abs($size[5]-$size[3]);
>>   $xpad=9;
>>   $ypad=9;
>>   $im = imagecreate($dx+$xpad,$dy+$ypad);
>>   $blue = ImageColorAllocate($im, 0x2c,0x6D,0xAF);
>>   $black = ImageColorAllocate($im, 0,0,0);
>>   $white = ImageColorAllocate($im, 255,255,255);
>>   ImageRectangle($im,0,0,$dx+$xpad-1,$dy+$ypad-1,$black);
>>   ImageRectangle($im,0,0,$dx+$xpad,$dy+$ypad,$white);
>>   ImageTTFText($im, $s, 0, (int)($xpad/2)+1, $dy+(int)($ypad/2), $black,
>> "times.ttf", $text);
>>   ImageTTFText($im, $s, 0, (int)($xpad/2), $dy+(int)($ypad/2)-1, $white,
>> "times.ttf", $text);
>>   ImageGif($im);
>>   ImageDestroy($im);
>> ?>
>> ONLY the above & nothing else. So far, all I get is a small blue square.
>> Replacing the $text with the text just gives a rectangle a bit wider.
>> gd is installed but ttf is not, so I figure that is the culprit.
>> But how is the text supposed to be assigned to $text from file1?
>> TIA
Thank you for that. Now it works. I see, the $s had to come from
somewhere...
But what's the custom_cleaner_function - I mean, to clean what? & Why?
What if I use some foreign accents, like &eacute; or  &Agrave; ?

-- 
Hervé Kempf: "Pour sauver la planète, sortez du capitalisme."
-------------------------------------------------------------
Phil Jourdan --- pj@xxxxxxxxxxxxx
   http://www.ptahhotep.com
   http://www.chiccantine.com/andypantry.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux