mirror of
https://github.com/php/doc-ja.git
synced 2026-04-29 02:53:11 +02:00
250 lines
8.4 KiB
XML
250 lines
8.4 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: 48220b9fcde41afb13e0b7f3e806f51cd179df90 Maintainer: hirokawa Status: ready -->
|
|
<!-- Credits: mumumu -->
|
|
<refentry xml:id="function.imagettftext" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
<refnamediv>
|
|
<refname>imagettftext</refname>
|
|
<refpurpose>TrueType フォントを使用してテキストを画像に書き込む</refpurpose>
|
|
</refnamediv>
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type class="union"><type>array</type><type>false</type></type><methodname>imagettftext</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>
|
|
<para>
|
|
指定した <parameter>text</parameter> を、
|
|
TrueType フォントを使用して画像に書き込みます。
|
|
</para>
|
|
<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>&gd.font.size;</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>angle</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
度で表される角度。0 度は左から右にテキストを読む方向になります。
|
|
0 より大きな値は、反時計回りの回転を表現します。例えば、
|
|
90 という値は下から上にテキストを読む方向になります。
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>x</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
<parameter>x</parameter> と <parameter>y</parameter>
|
|
で与えられた座標は、最初の文字のベースポイント
|
|
(ほぼ文字の左下角) を定義します。
|
|
この仕様は、<parameter>x</parameter> と <parameter>y</parameter>
|
|
で最初の文字の右上角を定義する
|
|
<function>imagestring</function> と異なっています。
|
|
例えば、左上は 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>imagecolorallocate</function> を参照ください。
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
&gd.ttf.fontfile;
|
|
<varlistentry>
|
|
<term><parameter>text</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
テキスト文字列を UTF-8 エンコーディングで表したもの。
|
|
</para>
|
|
<para>
|
|
フォント内で 127 文字目以降の文字にアクセスするために、
|
|
(<literal>&#8364;</literal> のような) 十進数文字参照を含めることができます。
|
|
(<literal>&#xA9;</literal> のような) 十六進形式もサポートしています。
|
|
UTF-8 エンコーディングされた文字列を直接渡すことができます。
|
|
</para>
|
|
<para>
|
|
<literal>&copy;</literal> のような文字エンティティはサポートされません。
|
|
<function>html_entity_decode</function> を使用して、
|
|
文字エンティティを UTF-8 文字列にすることを検討してください。
|
|
</para>
|
|
<para>
|
|
フォントでサポートされていない文字が文字列で使用されている場合、
|
|
その文字は白抜きの矩形に置き換えられます。
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>options</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
<literal>linespacing</literal> キーに <type>float</type> 値を指定した配列。
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
テキストの境界を
|
|
構成する 4 点を表す 8 個の要素を有する配列を返します。
|
|
返される点は左下、右下、右上、左上の順番となります。
|
|
点の座標は、角度によらず text に関する相対座標として表されます。
|
|
つまり、"左上"は、text を水平に見た場合の左上の隅を表します。
|
|
エラー時には &false; を返します。
|
|
</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>imagettftext</function> の例</title>
|
|
<para>
|
|
この例は、400x30 ピクセルの白地に Arial
|
|
フォントを用いて、黒字 (グレーの影付き) で "Testing..."
|
|
と書かれた PNG を作成します。
|
|
</para>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
|
|
// content-type を設定します
|
|
header('Content-Type: image/png');
|
|
|
|
// 画像を生成します
|
|
$im = imagecreatetruecolor(400, 30);
|
|
|
|
// いくつかの色を生成します
|
|
$white = imagecolorallocate($im, 255, 255, 255);
|
|
$grey = imagecolorallocate($im, 128, 128, 128);
|
|
$black = imagecolorallocate($im, 0, 0, 0);
|
|
imagefilledrectangle($im, 0, 0, 399, 29, $white);
|
|
|
|
// 描画する文字列
|
|
$text = 'Testing...';
|
|
|
|
// フォント自身のパスでパスを置き換えます
|
|
$font = 'arial.ttf';
|
|
|
|
// テキストに影を付けます
|
|
imagettftext($im, 20, 0, 11, 21, $grey, $font, $text);
|
|
|
|
// テキストを追加します
|
|
imagettftext($im, 20, 0, 10, 20, $black, $font, $text);
|
|
|
|
// imagepng() を使用して imagejpeg() よりもクリアなテキストにします
|
|
imagepng($im);
|
|
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs.similar;
|
|
<mediaobject>
|
|
<alt>出力例 : imagettftext()</alt>
|
|
<imageobject>
|
|
<imagedata fileref="en/reference/image/figures/imagettftext.png"/>
|
|
</imageobject>
|
|
</mediaobject>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
<refsect1 role="notes">
|
|
&reftitle.notes;
|
|
¬e.freetype;
|
|
</refsect1>
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<simplelist>
|
|
<member><function>imagettfbbox</function></member>
|
|
<member><function>imagefttext</function></member>
|
|
<member><function>imagestring</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
|
|
-->
|