<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.image.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'zh',
  ),
  'this' => 
  array (
    0 => 'function.imagefontwidth.php',
    1 => 'imagefontwidth',
    2 => '获取字体宽度',
  ),
  'up' => 
  array (
    0 => 'ref.image.php',
    1 => 'GD 和图像处理 函数',
  ),
  'prev' => 
  array (
    0 => 'function.imagefontheight.php',
    1 => 'imagefontheight',
  ),
  'next' => 
  array (
    0 => 'function.imageftbbox.php',
    1 => 'imageftbbox',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'zh',
    'path' => 'reference/image/functions/imagefontwidth.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.imagefontwidth" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">imagefontwidth</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">imagefontwidth</span> &mdash; <span class="dc-title">获取字体宽度</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.imagefontwidth-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>imagefontwidth</strong></span>(<span class="methodparam"><span class="type"><span class="type"><a href="class.gdfont.php" class="type GdFont">GdFont</a></span>|<span class="type"><a href="language.types.integer.php" class="type int">int</a></span></span> <code class="parameter">$font</code></span>): <span class="type"><a href="language.types.integer.php" class="type int">int</a></span></div>

  <p class="para rdfs-comment">
   返回字体中字符的像素宽度。
  </p>
 </div>

 <div class="refsect1 parameters" id="refsect1-function.imagefontwidth-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    <dt>
<code class="parameter">font</code></dt><dd><p class="para">取值对于内建的 latin2 编码字体可以是：1、2、3、4、5(更高的数字对应更大的字体)，
或是通过 <span class="function"><a href="function.imageloadfont.php" class="function">imageloadfont()</a></span> 返回的 <span class="classname"><a href="class.gdfont.php" class="classname">GdFont</a></span> 实例。</p></dd>
   </dl>
  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-function.imagefontwidth-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   返回字体的像素宽度。
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.imagefontwidth-changelog">
 <h3 class="title">更新日志</h3>
 <p class="para">
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>版本</th>
      <th>说明</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
  <td>8.1.0</td>
  <td>
  <code class="parameter">font</code> 参数现在接受 <span class="classname"><a href="class.gdfont.php" class="classname">GdFont</a></span> 
  实例和 <span class="type"><a href="language.types.integer.php" class="type int">int</a></span>，之前仅接受 <span class="type"><a href="language.types.integer.php" class="type int">int</a></span>。
  </td>
</tr>

    </tbody>
   
  </table>

 </p>
</div>

 
 <div class="refsect1 examples" id="refsect1-function.imagefontwidth-examples">
  <h3 class="title">示例</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>示例 #1 在内置字体上使用 <span class="function"><strong>imagefontwidth()</strong></span></strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">echo </span><span style="color: #DD0000">'Font width: ' </span><span style="color: #007700">. </span><span style="color: #0000BB">imagefontwidth</span><span style="color: #007700">(</span><span style="color: #0000BB">4</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>以上示例的输出类似于：</p></div>
    <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">Font width: 8</pre>
</div>
    </div>
   </div>
   <div class="example" id="example-2">
    <p><strong>示例 #2 将 <span class="function"><strong>imagefontwidth()</strong></span> 与 <span class="function"><a href="function.imageloadfont.php" class="function">imageloadfont()</a></span> 一起使用</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">// Load a .gdf font<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">'anonymous.gdf'</span><span style="color: #007700">);<br /><br />echo </span><span style="color: #DD0000">'Font width: ' </span><span style="color: #007700">. </span><span style="color: #0000BB">imagefontwidth</span><span style="color: #007700">(</span><span style="color: #0000BB">$font</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>以上示例的输出类似于：</p></div>
    <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">Font width: 23</pre>
</div>
    </div>
   </div>
  </p>
 </div>

 <div class="refsect1 seealso" id="refsect1-function.imagefontwidth-seealso">
  <h3 class="title">参见</h3>
  <ul class="simplelist">
   <li><span class="function"><a href="function.imagefontheight.php" class="function" rel="rdfs-seeAlso">imagefontheight()</a> - 获取字体高度</span></li>
   <li><span class="function"><a href="function.imageloadfont.php" class="function" rel="rdfs-seeAlso">imageloadfont()</a> - 载入新字体</span></li>
  </ul>
 </div>

</div><?php manual_footer($setup); ?>