note 25192 added to function.imagefttext

From: Date: Fri, 13 Sep 2002 17:18:48 +0000
Subject: note 25192 added to function.imagefttext
Groups: php.notes 
Request: Send a blank email to php-notes+get-36639@lists.php.net to get a copy of this message
Here's a useful script for testing how well your compilation of PHP with the GD and FREETYPE 2 libraries is working. <?PHP // // testgdfont.php (c) 2002 by Edward H. Trager <ehtrager@umich.edu> // // Under GPL -- See www.gnu.org // // This script tests some of the capabilities of the FreeType 2 // font rendering library under GD in PHP: // // // Make the image big enough to be able to really see some different things: // $i_width = 700; $i_height =300; $string = "Hello World!"; $pointsize = 25; // // Obviously, you need to specify fonts relevant on your system: // $fontfile="/usr/local/fonts/truetype/graver.ttf"; // // Create image: // $image = imagecreate($i_width, $i_height); $backcolor = imagecolorallocate ($image, 128,128,85); $forecolor = imagecolorallocate ($image, 255, 255, 255); $forecolor2= imagecolorallocate ($image, 255,128,0); // // IMAGEFTBBOX() // // array imageftbbox ( int size, int angle, string font_file, string text [, array extrainfo]) // // Well, this is only here as a reminder to myself on how to use it; // $string_size is not actually used in this script: // $string_size = Imageftbbox($pointsize, 0, $fontfile, $string); $s_width = $string_size[4]; $s_height = $string_size[5]; // // IMAGEFTTEXT() // // NOTE BENE: As far as I can tell, you CANNOT even pass the "array extrainfo" parameter // and have anything work. I tested this using PHP 4.2.3, GD 2.0.1, and FREETYPE 2.1.2. // (2002.09.13 -- or is it only because it was Friday the 13th that it didn't work?) // // array imagefttext ( resource image, int size, int angle, int x, int y, int col, // string font_file, string text [, array extrainfo]) // // // Text at an angle: // ImageFtText($image,$pointsize, 15, 5,125,$forecolor2,$fontfile,$string); // // Waterfall of point sizes to see what Freetype 2's autohinting looks like: // for($i=4;$i<=12;$i++){ ImageFtText($image,$i,0,10,(100+$i*14),$forecolor,$fontfile, $i . ". " . $string); } // // Let's test some UTF-8! // // // The free cyberbit font contains many scripts -- Download from // ftp://ftp8.netscape.com/pub/communicator/extras/fonts/windows/ // $fontfile="/usr/local/fonts/cyberbit/cyberbit.ttf"; // // This is a quotation from Mozi (Micius): // // My own approximate translation of this is: // // "Saintly men who are interested in governing everything under heaven // must first understand the (seemingly spontaneous) origins of chaos." // $chinese_utf8="聖人以治天下爲事者也必知亂之所自起 -- 墨子 "; ImageFtText($image,$pointsize, 0, 10,45,$forecolor,$fontfile,$chinese_utf8); // // The following is the name of an Egyptian singer, Om Kolthoum: // However, I haven't yet figured out how to render it right-to-left, so it is // currently all messed up. I even tried adding the unicode RIGHT-TO-LEFT-MARK // and RIGHT-TO-LEFT-EMBEDDING, but doesn't seem to work. If anyone knows how // to get this to work, please let me know: // $arabic_utf8="This is incorrectly rendered L->R instead of R->L!: أم كلثوم"; ImageFtText($image,16, 0, 10,80,$forecolor,$fontfile,$arabic_utf8); // // In Thai, we need to see whether Freetype places vowels and tone marks // in the right positions (usually over other letters, but some vowels go under or // before other letters). This really depends on the font being designed right: // // The following is the name of a popular Thai singer: // $thai_utf8="ธงไชย แม็คอินไตย์"; ImageFtText($image,$pointsize, 0, 120,120,$forecolor,$fontfile,$thai_utf8); Header ("Content-type: image/png"); ImagePNG ($image); ImageDestroy ($image); ?> -- http://www.php.net/manual/en/function.imagefttext.php http://master.php.net/manage/user-notes.php?action=edit+25192 http://master.php.net/manage/user-notes.php?action=delete+25192 http://master.php.net/manage/user-notes.php?action=reject+25192

« previous php.notes (#36639) next »