<?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 => 'ja',
  ),
  'this' => 
  array (
    0 => 'function.imageftbbox.php',
    1 => 'imageftbbox',
    2 => 'freetype2 によるフォントを用いたテキストを囲む箱を取得する',
  ),
  'up' => 
  array (
    0 => 'ref.image.php',
    1 => 'GD および Image 関数',
  ),
  'prev' => 
  array (
    0 => 'function.imagefontwidth.php',
    1 => 'imagefontwidth',
  ),
  'next' => 
  array (
    0 => 'function.imagefttext.php',
    1 => 'imagefttext',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'ja',
    'path' => 'reference/image/functions/imageftbbox.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.imageftbbox" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">imageftbbox</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.0.7, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">imageftbbox</span> &mdash; <span class="dc-title">freetype2 によるフォントを用いたテキストを囲む箱を取得する</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.imageftbbox-description">
  <h3 class="title">説明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>imageftbbox</strong></span>(<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.float.php" class="type float">float</a></span> <code class="parameter">$size</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.float.php" class="type float">float</a></span> <code class="parameter">$angle</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$font_filename</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$string</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.array.php" class="type array">array</a></span> <code class="parameter">$options</code><span class="initializer"> = []</span></span><br>): <span class="type"><span class="type"><a href="language.types.array.php" class="type array">array</a></span>|<span class="type"><a href="language.types.singleton.php" class="type false">false</a></span></span></div>

  <p class="para rdfs-comment">
   この関数は FreeType テキスト用のバウンディングボックスをピクセル単位で算出し、
   それを返します。
  </p>
  <blockquote class="note"><p><strong class="note">注意</strong>: 
   <p class="para">
    PHP 8.0.0 より前のバージョンでは、
    <span class="function"><strong>imageftbbox()</strong></span> は、
    <span class="function"><a href="function.imagettfbbox.php" class="function">imagettfbbox()</a></span> を拡張したものでした。
    追加で <code class="parameter">options</code> をサポートしていました。
    PHP 8.0.0 以降では、
    <span class="function"><a href="function.imagettfbbox.php" class="function">imagettfbbox()</a></span> は
    <span class="function"><strong>imageftbbox()</strong></span> のエイリアスになっています。
   </p>
  </p></blockquote>
 </div>

 <div class="refsect1 parameters" id="refsect1-function.imageftbbox-parameters">
  <h3 class="title">パラメータ</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">size</code></dt>
     <dd>
      <p class="para">ポイント数単位のフォントサイズ。</p>
     </dd>
    
    
     <dt><code class="parameter">angle</code></dt>
     <dd>
      <p class="para">
       <code class="parameter">string</code> を取得する角度。
      </p>
     </dd>
    
    
     <dt><code class="parameter">font_filename</code></dt>
     <dd>
      <p class="para">
       TrueType フォントのファイル名 (URL も可)。
       PHP が使用している GD ライブラリのバージョンにも依存しますが、
       先頭に &#039;/&#039; がついていないファイル名を渡した場合は
       ファイル名の末尾に &#039;.ttf&#039; を追加して GD
       のフォントパスからファイルを探そうとすることもあります。
      </p>
     </dd>
    
    
     <dt><code class="parameter">string</code></dt>
     <dd>
      <p class="para">
       取得したい文字列。
      </p>
     </dd>
    
    
     <dt><code class="parameter">options</code></dt>
     <dd>
      <p class="para">
       <table class="doctable table">
       <caption><strong><code class="parameter">options</code> の配列のインデックス</strong></caption>
        
         <thead>
          <tr>
           <th>キー</th>
           <th>型</th>
           <th>意味</th>
          </tr>

         </thead>

         <tbody class="tbody">
          <tr>
           <td><code class="literal">linespacing</code></td>
           <td><span class="type"><a href="language.types.float.php" class="type float">float</a></span></td>
           <td>描画時の行間を定義します</td>
          </tr>

         </tbody>
        
       </table>

      </p>
     </dd>
    
   </dl>
  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-function.imageftbbox-returnvalues">
  <h3 class="title">戻り値</h3>
  <p class="para">
   <span class="function"><strong>imageftbbox()</strong></span> は 8 つの要素からなる配列を返します。
   これが、テキストを囲む箱の 4 つの角の座標を表します。
   <table class="doctable informaltable">
    
     <tbody class="tbody">
      <tr>
       <td>0</td>
       <td>左下角の X 座標</td>
      </tr>

      <tr>
       <td>1</td>
       <td>左下角の Y 座標</td>
      </tr>

      <tr>
       <td>2</td>
       <td>右下角の X 座標</td>
      </tr>

      <tr>
       <td>3</td>
       <td>右下角の Y 座標</td>
      </tr>

      <tr>
       <td>4</td>
       <td>右上角の X 座標</td>
      </tr>

      <tr>
       <td>5</td>
       <td>右上角の Y 座標</td>
      </tr>

      <tr>
       <td>6</td>
       <td>左上角の X 座標</td>
      </tr>

      <tr>
       <td>7</td>
       <td>左上角の Y 座標</td>
      </tr>

     </tbody>
    
   </table>

  </p>
  <p class="para">
   これらの点は、<code class="parameter">angle</code> の値にかかわらず
   <em>text</em> からの相対位置になります。
   つまり「左上」とは、そのテキストが水平になるように見たときの左上ということです。
  </p>
  <p class="para">
   失敗した場合には、<strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> を返します。
  </p>
 </div>

 <div class="refsect1 examples" id="refsect1-function.imageftbbox-examples">
  <h3 class="title">例</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>例1 <span class="function"><strong>imageftbbox()</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: #FF8000">// 300x150 の画像を作成します<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">300</span><span style="color: #007700">, </span><span style="color: #0000BB">150</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">// 背景色を白に設定します<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">299</span><span style="color: #007700">, </span><span style="color: #0000BB">299</span><span style="color: #007700">, </span><span style="color: #0000BB">$white</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// フォントファイルへのパス<br /></span><span style="color: #0000BB">$font </span><span style="color: #007700">= </span><span style="color: #DD0000">'./arial.ttf'</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">// まずバウンディングボックスを作成します<br /></span><span style="color: #0000BB">$bbox </span><span style="color: #007700">= </span><span style="color: #0000BB">imageftbbox</span><span style="color: #007700">(</span><span style="color: #0000BB">10</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">$font</span><span style="color: #007700">, </span><span style="color: #DD0000">'The PHP Documentation Group'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// X 座標および Y 座標<br /></span><span style="color: #0000BB">$x </span><span style="color: #007700">= </span><span style="color: #0000BB">$bbox</span><span style="color: #007700">[</span><span style="color: #0000BB">0</span><span style="color: #007700">] + (</span><span style="color: #0000BB">imagesx</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">) / </span><span style="color: #0000BB">2</span><span style="color: #007700">) - (</span><span style="color: #0000BB">$bbox</span><span style="color: #007700">[</span><span style="color: #0000BB">4</span><span style="color: #007700">] / </span><span style="color: #0000BB">2</span><span style="color: #007700">) - </span><span style="color: #0000BB">5</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$y </span><span style="color: #007700">= </span><span style="color: #0000BB">$bbox</span><span style="color: #007700">[</span><span style="color: #0000BB">1</span><span style="color: #007700">] + (</span><span style="color: #0000BB">imagesy</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">) / </span><span style="color: #0000BB">2</span><span style="color: #007700">) - (</span><span style="color: #0000BB">$bbox</span><span style="color: #007700">[</span><span style="color: #0000BB">5</span><span style="color: #007700">] / </span><span style="color: #0000BB">2</span><span style="color: #007700">) - </span><span style="color: #0000BB">5</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">imagefttext</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">, </span><span style="color: #0000BB">10</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">$x</span><span style="color: #007700">, </span><span style="color: #0000BB">$y</span><span style="color: #007700">, </span><span style="color: #0000BB">$black</span><span style="color: #007700">, </span><span style="color: #0000BB">$font</span><span style="color: #007700">, </span><span style="color: #DD0000">'The PHP Documentation Group'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// ブラウザに出力します<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">?&gt;</span></span></code></div>
    </div>

   </div>
  </p>
 </div>

 <div class="refsect1 notes" id="refsect1-function.imageftbbox-notes">
  <h3 class="title">注意</h3>
  <blockquote class="note"><p><strong class="note">注意</strong>: <span class="simpara">この関数は、PHP が FreeType サポート
(<strong class="option configure">--with-freetype-dir=DIR</strong>)
を有効にしてコンパイルされている場合のみ使用可能です。
</span></p></blockquote>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.imageftbbox-seealso">
  <h3 class="title">参考</h3>
  <ul class="simplelist">
   <li><span class="function"><a href="function.imagefttext.php" class="function" rel="rdfs-seeAlso">imagefttext()</a> - FreeType 2 によるフォントを用いてイメージにテキストを描画する</span></li>
   <li><span class="function"><a href="function.imagettfbbox.php" class="function" rel="rdfs-seeAlso">imagettfbbox()</a> - TypeType フォントを使用したテキストの bounding box を生成する</span></li>
  </ul>
 </div>

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