1
0
mirror of https://github.com/php/doc-ru.git synced 2026-04-28 01:33:30 +02:00
Files
archived-doc-ru/reference/image/functions/imagettfbbox.xml
T
Sergey Panteleev 6d43fd64d7 Исправление форматирования
[skip-spellcheck]
[skip-lint]
2022-12-27 03:42:36 +03:00

227 lines
7.1 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?xml version="1.0" encoding="utf-8"?>
<!-- EN-Revision: 593ea510e853ff034e03f78a4be0daa41661c9d4 Maintainer: tmn Status: ready -->
<!-- Reviewed: no -->
<refentry xml:id="function.imagettfbbox" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>imagettfbbox</refname>
<refpurpose>
Получение параметров рамки обрамляющей текст написанный TrueType шрифтом
</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type class="union"><type>array</type><type>false</type></type><methodname>imagettfbbox</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>
Эта функция рассчитывает и возвращает параметры рамки вокруг TrueType текста
в пикселах.
</para>
<note>
<para>
До PHP 8.0.0 <function>imageftbbox</function> - это расширенный вариант
<function>imagettfbbox</function> который дополнительно поддерживает
<parameter>extrainfo</parameter>.
Начиная с PHP 8.0.0, <function>imagettfbbox</function> является псевдонимом <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>
Угол в градусах в котором будет измерен <parameter>string</parameter>.
</para>
</listitem>
</varlistentry>
&gd.ttf.fontfile;
<varlistentry>
<term><parameter>string</parameter></term>
<listitem>
<para>
Измеряемая строка.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
<function>imagettfbbox</function> возвращает массив из 8 элементов
представляющих координаты четырёх точек - вершин рамки вокруг текста. В случае
ошибки функция вернёт &false;.
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>ключ</entry>
<entry>содержимое</entry>
</row>
</thead>
<tbody>
<row>
<entry>0</entry>
<entry>нижний левый угол, X координата</entry>
</row>
<row>
<entry>1</entry>
<entry>нижний левый угол, Y координата</entry>
</row>
<row>
<entry>2</entry>
<entry>нижний правый угол, X координата</entry>
</row>
<row>
<entry>3</entry>
<entry>нижний правый угол, Y координата</entry>
</row>
<row>
<entry>4</entry>
<entry>верхний правый угол, X координата</entry>
</row>
<row>
<entry>5</entry>
<entry>верхний правый угол, Y координата</entry>
</row>
<row>
<entry>6</entry>
<entry>верхний левый угол, X координата</entry>
</row>
<row>
<entry>7</entry>
<entry>верхний левый угол, Y координата</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
<para>
Точки рассчитаны относительно текста <emphasis>text</emphasis> и независимо от
угла <parameter>angle</parameter>. То есть "верхний левый" означает верхний левый
угол, если смотреть на текст горизонтально.
</para>
</refsect1>
<refsect1 role="changelog">
&reftitle.changelog;
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
<row>
<entry>8.0.0</entry>
<entry>
Добавлен параметр <parameter>options</parameter>.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Пример использования <function>imagettfbbox</function></title>
<programlisting role="php">
<![CDATA[
<?php
// создание изображения 300x150
$im = imagecreatetruecolor(300, 150);
$black = imagecolorallocate($im, 0, 0, 0);
$white = imagecolorallocate($im, 255, 255, 255);
// Белый фон
imagefilledrectangle($im, 0, 0, 299, 299, $white);
// Путь к файлу шрифта
$font = './arial.ttf';
// создаём рамку для текста
$bbox = imagettfbbox(10, 45, $font, 'Powered by PHP ' . phpversion());
// наши координаты X и Y
$x = $bbox[0] + (imagesx($im) / 2) - ($bbox[4] / 2) - 25;
$y = $bbox[1] + (imagesy($im) / 2) - ($bbox[5] / 2) - 5;
// Пишем текст
imagettftext($im, 10, 45, $x, $y, $black, $font, 'Powered by PHP ' . phpversion());
// создаём другую рамку для другого текста
$bbox = imagettfbbox(10, 45, $font, 'and Zend Engine ' . zend_version());
// задаём координаты так, чтобы текст шёл сразу за первой надписью
$x = $bbox[0] + (imagesx($im) / 2) - ($bbox[4] / 2) + 10;
$y = $bbox[1] + (imagesy($im) / 2) - ($bbox[5] / 2) - 5;
// Пишем вторую надпись
imagettftext($im, 10, 45, $x, $y, $black, $font, 'and Zend Engine ' . zend_version());
// Вывод в броузер
header('Content-Type: image/png');
imagepng($im);
imagedestroy($im);
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
<refsect1 role="notes">
&reftitle.notes;
&note.freetype;
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<simplelist>
<member><function>imagettftext</function></member>
<member><function>imageftbbox</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
-->