On Mon, 2009-05-04 at 18:42 -0400, PJ wrote: > 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 é or À ? > > -- > Hervé Kempf: "Pour sauver la planète, sortez du capitalisme." > ------------------------------------------------------------- > Phil Jourdan --- pj@xxxxxxxxxxxxx > http://www.ptahhotep.com > http://www.chiccantine.com/andypantry.php > > content coming from MS Office clipboard pastes generally contain characters that are encoded wrong, and do not display correctly in web pages unless they have very relaxed doctypes. The function I generally use is: function removeMSCrap($crap) { $find = Array(chr(128), chr(133), chr(8226), chr(145), chr(8217), chr(146), chr(8220), chr(147), chr(8221), chr(148), chr(8226), chr(149), chr(8211), chr(150), chr(8212), chr(151), chr(8282), chr(153), chr(169), chr(174)); $replace = Array("€", "…", "″", "'", "'", "'", "'", """, """, """, """, "•", "•", "–", "–", "—", "—", "™", "™", "©", "®"); $roses = str_replace($find, $replace, $crap); return $roses; } Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php