<?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 => 'de',
  ),
  'this' => 
  array (
    0 => 'function.imagettfbbox.php',
    1 => 'imagettfbbox',
    2 => 'Ermittelt das umgebende Rechteck eines Textes, der eine TrueType-Schriftart
   verwendet',
  ),
  'up' => 
  array (
    0 => 'ref.image.php',
    1 => 'GD- und Image-Funktionen',
  ),
  'prev' => 
  array (
    0 => 'function.imagetruecolortopalette.php',
    1 => 'imagetruecolortopalette',
  ),
  'next' => 
  array (
    0 => 'function.imagettftext.php',
    1 => 'imagettftext',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'de',
    'path' => 'reference/image/functions/imagettfbbox.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.imagettfbbox" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">imagettfbbox</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">imagettfbbox</span> &mdash; <span class="dc-title">
   Ermittelt das umgebende Rechteck eines Textes, der eine TrueType-Schriftart
   verwendet
  </span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.imagettfbbox-description">
  <h3 class="title">Beschreibung</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>imagettfbbox</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">
   Diese Funktion berechnet den Begrenzungsrahmen (Bounding Box) eines
   TrueType-Textes in Pixeln und gibt ihn zurück.
  </p>
  <blockquote class="note"><p><strong class="note">Hinweis</strong>: 
   <p class="para">
    Vor PHP 8.0.0 war <span class="function"><a href="function.imageftbbox.php" class="function">imageftbbox()</a></span> eine erweiterte
    Variante von <span class="function"><strong>imagettfbbox()</strong></span>, die zusätzlich den
    Parameter <code class="parameter">extrainfo</code> unterstützte. Ab PHP 8.0.0 ist
    <span class="function"><strong>imagettfbbox()</strong></span> ein Alias von
    <span class="function"><a href="function.imageftbbox.php" class="function">imageftbbox()</a></span>.
   </p>
  </p></blockquote>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.imagettfbbox-parameters">
  <h3 class="title">Parameter-Liste</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">size</code></dt>
     <dd>
      <p class="para">Die Schriftgröße in Punkten.</p>
     </dd>
    
    
     <dt><code class="parameter">angle</code></dt>
     <dd>
      <p class="para">
       Der Winkel in Grad, in dem <code class="parameter">string</code> vermessen wird.
      </p>
     </dd>
    
    
    
     <dt><code class="parameter">fontfile</code></dt>
     <dd>
      <p class="para">
       Der Pfad zu der TrueType-Schriftart, die verwendet werden soll.
      </p>
      <p class="para">
       Der Pfad zu der TrueType-Schriftart, die verwendet werden soll.
       Abhängig davon, welche Version der GD-Bibliothek PHP verwendet, wird,
       <em>wenn <code class="parameter">fontfile</code> nicht mit einem
       vorangestellten <code class="literal">/</code> beginnt, <code class="literal">.ttf</code>
       an den Dateinamen angehängt</em> und die Bibliothek versucht,
       diesen Dateinamen entlang eines von der Bibliothek definierten
       Schriftarten-Pfades zu suchen.
      </p>
      <p class="para">
       Bei der Verwendung von Versionen der GD-Bibliothek, die älter als
       2.0.18 sind, wurde ein <code class="literal">space</code>-Zeichen, anstelle eines
       Semikolons als Pfad-Trennzeichen für verschiedene Schriftdateien
       verwendet. Die unbeabsichtigte Verwendung dieser Eigenschaft führt zu
       einer Warnmeldung: <code class="literal">Warnung: Schriftart konnte nicht
       gefunden/geöffnet werden</code>. Für diese betroffenen Versionen
       besteht die einzige Lösung darin, die Schriftart in einen Pfad zu
       verschieben, der keine Leerzeichen enthält.
      </p>
      <p class="para">
       In vielen Fällen, in denen sich eine Schriftart im selben Verzeichnis
       befindet wie das Skript, das sie verwendet, kann der folgende Trick die
       Probleme beim Einbinden lösen.
       <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">// Setzten der Umgebungsvariablen für 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">// Benennen der zu verwendenden Schriftart<br />// (zu beachten ist das Fehlen der Erweiterung .ttf)<br /></span><span style="color: #0000BB">$font </span><span style="color: #007700">= </span><span style="color: #DD0000">'IrgendeineSchriftart'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
       </div>

      </p>
      <blockquote class="note"><p><strong class="note">Hinweis</strong>: 
       <p class="para">
        Zu beachten ist, dass
        <a href="ini.core.php#ini.open-basedir" class="link">open_basedir</a>
        <em>nicht</em> für <code class="parameter">fontfile</code> gilt.
       </p>
      </p></blockquote>
     </dd>
    

    
     <dt><code class="parameter">string</code></dt>
     <dd>
      <p class="para">
       Die zu vermessende Zeichenkette.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.imagettfbbox-returnvalues">
  <h3 class="title">Rückgabewerte</h3>
  <p class="para">
   <span class="function"><strong>imagettfbbox()</strong></span> gibt im Erfolgsfall ein Array mit 8
   Elementen zurück, die die vier Punkte des umgebenden Rechtecks des Texts
   repräsentieren, und <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> im Fehlerfall.
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>Schlüssel</th>
       <th>Wert</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>0</td>
       <td>untere linke Ecke, x-Koordinate</td>
      </tr>

      <tr>
       <td>1</td>
       <td>untere linke Ecke, y-Koordinate</td>
      </tr>

      <tr>
       <td>2</td>
       <td>untere rechte Ecke, x-Koordinate</td>
      </tr>

      <tr>
       <td>3</td>
       <td>untere rechte Ecke, y-Koordinate</td>
      </tr>

      <tr>
       <td>4</td>
       <td>obere rechte Ecke, x-Koordinate</td>
      </tr>

      <tr>
       <td>5</td>
       <td>obere rechte Ecke, y-Koordinate</td>
      </tr>

      <tr>
       <td>6</td>
       <td>obere linke Ecke, x-Koordinate</td>
      </tr>

      <tr>
       <td>7</td>
       <td>obere linke Ecke, y-Koordinate</td>
      </tr>

     </tbody>
    
   </table>

  </p>
  <p class="para">
   Die Punkte sind relativ zum <em>Text</em>, unabhängig von
   <code class="parameter">angle</code>, sodass &quot;obere linke Ecke&quot; bedeutet &quot;in der
   oberen linken Ecke, wenn der Text horizontal gesehen wird&quot;.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.imagettfbbox-changelog">
  <h3 class="title">Changelog</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>Version</th>
      <th>Beschreibung</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.0.0</td>
      <td>
       Die <code class="parameter">options</code> wurden hinzugefügt.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.imagettfbbox-examples">
  <h3 class="title">Beispiele</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Beispiel #1 <span class="function"><strong>imagettfbbox()</strong></span>-Beispiel</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">// Erzeuge ein 300x150-Bild<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">// Weißer Hintergrund<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">// Pfad der Schriftartdatei<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">// Zunächst ermitteln wir das umgebende Rechteck für den ersten Text<br /></span><span style="color: #0000BB">$bbox </span><span style="color: #007700">= </span><span style="color: #0000BB">imagettfbbox</span><span style="color: #007700">(</span><span style="color: #0000BB">10</span><span style="color: #007700">, </span><span style="color: #0000BB">45</span><span style="color: #007700">, </span><span style="color: #0000BB">$font</span><span style="color: #007700">, </span><span style="color: #DD0000">'Powered by PHP ' </span><span style="color: #007700">. </span><span style="color: #0000BB">phpversion</span><span style="color: #007700">());<br /><br /></span><span style="color: #FF8000">// Dies sind die x- und y-Koordinaten<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">25</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: #FF8000">// Schreibe<br /></span><span style="color: #0000BB">imagettftext</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">45</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">'Powered by PHP ' </span><span style="color: #007700">. </span><span style="color: #0000BB">phpversion</span><span style="color: #007700">());<br /><br /></span><span style="color: #FF8000">// Ermittle das umgebende Rechteck für den zweiten Text<br /></span><span style="color: #0000BB">$bbox </span><span style="color: #007700">= </span><span style="color: #0000BB">imagettfbbox</span><span style="color: #007700">(</span><span style="color: #0000BB">10</span><span style="color: #007700">, </span><span style="color: #0000BB">45</span><span style="color: #007700">, </span><span style="color: #0000BB">$font</span><span style="color: #007700">, </span><span style="color: #DD0000">'and Zend Engine ' </span><span style="color: #007700">. </span><span style="color: #0000BB">zend_version</span><span style="color: #007700">());<br /><br /></span><span style="color: #FF8000">// Berechne die Koordinaten, sodass es neben dem ersten Text ist<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">10</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: #FF8000">// Schreibe<br /></span><span style="color: #0000BB">imagettftext</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">45</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">'and Zend Engine ' </span><span style="color: #007700">. </span><span style="color: #0000BB">zend_version</span><span style="color: #007700">());<br /><br /></span><span style="color: #FF8000">// Ausgabe an den 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">?&gt;</span></span></code></div>
    </div>

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


 <div class="refsect1 notes" id="refsect1-function.imagettfbbox-notes">
  <h3 class="title">Anmerkungen</h3>
  <blockquote class="note"><p><strong class="note">Hinweis</strong>: <span class="simpara">Diese Funktion ist nur verfügbar
wenn PHP mit Freetype unterstützung (<strong class="option configure">--with-freetype-dir=DIR</strong>)
kompiliert wurde</span></p></blockquote>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.imagettfbbox-seealso">
  <h3 class="title">Siehe auch</h3>
  <ul class="simplelist">
   <li><span class="function"><a href="function.imagettftext.php" class="function" rel="rdfs-seeAlso">imagettftext()</a> - Schreibt Text mit TrueType-Schriftarten ins Bild</span></li>
   <li><span class="function"><a href="function.imageftbbox.php" class="function" rel="rdfs-seeAlso">imageftbbox()</a> - Give the bounding box of a text using fonts via freetype2</span></li>
  </ul>
 </div>


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