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

291 lines
9.8 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: 213fbd9440a224f9c1da4942c85124ce0c120c52 Maintainer: tmn Status: ready -->
<!-- Reviewed: no -->
<refentry xml:id="function.imagefttext" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>imagefttext</refname>
<refpurpose>
Нанесение текста на изображение, используя шрифты FreeType 2
</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type class="union"><type>array</type><type>false</type></type><methodname>imagefttext</methodname>
<methodparam><type>GdImage</type><parameter>image</parameter></methodparam>
<methodparam><type>float</type><parameter>size</parameter></methodparam>
<methodparam><type>float</type><parameter>angle</parameter></methodparam>
<methodparam><type>int</type><parameter>x</parameter></methodparam>
<methodparam><type>int</type><parameter>y</parameter></methodparam>
<methodparam><type>int</type><parameter>color</parameter></methodparam>
<methodparam><type>string</type><parameter>font_filename</parameter></methodparam>
<methodparam><type>string</type><parameter>text</parameter></methodparam>
<methodparam choice="opt"><type>array</type><parameter>options</parameter><initializer>[]</initializer></methodparam>
</methodsynopsis>
<note>
<para>
До PHP 8.0.0 <function>imagefttext</function> - это расширенный вариант
<function>imagettftext</function>, который дополнительно поддерживает
<parameter>extrainfo</parameter>.
Начиная с PHP 8.0.0, <function>imagettftext</function> является псевдонимом <function>imagefttext</function>.
</para>
</note>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
&gd.image.description;
<varlistentry>
<term><parameter>size</parameter></term>
<listitem>
<para>
Размер шрифта в пунктах.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>angle</parameter></term>
<listitem>
<para>
Угол в градусах, 0 градусов означает расположение текста слева направо.
Положительные значения означают поворот текста против часовой стрелки.
Например, текст повёрнутый на 90 градусов нужно будет читать снизу вверх.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>x</parameter></term>
<listitem>
<para>
Координаты <parameter>x</parameter> и <parameter>y</parameter> определяют
отправную точку для первого символа текста (конкретно, левый нижний угол
символа). Здесь есть отличие от функции <function>imagestring</function>,
в которой <parameter>x</parameter> и <parameter>y</parameter> определяют
верхний левый угол первого символа. Например, "верхний левый" имеет
координаты 0,0.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>y</parameter></term>
<listitem>
<para>
y-координата. Это позиция базовой линии шрифта, в общем случае она не
совпадает с низшей точкой в символе.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>color</parameter></term>
<listitem>
<para>
Индекс требуемого цвета текста, смотрите <function>imagecolorexact</function>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>font_filename</parameter></term>
<listitem>
<para>
Путь к TrueType шрифту, который требуется использовать.
</para>
<para>
В зависимости от версии GD библиотеки <emphasis>если
<parameter>font_filename</parameter> не начинается с <literal>/</literal>,
то в конец названия файла будет добавлено расширение
<literal>.ttf</literal></emphasis>, и библиотека будет пытаться найти
этот файл по адресу, определённому в настройках библиотеки.
</para>
<para>
В большинстве случаев размещение файлов шрифтов в директории скрипта решает
подобные проблемы включения файлов.
<programlisting role="php">
<![CDATA[
<?php
// Задание переменной окружения для GD
putenv('GDFONTPATH=' . realpath('.'));
// Имя шрифта для использования (обратите внимание на отсутствие расширения .ttf)
$font = 'SomeFont';
?>
]]>
</programlisting>
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>text</parameter></term>
<listitem>
<para>
Текст для вставки в изображение.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>options</parameter></term>
<listitem>
<para>
<table>
<title>
Возможные значения массива <parameter>options</parameter>
</title>
<tgroup cols="2">
<thead>
<row>
<entry>Ключ</entry>
<entry>Тип</entry>
<entry>Значение</entry>
</row>
</thead>
<tbody>
<row>
<entry><literal>linespacing</literal></entry>
<entry><type>float</type></entry>
<entry>
Определяет рисование нижнего подчёркивания
</entry>
</row>
</tbody>
</tgroup>
</table>
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Эта функция возвращает массив, определяющий четыре точки рамки текста. Текст
внутри этих границ начинается с левого нижнего угла и поворачивается против
часовой стрелки:
<informaltable>
<tgroup cols="2">
<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>
В случае возникновения ошибки возвращает &false;.
</para>
</refsect1>
<refsect1 role="changelog">
&reftitle.changelog;
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
&gd.changelog.image-param;
</tbody>
</tgroup>
</informaltable>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Пример использования <function>imagefttext</function></title>
<programlisting role="php">
<![CDATA[
<?php
// Создание изображения 300x100
$im = imagecreatetruecolor(300, 100);
$red = imagecolorallocate($im, 0xFF, 0x00, 0x00);
$black = imagecolorallocate($im, 0x00, 0x00, 0x00);
// Сделаем красный фон
imagefilledrectangle($im, 0, 0, 299, 99, $red);
// Путь к ttf файлу шрифта
$font_file = './arial.ttf';
// Рисуем текст 'PHP Manual' шрифтом 13го размера
imagefttext($im, 13, 0, 105, 55, $black, $font_file, 'PHP Manual');
// Вывод изображения
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>imageftbbox</function></member>
<member><function>imagettftext</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
-->