mirror of
https://github.com/php/doc-es.git
synced 2026-03-23 23:12:09 +01:00
226 lines
6.6 KiB
XML
226 lines
6.6 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- EN-Revision: 9960a09a5705102bf4dd0ce63e03d9ec716d0015 Maintainer: PhilDaiguille Status: ready -->
|
|
<!-- Reviewed: no -->
|
|
<refentry xml:id="function.imageftbbox" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>imageftbbox</refname>
|
|
<refpurpose>Calcula el rectángulo de delimitación para un texto, utilizando la fuente actual y freetype2</refpurpose>
|
|
</refnamediv>
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type class="union"><type>array</type><type>false</type></type><methodname>imageftbbox</methodname>
|
|
<methodparam><type>float</type><parameter>size</parameter></methodparam>
|
|
<methodparam><type>float</type><parameter>angle</parameter></methodparam>
|
|
<methodparam><type>string</type><parameter>font_filename</parameter></methodparam>
|
|
<methodparam><type>string</type><parameter>string</parameter></methodparam>
|
|
<methodparam choice="opt"><type>array</type><parameter>options</parameter><initializer>[]</initializer></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
<function>imageftbbox</function> calcula el rectángulo de delimitación
|
|
para el texto <parameter>text</parameter>, utilizando la fuente
|
|
actual y freetype2.
|
|
</para>
|
|
<note>
|
|
<para>
|
|
Anterior a PHP 8.0.0, <function>imageftbbox</function> era una variante
|
|
extendida de <function>imagettfbbox</function> que además soporta
|
|
<parameter>extrainfo</parameter>.
|
|
A partir de PHP 8.0.0, <function>imagettfbbox</function> es un alias de
|
|
<function>imageftbbox</function>.
|
|
</para>
|
|
</note>
|
|
</refsect1>
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>size</parameter></term>
|
|
<listitem>
|
|
<para>&gd.font.size;</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>angle</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Ángulo, en grados, en el cual el parámetro <parameter>string</parameter>
|
|
será medido.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>font_filename</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
El nombre del archivo de la fuente TrueType (puede ser una URL).
|
|
Dependiendo de la versión de GD utilizada por PHP, se buscarán
|
|
los archivos que no comiencen con un '/', añadiendo la extensión
|
|
'.ttf', y siguiendo la ruta de fuentes definida por la biblioteca.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>string</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
La cadena a medir.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>options</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
<table>
|
|
<title>Índices posibles para el array <parameter>options</parameter></title>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>Clave</entry>
|
|
<entry>Tipo</entry>
|
|
<entry>Significado</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry><literal>linespacing</literal></entry>
|
|
<entry><type>float</type></entry>
|
|
<entry>Representa el espaciado entre líneas al dibujar</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</table>
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
<function>imageftbbox</function> devuelve un array que contiene 8 elementos
|
|
representando los 4 puntos del rectángulo que rodea el texto:
|
|
<informaltable>
|
|
<tgroup cols="2">
|
|
<tbody>
|
|
<row>
|
|
<entry>0</entry>
|
|
<entry>Esquina inferior izquierda, posición en X</entry>
|
|
</row>
|
|
<row>
|
|
<entry>1</entry>
|
|
<entry>Esquina inferior izquierda, posición en Y</entry>
|
|
</row>
|
|
<row>
|
|
<entry>2</entry>
|
|
<entry>Esquina inferior derecha, posición en X</entry>
|
|
</row>
|
|
<row>
|
|
<entry>3</entry>
|
|
<entry>Esquina inferior derecha, posición en Y</entry>
|
|
</row>
|
|
<row>
|
|
<entry>4</entry>
|
|
<entry>Esquina superior derecha, posición en X</entry>
|
|
</row>
|
|
<row>
|
|
<entry>5</entry>
|
|
<entry>Esquina superior derecha, posición en Y</entry>
|
|
</row>
|
|
<row>
|
|
<entry>6</entry>
|
|
<entry>Esquina superior izquierda, posición en X</entry>
|
|
</row>
|
|
<row>
|
|
<entry>7</entry>
|
|
<entry>Esquina superior izquierda, posición en Y</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</informaltable>
|
|
</para>
|
|
<para>
|
|
Los puntos son relativos al <emphasis>texto</emphasis> según el parámetro
|
|
<parameter>angle</parameter>, por lo que "arriba a la izquierda" significa la esquina en
|
|
la parte superior izquierda cuando se mira el texto horizontalmente.
|
|
</para>
|
|
<para>
|
|
En caso de error, se devuelve &false;.
|
|
</para>
|
|
</refsect1>
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title>Ejemplo con <function>imageftbbox</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
// Creación de una imagen de 300x150 píxeles
|
|
$im = imagecreatetruecolor(300, 150);
|
|
$black = imagecolorallocate($im, 0, 0, 0);
|
|
$white = imagecolorallocate($im, 255, 255, 255);
|
|
|
|
// Define el fondo en blanco
|
|
imagefilledrectangle($im, 0, 0, 299, 299, $white);
|
|
|
|
// Ruta hacia nuestro archivo de fuente
|
|
$font = './arial.ttf';
|
|
|
|
// Primero, creamos un rectángulo que contenga nuestro texto
|
|
$bbox = imageftbbox(10, 0, $font, 'The PHP Documentation Group');
|
|
|
|
// Nuestras coordenadas en X y en Y
|
|
$x = $bbox[0] + (imagesx($im) / 2) - ($bbox[4] / 2) - 5;
|
|
$y = $bbox[1] + (imagesy($im) / 2) - ($bbox[5] / 2) - 5;
|
|
|
|
imagefttext($im, 10, 0, $x, $y, $black, $font, 'The PHP Documentation Group');
|
|
|
|
// Muestra hacia el navegador
|
|
header('Content-Type: image/png');
|
|
|
|
imagepng($im);
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="notes">
|
|
&reftitle.notes;
|
|
¬e.freetype;
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<simplelist>
|
|
<member><function>imagefttext</function></member>
|
|
<member><function>imagettfbbox</function></member>
|
|
</simplelist>
|
|
</refsect1>
|
|
</refentry>
|
|
<!-- Keep this comment at the end of the file
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
vim: et tw=78 syn=sgml
|
|
vi: ts=1 sw=1
|
|
-->
|