📄 function.imageloadfont.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Load a new font</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.imageline.html">imageline</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.imagepalettecopy.html">imagepalettecopy</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.imageloadfont" class="refentry"> <div class="refnamediv"> <h1 class="refname">imageloadfont</h1> <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">imageloadfont</span> — <span class="dc-title">Load a new font</span></p> </div> <div class="refsect1 description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">int</span> <span class="methodname"><b><b>imageloadfont</b></b></span> ( <span class="methodparam"><span class="type">string</span> <tt class="parameter">$file</tt></span> )</div> <p class="para rdfs-comment"> <b>imageloadfont()</b> loads a user-defined bitmap and returns its identifier. </p> </div> <div class="refsect1 parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><i><tt class="parameter">file</tt></i></span> <dd> <p class="para"> The font file format is currently binary and architecture dependent. This means you should generate the font files on the same type of CPU as the machine you are running PHP on. </p> <p class="para"> <table border="5"> <caption><b>Font file format</b></caption> <colgroup> <thead valign="middle"> <tr valign="middle"> <th colspan="1">byte position</th> <th colspan="1">C data type</th> <th colspan="1">description</th> </tr> </thead> <tbody valign="middle" class="tbody"> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">byte 0-3</td> <td colspan="1" rowspan="1" align="left">int</td> <td colspan="1" rowspan="1" align="left">number of characters in the font</td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">byte 4-7</td> <td colspan="1" rowspan="1" align="left">int</td> <td colspan="1" rowspan="1" align="left"> value of first character in the font (often 32 for space) </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">byte 8-11</td> <td colspan="1" rowspan="1" align="left">int</td> <td colspan="1" rowspan="1" align="left">pixel width of each character</td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">byte 12-15</td> <td colspan="1" rowspan="1" align="left">int</td> <td colspan="1" rowspan="1" align="left">pixel height of each character</td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">byte 16-</td> <td colspan="1" rowspan="1" align="left">char</td> <td colspan="1" rowspan="1" align="left"> array with character data, one byte per pixel in each character, for a total of (nchars*width*height) bytes. </td> </tr> </tbody> </colgroup> </table> </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> The font identifier which is always bigger than 5 to avoid conflicts with built-in fonts or <b><tt>FALSE</tt></b> on errors. </p> </div> <div class="refsect1 examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example"> <p><b>Example #1 <b>imageloadfont()</b> usage example</b></p> <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB"><?php<br /></span><span style="color: #FF8000">// Create a new image instance<br /></span><span style="color: #0000BB">$im </span><span style="color: #007700">= </span><span style="color: #0000BB">imagecreatetruecolor</span><span style="color: #007700">(</span><span style="color: #0000BB">50</span><span style="color: #007700">, </span><span style="color: #0000BB">20</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$black </span><span style="color: #007700">= </span><span style="color: #0000BB">imagecolorallocate</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$white </span><span style="color: #007700">= </span><span style="color: #0000BB">imagecolorallocate</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">, </span><span style="color: #0000BB">255</span><span style="color: #007700">, </span><span style="color: #0000BB">255</span><span style="color: #007700">, </span><span style="color: #0000BB">255</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// Make the background white<br /></span><span style="color: #0000BB">imagefilledrectangle</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">49</span><span style="color: #007700">, </span><span style="color: #0000BB">19</span><span style="color: #007700">, </span><span style="color: #0000BB">$white</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// Load the gd font and write 'Hello'<br /></span><span style="color: #0000BB">$font </span><span style="color: #007700">= </span><span style="color: #0000BB">imageloadfont</span><span style="color: #007700">(</span><span style="color: #DD0000">'./04b.gdf'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">imagestring</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">, </span><span style="color: #0000BB">$font</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #DD0000">'Hello'</span><span style="color: #007700">, </span><span style="color: #0000BB">$black</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// Output to browser<br /></span><span style="color: #0000BB">header</span><span style="color: #007700">(</span><span style="color: #DD0000">'Content-type: image/png'</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">imagepng</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">imagedestroy</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></span></span></code></div> </div> </div> </p> </div> <div class="refsect1 seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"><a href="function.imagefontwidth.html" class="function" rel="rdfs-seeAlso">imagefontwidth()</a></li> <li class="member"><a href="function.imagefontheight.html" class="function" rel="rdfs-seeAlso">imagefontheight()</a></li> </ul> </p> </div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.imageline.html">imageline</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.imagepalettecopy.html">imagepalettecopy</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></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -