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

PHP Home Page

Manual Table of Contents
Up to Graphisme
Quick Reference
English version of this pageGerman version of this pageJapanese version of this pageItalian version of this pageHungarian version of this page
Graphisme
* GetImageSize
* ImageArc
* ImageChar
* ImageCharUp
* ImageColorAllocate
* ImageColorAt
* ImageColorClosest
* ImageColorExact
* ImageColorResolve
* ImageColorSet
* ImageColorsForIndex
* ImageColorsTotal
* ImageColorTransparent
* ImageCopyResized
* ImageCreate
* ImageCreateFromGif
* ImageDashedLine
* ImageDestroy
* ImageFill
* ImageFilledPolygon
* ImageFilledRectangle
* ImageFillToBorder
* ImageFontHeight
* ImageFontWidth
* ImageGif
* ImageInterlace
* ImageLine
* ImageLoadFont
* ImagePolygon
* ImagePSBBox
* ImagePSEncodeFont
* ImagePSFreeFont
* ImagePSLoadFont
* ImagePSText
* ImageRectangle
* ImageSetPixel
* ImageString
* ImageStringUp
* ImageSX
* ImageSY
* ImageTTFBBox
* ImageTTFText
Manual: ImageTTFBBox
View the source code for this pageSearch the site



Previous page
 ImageSY
 Updated
Sun, 06 Aug 2000
ImageTTFText 
Next page


ImageTTFBBox

(unknown)

ImageTTFBBox -- retourne le rectangle entourant un texte et dessiné avec une police TrueType.

Description

array ImageTTFBBox (int size, int angle, string fontfile, string text)

ImageTTFBBox() calcule et retourne le rectangle entourant le texte text, écrit avec une police truetype.

text

La chaîne à mesurer.

size

La taille de la police.

fontfile

Le nom de la police TrueType (peut aussi être une URL.)

angle

Angle en degré dans lequel le texte text va être mesuré.

ImageTTFBBox() retourne une tableau avec 8 éléments, représentants les 4 sommets du rectangle ainsi définis.

0Coin inférieur gauche, abscisse
1Coin inférieur gauche, ordonnée
2Coin inférieur droit, abscisse
3Coin inférieur droit, ordonnée
4Coin supérieur droit, abscisse
5Coin supérieur droit, ordonnée
6Coin supérieur gauche, abscisse
7Coin supérieur gauche, ordonnée

Les positions des points sont relatives au texte text, indépendamment de l'angle : coin supérieur gauche faire référence au coin supérieur gauche du texte écrit horizontalement.

Cette fonction requiert les bibliothèques GD et Freetype.

Voir aussi ImageTTFText().


User Contributed Notes: ImageTTFBBox


barton@applitec.com
21-Dec-1999 06:10
The numbers seem to be baseline relitive. An 'A' for example is all above the base line while a 'j' goes below the baseline. The numbers above the baseline seem to be negitive while the number below seem to be positive. To position text you need to account for the 'drop' below the line. For example:
$ht = $tdy+($ypad)-$drop;
ImageTTFText($im, $s, 0, $ws, $ht, $color, $fontfile, $text);

To get $tdy I did:
$size = imagettfbbox($s,0, $fontfile, $text);
$dx = abs($size[2]-$size[0]);
if($size[1] >= 0)
$drop = $size[1] + 2;

I don't know why I have to add two or why it's >=0 instead of >?



j.schmitz@web.de
22-Feb-2000 01:32
Another solution:
<pre>
$size=ImageTTFBBox($fontsize,0,$font,$text);
$tw=abs($size[4]-$size[0]);
$upper=abs($size[5]);
$under=$size[1];
$th=$upper+$under;
</pre>
$tw - text width, $th - text height, $upper - graphic above baseline, $under - graphic below baseline

This only works with an angle of 0 and one textline (no return/linefeed). To place a text with ImageTTFText() use $ty=$your_y+$upper-2:
<pre>
ImageTTFText($im,$fontsize,0,0,$your_y+$upper-2,$col_draw,$font,$text);
</pre>
-2 is required - seams it uses floats internal

I hope this is true - it works fine here after hundreds of tries and reloads ;-)



 About Notes


Previous page
 ImageSY
 Updated
Sun, 06 Aug 2000
ImageTTFText 
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.