<?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 => 'fr',
  ),
  'this' => 
  array (
    0 => 'function.imagettfbbox.php',
    1 => 'imagettfbbox',
    2 => 'Retourne le rectangle entourant un texte et dessin&eacute; avec une police TrueType',
  ),
  'up' => 
  array (
    0 => 'ref.image.php',
    1 => 'Fonctions GD et images',
  ),
  'prev' => 
  array (
    0 => 'function.imagetruecolortopalette.php',
    1 => 'imagetruecolortopalette',
  ),
  'next' => 
  array (
    0 => 'function.imagettftext.php',
    1 => 'imagettftext',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'fr',
    '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">Retourne le rectangle entourant un texte et dessiné avec une police TrueType</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.imagettfbbox-description">
  <h3 class="title">Description</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">
   Calcule et retourne le rectangle entourant le texte
   <code class="parameter">text</code>, écrit avec une police truetype.
  </p>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <p class="para">
    Antérieur à PHP 8.0.0, <span class="function"><a href="function.imageftbbox.php" class="function">imageftbbox()</a></span> était une variante
    étendue de <span class="function"><strong>imagettfbbox()</strong></span> qui en plus supportait
    <code class="parameter">extrainfo</code>.
    À partir de PHP 8.0.0, <span class="function"><strong>imagettfbbox()</strong></span> est un alias de
    <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">Liste de paramètres</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">size</code></dt>
     <dd>
      <p class="para">La taille de la police de caractères en point.</p>
     </dd>
    
    
     <dt><code class="parameter">angle</code></dt>
     <dd>
      <p class="para">
       L&#039;angle, en degrés, dans lequel le paramètre <code class="parameter">string</code>
       sera mesuré.
      </p>
     </dd>
    
    

<dt><code class="parameter">fontfile</code></dt>
<dd>
    <p class="para">
        Le chemin d&#039;accès à la police TrueType que vous souhaitez utiliser.
    </p>
    <p class="para">
        Selon la version de la bibliothèque GD que PHP utilise, <em>quand
        <code class="parameter">fontfile</code> ne commence pas par une premier
        <code class="literal">/</code> alors <code class="literal">.ttf</code> sera ajouté</em>
        au nom de fichier et la bibliothèque essaiera de rechercher ce nom de
        fichier le long d&#039;un chemin de police défini par la bibliothèque.
    </p>
    <p class="para">
        Lorsque vous utilisez des versions de la bibliothèque GD inférieure à
        2.0.18, un caractère <code class="literal">espace</code>, plutôt qu&#039;un
        point-virgule, a été utilisé comme séparateur de chemin d&#039;accès pour
        différents fichiers de police. L&#039;utilisation involontaire de cette
        fonctionnalité se traduira par le message d&#039;avertissement: <code class="literal">
        Avertissement: impossible de trouver/ouvrir la police</code>. Pour
        ces versions affectées, la seule solution consiste à déplacer la police
        vers un chemin qui ne contient pas d&#039;espaces.
    </p>
    <p class="para">
        Dans de nombreux cas où une police réside dans le même répertoire que le
        script en l&#039;utilisant l&#039;astuce suivante permettra d&#039;atténuer les
        problèmes d&#039;inclusion.
        <div class="example-contents">
            <div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">// Définir la variable d'environnement pour 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">// Nommez la police à utiliser (Notez l'absence de l'extension .ttf)<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">?&gt;</span></span></code></div>
        </div>

    </p>
    <blockquote class="note"><p><strong class="note">Note</strong>: 
        <p class="para">
            Notez que <a href="ini.core.php#ini.open-basedir" class="link">open_basedir</a>
            <em>ne s&#039;applique pas</em> à <code class="parameter">fontfile</code>.
        </p>
    </p></blockquote>
</dd>


    
     <dt><code class="parameter">string</code></dt>
     <dd>
      <p class="para">
       La chaîne à mesurer.
      </p>
     </dd>
    
    
     <dt><code class="parameter">options</code></dt>
     <dd>
      <p class="para">
       Similaire à <span class="function"><a href="function.imagettftext.php" class="function">imagettftext()</a></span>.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.imagettfbbox-returnvalues">
  <h3 class="title">Valeurs de retour</h3>
  <p class="para">
   <span class="function"><strong>imagettfbbox()</strong></span> retourne un tableau avec 8
   éléments représentant les 4 sommets du rectangle
   en cas de succès, <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> si une erreur survient.
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>Clé</th>
       <th>Signification</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>0</td>
       <td>Coin inférieur gauche, abscisse</td>
      </tr>

      <tr>
       <td>1</td>
       <td>Coin inférieur gauche, ordonnée</td>
      </tr>

      <tr>
       <td>2</td>
       <td>Coin inférieur droit, abscisse</td>
      </tr>

      <tr>
       <td>3</td>
       <td>Coin inférieur droit, ordonnée</td>
      </tr>

      <tr>
       <td>4</td>
       <td>Coin supérieur droit, abscisse</td>
      </tr>

      <tr>
       <td>5</td>
       <td>Coin supérieur droit, ordonnée</td>
      </tr>

      <tr>
       <td>6</td>
       <td>Coin supérieur gauche, abscisse</td>
      </tr>

      <tr>
       <td>7</td>
       <td>Coin supérieur gauche, ordonnée</td>
      </tr>

     </tbody>
    
   </table>

  </p>
  <p class="para">
   Les positions des points sont relatives au texte <em>text</em>,
   indépendamment de l&#039;angle : coin supérieur gauche fait
   référence au coin supérieur gauche du texte écrit
   horizontalement.
  </p>
 </div>


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

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.0.0</td>
      <td>
       Le paramètre <code class="parameter">options</code> a été ajouté.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.imagettfbbox-examples">
  <h3 class="title">Exemples</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Exemple #1 Exemple avec <span class="function"><strong>imagettfbbox()</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">// Création d'une image de 300x150 pixels<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">// Définit l'arrière-plan en blanc<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">// Chemin vers le fichier de police<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">// Tout d'abord, nous créons notre rectangle entourant notre premier texte<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">// Nos coordonnées en X et en 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">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">// Dessin du texte<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">// Nous créons notre rectangle entourant notre second texte<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">// Définit les coordonnées afin que le second text suive le premier<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">// Dessin du texte<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">// Affichage vers le navigateur<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">Notes</h3>
  <blockquote class="note"><p><strong class="note">Note</strong>: <span class="simpara">Cette fonction n&#039;est disponible que si
    si PHP est compilé avec le support Freetype (<strong class="option configure">--with-freetype-dir=DIR</strong>)
</span></p></blockquote>
 </div>

 <div class="refsect1 seealso" id="refsect1-function.imagettfbbox-seealso">
  <h3 class="title">Voir aussi</h3>
  <ul class="simplelist">
   <li><span class="function"><a href="function.imagettftext.php" class="function" rel="rdfs-seeAlso">imagettftext()</a> - Dessine un texte avec une police TrueType</span></li>
   <li><span class="function"><a href="function.imageftbbox.php" class="function" rel="rdfs-seeAlso">imageftbbox()</a> - Calcule le rectangle d'encadrement pour un texte, en utilisant la police courante et freetype2</span></li>
  </ul>
 </div>

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