★ wanayoo — archive 1999 http://www.php.net/manual/function.imagettftext.phpNouvelle recherche | Portail wanayoo

PHP Home Page

Manual Table of Contents
Up to Graphics
Quick Reference
German version of this pageJapanese version of this pageItalian version of this pageFrench version of this pageHungarian version of this page
Graphics
* GetImageSize
* ImageArc
* ImageChar
* ImageCharUp
* ImageColorAllocate
* ImageColorDeAllocate
* ImageColorAt
* ImageColorClosest
* ImageColorExact
* ImageColorResolve
* ImageGammaCorrect
* ImageColorSet
* ImageColorsForIndex
* ImageColorsTotal
* ImageColorTransparent
* ImageCopy
* ImageCopyResized
* ImageCreate
* ImageCreateFromGIF
* ImageCreateFromJPEG
* ImageCreateFromPNG
* ImageDashedLine
* ImageDestroy
* ImageFill
* ImageFilledPolygon
* ImageFilledRectangle
* ImageFillToBorder
* ImageFontHeight
* ImageFontWidth
* ImageGIF
* ImagePNG
* ImageJPEG
* ImageInterlace
* ImageLine
* ImageLoadFont
* ImagePolygon
* ImagePSBBox
* ImagePSEncodeFont
* ImagePSFreeFont
* ImagePSLoadFont
* ImagePsExtendFont
* ImagePsSlantFont
* ImagePSText
* ImageRectangle
* ImageSetPixel
* ImageString
* ImageStringUp
* ImageSX
* ImageSY
* ImageTTFBBox
* ImageTTFText
* ImageTypes
* read_exif_data
Manual: ImageTTFText
View the source code for this pageSearch the site



Previous page
 ImageTTFBBox
 Updated
Sat, 12 Aug 2000
ImageTypes 
Next page


ImageTTFText

(unknown)

ImageTTFText --  Write text to the image using TrueType fonts

Description

array imagettftext (int im, int size, int angle, int x, int y, int col, string fontfile, string text)

ImageTTFText() draws the string text in the image identified by im, starting at coordinates x, y (top left is 0, 0), at an angle of angle in color col, using the TrueType font file identified by fontfile.

The coordinates given by x, y will define the basepoint of the first character (roughly the lower-left corner of the character). This is different from the ImageString(), where x, y define the upper-right corner of the first character.

Angle is in degrees, with 0 degrees being left-to-right reading text (3 o'clock direction), and higher values representing a counter-clockwise rotation. (i.e., a value of 90 would result in bottom-to-top reading text).

Fontfile is the path to the TrueType font you wish to use.

Text is the text string which may include UTF-8 character sequences (of the form: {) to access characters in a font beyond the first 255.

Col is the color index. Using the negative of a color index has the effect of turning off antialiasing.

ImageTTFText() returns an array with 8 elements representing four points making the bounding box of the text. The order of the points is upper left, upper right, lower right, lower left. The points are relative to the text regardless of the angle, so "upper left" means in the top left-hand corner when you see the text horizontallty.

This example script will produce a black GIF 400x30 pixels, with the words "Testing..." in white in the font Arial.

Example 1. ImageTTFText


<?php
Header ("Content-type: image/gif");
$im = imagecreate (400, 30);
$black = ImageColorAllocate ($im, 0, 0, 0);
$white = ImageColorAllocate ($im, 255, 255, 255);
ImageTTFText ($im, 20, 0, 10, 20, $white, "/path/arial.ttf", 
              "Testing... Omega: &#937;");
ImageGif ($im);
ImageDestroy ($im);
?>
      

This function requires both the GD library and the FreeType library.

See also ImageTTFBBox().


User Contributed Notes: ImageTTFText


icon@mricon.com
22-Jul-1999 11:46
As it says, to operate TTF fonts, you will need FreeType libraries before you compile PHP. On RedHat Linux systems you need to make sure you have both FreeType and FreeType-devel RPM packages installed. The configure script will locate FreeType libraries and automagically compile with TTF support. Tested on RedHat-6.0 with FreeType-1.2.


icon@mricon.com
22-Jul-1999 11:58
TTF fonts that don't contain a Unicode mapping table won't work. E.g. wingdings... Overall, if your images don't show up and you can't figure out what it is, it's a good idea to quote out Header("Content-type: image/gif") to see if any error information is generated.


brian@bkw.org
27-Sep-1999 11:43
It says you have to recompile apache to add both GD and FreeType to your Apache/PHP... I didnt have too! hmm I wonder why it worked! :)


icon@mricon.com
15-Feb-2000 10:08
For fellow cyrillic users. If you're looking for a way to painlessly make this work with Russian fonts, check out the page I set up: http://www.mricon.com/cyrttf.html


j.schmitz@web.de
22-Feb-2000 12:47
Ok, after wasting my time in finding a hack to disable anti aliasing I found a feature in the source: set a negativ color number and anti aliasing is disabled - simply write ImageTTFText(.....,-$mycolor,....)


kevin@nsane.net
26-Mar-2000 04:34
The aliasing is terrible. I hope freetype2 support comes soon.


imacs@email.com
06-Apr-2000 02:16
to make it support chinese and japaness font,
have a look here.
<a href=/old?u=http%3A%2F%2Fwww.php.net%2Fmanual%2F%26quot%3Bhttp%3A%2Fwww.freshmeat.net%2Fappindex%2F1999%2F12%2F27%2F946305846.html%26quot%3B%26gt%3Bhttp%3A%2Fwww.freshmeat.net%2Fappindex%2F1999%2F12%2F27%2F946305846.html%26lt%3B%2Fa%26gt%3B%3C%2Ftt&y=1999>


natematias@juno.com
28-Jul-2000 06:15
Keep in mind that if you load an external image you need to take your text colors from the external image's pallete using
<pre>$color=imagecolorat($image, $xcoord, $ycoord);</pre>



inane@phreaker.net
30-Jul-2000 05:42
as above, it says to go here to find out how to make php support japanese and chinese support...
well... i can get it to support japanese in EUC only, not in SJIS or JIS... and i cannot get chinese to work at all and i would like korean to work as well... anyone else know any sites or ways to add chinese, japanese, and korean support?



soojin001@kebi.com
07-Aug-2000 10:28
¿©±â¿¡ ¾ÆÁ÷ ÇѱÛÀº º¸ÀÌÁö ¾Ê³×¿ä..
imagettftext() ÇÔ¼ö¿¡ °üÇØ¼­ ¾Ë¾Æº¸´Â Áß¿¡
¿©±â ±îÁö ¿Ô´Âµ¥....¸îÀÚ ³²±â°í°©´Ï´Ù...

Be Happy !!




soojin001@kebi.com
07-Aug-2000 10:33
Á¶±ÝÀü¿¡ ±ÛÀ» Àû¾ú´Âµ¥ ¾Èº¸À̳׿ä..
imagettftext() ÇÑ±Û Áö¿ø¿¡ °üÇØ¼­...
http://my.netian.com/~mischoi/mischoi.zip
ÀÌ ÆÄÀÏ ¹Þ¾Æ º¸¼¼¿ä..gif ÇѱÛÀÌ °¡´É ÇØÁú°Ì´Ï´Ù.Àúµµ ´Ù¿î ¹ÞÀº °Ì´Ï´Ù. Àü ´Ù¸¥ ¹®Á¦ ¶§¹®¿¡ ¿©±â ¿Ô´Âµ¥....



 About Notes


Previous page
 ImageTTFBBox
 Updated
Sat, 12 Aug 2000
ImageTypes 
Next page





Who's responsible for this?
Top of this page

Site
Hosting:



Located in
United States
Elements of this website are subject to copyright.
Questions about installing or using PHP should be directed to one of the mailing lists.
Only questions about the website should be directed to webmaster@php.net.