This post was last edited by sz07551com on 2013-06-28 14:01:05
PHP text watermark
PHP text watermark with Imagettftext do, how to calculate the width of the text of the high??
Reply to discussion (solution)
If the text rotation angle is not considered,
$width =strlen ($text) * $font _size; $height = $font _size;
The above calculation only applies to the equal width font, see: Imagettfbbox () function, it can solve your needs, including angle
Imagettfbbox--Gets the range of text using TrueType fonts
Array imagettfbbox (float size, float angle, st Ring Fontfile, string text)
This function calculates and returns the pixel size of a virtual box that surrounds the TrueType text range. The font size of the
size pixel unit. The size of the angle
angle text will be measured. The file name of the
fontfile TrueType font file (which can be a URL). The
text string to measure.
Imagettfbbox () returns an array of 8 cells representing four corners of the text box:
0 lower left x position
1 lower left corner y position
2 lower right x position
3 lower right corner y position
4 upper right X position
5 upper right Y position
6 upper left corner x position
7 upper left Y position
These points are relative to the text and are angle independent, so the upper left corner refers to the upper-left corner of the text when viewed horizontally.
Imagettfbbox--Get the range of text using TrueType fonts
Array Imagettfbbox (float size, float angle, string fontfile, string text)
This function calculates and returns the pixel size of a virtual box that surrounds the TrueType text range.
The font size of a size pixel unit.
Angle text will be measured by the angle size.
Fontfile the file name of the TrueType font file (which can be a URL).
The text string to measure.
Imagettfbbox () returns an array of 8 cells representing the four corners of the text outer frame:
0 lower left corner X position
1 lower left corner Y position
2 lower right corner X position
3 lower right corner Y position
4 upper right corner X position
5 upper right corner Y position
6 upper left corner X position
7 upper left corner Y position
These points are relative to the text and are independent of the angle, so the upper left corner refers to the upper-left corner of the text when viewed horizontally.
8 parameters, I do not how to use,
Can you write a handler function? Thank you
(6,7) (4,5) Text (0,1) (2,3)