|
|
 |
imagefttext (PHP 4 >= 4.1.0, PHP 5) imagefttext -- Write text to the image using fonts using FreeType 2 Descriptionarray imagefttext ( resource image, float size, float angle, int x, int y, int col, string font_file, string text [, array extrainfo] )
| Warning | This function is
currently not documented; only the argument list is
available. |
Note: This function requires GD 2.0.1 or later.
Note:
Parameter extrainfo is optional since PHP 4.3.5.
User Contributed Notes
imagefttext
MagicalTux at FF dot st
27-Jan-2005 04:20
When compiling PHP with FreeType 2 support, you'll probably have some problems if - for example - you use debian and didn't compile freetype2 yourself...
If configure fails after saying "If configure fails, try --with-xpm-dir..." you most likely have FreeType1 installed, but not freetype2 ...
Do this as root :
apt-get install libfreetype6-dev
It took me some time to find out that apt-get install freetype2 is actually installing freetype1 ...
kagaku at gmail dot com
07-Dec-2004 10:27
I found myself in need of an align right function and found one on the imagepstext manual page. I can't imagine I'm the only person who's needed to use this, so here's a slightly modified version that works with imagefttext:
<?
function align_right($string, $fontfile, $imgwidth, $fontsize){
$spacing = 0;
$line = array("linespacing" => $spacing);
list($lx,$ly,$rx,$ry) = imageftbbox($fontsize,0,$fontfile,$string,$line);
$textwidth = $rx - $lx;
$imw = ($imgwidth-10-$textwidth);
return $imw;
}
?>
eshenk at comcast dot net
24-Jan-2004 04:05
I wrote a bit of code to gather all the .ttf files in the directory with this script, and randomize them to write text on a header image for my site. The only catch is the font files have to be named 1.ttf, 2.ttf etc etc.
<?php
srand((double)microtime()*1234567); $image = imagecreatefromjpeg(rand(1,exec('ls *.jpg | wc -l')) . ".jpg"); $font = rand(1,exec('ls *.ttf | wc -l')) . ".ttf"; $textcolor = imagecolorallocate($image,0,0,0); $text1 = "shenko.homedns.org"; imagettftext($image, 50, 0, 20, 50, $textcolor, $font, $text1); header("Content-type: image/jpeg"); imagejpeg($image,'',90); imagedestroy($image); ?>
sebastiand at gmx dot de
17-Sep-2003 04:07
After spending the evening with some work on automatically generated images, I had the idea to switch of anti-aliasing (looking, if some font would look better that way), which turned out not to be quite so easy.
Actually you have to use the negative of the desired color to switch of antialising. I include the corresponding line from my code (line split up):
// USE NEGATIVE OF DESIRED COLOR TO SWITCH OF ANTI-ALIASING
ImageFTText ($neuesBild,$fontsize,$fontangle,$TextPosX,$TextPosY,
-$custom_fg,$fonttype,$text,array());
jwilliam at kcr dot uky dot edu
21-Nov-2002 02:22
Thanks for the script! I modified it to show several fonts that I was wanting to use. I am using GD-2.0.7, FreeType-2.1.3(text rotation fix,among others), and PHP-4.2.3 and had to include the array information to get it to work.
Code change follows:
$fontfile="/usr/local/fonts/ttf/bookantbd.ttf";
// Waterfall of point sizes to see what Freetype 2's autohinting looks like:
//
for($i=4;$i<=12;$i++){
ImageFtText($image,$i,0,10,(280+$i*14),$forecolor,$fontfile, bookantbd . $i . ". " . $string, array("linespacing" => 1.0));
}
John
ben at tNOSPAManjNOSPAMo dot cnospamordots dot om
08-Aug-2002 02:59
If you're interested in turning off FreeType hinting, search for the following line in the gd source (gdft.c):
err = FT_Load_Glyph (face, glyph_index, FT_LOAD_DEFAULT);
and replace it with
err = FT_Load_Glyph (face, glyph_index, FT_LOAD_NO_HINTING);
Recompile GD, and voìla: beauteous antialiasing.
| |