/
imagettftext.xml
238 lines (230 loc) · 8.03 KB
/
imagettftext.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: 593ea510e853ff034e03f78a4be0daa41661c9d4 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 文字目以降の文字にアクセスするために、
(&#8364; のような) 十進数文字参照を含めることができます。
(&#xA9; のような) 十六進形式もサポートしています。
UTF-8 エンコーディングされた文字列を直接渡すことができます。
</para>
<para>
&copy; のような文字エンティティはサポートされません。
<function>html_entity_decode</function> を使用して、
文字エンティティを UTF-8 文字列にすることを検討してください。
</para>
<para>
フォントでサポートされていない文字が文字列で使用されている場合、
その文字は白抜きの矩形に置き換えられます。
</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
// コンテントタイプを設定します
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);
imagedestroy($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>
</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
-->