📄 function.imagefttext.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Write text to the image using fonts using FreeType 2</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.imageftbbox.html">imageftbbox</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.imagegammacorrect.html">imagegammacorrect</a></div> <div class="up"><a href="ref.image.html">GD Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="function.imagefttext" class="refentry"> <div class="refnamediv"> <h1 class="refname">imagefttext</h1> <p class="verinfo">(PHP 4 >= 4.0.7, PHP 5)</p><p class="refpurpose"><span class="refname">imagefttext</span> — <span class="dc-title">Write text to the image using fonts using FreeType 2</span></p> </div> <div class="refsect1 description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">array</span> <span class="methodname"><b><b>imagefttext</b></b></span> ( <span class="methodparam"><span class="type">resource</span> <tt class="parameter">$image</tt></span> , <span class="methodparam"><span class="type">float</span> <tt class="parameter">$size</tt></span> , <span class="methodparam"><span class="type">float</span> <tt class="parameter">$angle</tt></span> , <span class="methodparam"><span class="type">int</span> <tt class="parameter">$x</tt></span> , <span class="methodparam"><span class="type">int</span> <tt class="parameter">$y</tt></span> , <span class="methodparam"><span class="type">int</span> <tt class="parameter">$color</tt></span> , <span class="methodparam"><span class="type">string</span> <tt class="parameter">$fontfile</tt></span> , <span class="methodparam"><span class="type">string</span> <tt class="parameter">$text</tt></span> [, <span class="methodparam"><span class="type">array</span> <tt class="parameter">$extrainfo</tt></span> ] )</div> </div> <div class="refsect1 parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt><span class="term"><i><tt class="parameter">image</tt></i></span><dd><p class="para">An image resource, returned by one of the image creation functions, such as <a href="function.imagecreatetruecolor.html" class="function">imagecreatetruecolor()</a>.</p></dd></dt> <dt> <span class="term"><i><tt class="parameter">size</tt></i></span> <dd> <p class="para"> The font size to use in points. </p> </dd> </dt> <dt> <span class="term"><i><tt class="parameter">angle</tt></i></span> <dd> <p class="para"> The angle in degrees, with 0 degrees being left-to-right reading text. Higher values represent a counter-clockwise rotation. For example, a value of 90 would result in bottom-to-top reading text. </p> </dd> </dt> <dt> <span class="term"><i><tt class="parameter">x</tt></i></span> <dd> <p class="para"> The coordinates given by <i><tt class="parameter">x</tt></i> and <i><tt class="parameter">y</tt></i> will define the basepoint of the first character (roughly the lower-left corner of the character). This is different from the <a href="function.imagestring.html" class="function">imagestring()</a>, where <i><tt class="parameter">x</tt></i> and <i><tt class="parameter">y</tt></i> define the upper-left corner of the first character. For example, "top left" is 0, 0. </p> </dd> </dt> <dt> <span class="term"><i><tt class="parameter">y</tt></i></span> <dd> <p class="para"> The y-ordinate. This sets the position of the fonts baseline, not the very bottom of the character. </p> </dd> </dt> <dt> <span class="term"><i><tt class="parameter">color</tt></i></span> <dd> <p class="para"> The index of the desired color for the text, see <a href="function.imagecolorexact.html" class="function">imagecolorexact()</a>. </p> </dd> </dt> <dt> <span class="term"><i><tt class="parameter">fontfile</tt></i></span> <dd> <p class="para"> The path to the TrueType font you wish to use. </p> <p class="para"> Depending on which version of the GD library PHP is using, <em class="emphasis">when <i><tt class="parameter">fontfile</tt></i> does not begin with a leading <i>/</i> then <i>.ttf</i> will be appended</em> to the filename and the library will attempt to search for that filename along a library-defined font path. </p> <p class="para"> When using versions of the GD library lower than 2.0.18, a <i>space</i> character, rather than a semicolon, was used as the 'path separator' for different font files. Unintentional use of this feature will result in the warning message: <i>Warning: Could not find/open font</i>. For these affected versions, the only solution is moving the font to a path which does not contain spaces. </p> <p class="para"> In many cases where a font resides in the same directory as the script using it the following trick will alleviate any include problems. <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB"><?php<br /></span><span style="color: #FF8000">// Set the enviroment variable for GD<br /></span><span style="color: #0000BB">putenv</span><span style="color: #007700">(</span><span style="color: #DD0000">'GDFONTPATH=' </span><span style="color: #007700">. </span><span style="color: #0000BB">realpath</span><span style="color: #007700">(</span><span style="color: #DD0000">'.'</span><span style="color: #007700">));<br /><br /></span><span style="color: #FF8000">// Name the font to be used (note the lack of the .ttf extension)<br /></span><span style="color: #0000BB">$font </span><span style="color: #007700">= </span><span style="color: #DD0000">'SomeFont'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?></span></span></code></div> </div> </p> </dd> </dt> <dt>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -