reference/image/functions/imagettftext.xml
48220b9fcde41afb13e0b7f3e806f51cd179df90
48220b9fcde41afb13e0b7f3e806f51cd179df90
...
...
@@ -8,20 +8,29 @@
8
8
<refsect1 role="description">
9
9
&reftitle.description;
10
10
<methodsynopsis>
11
-
<type>array</type><methodname>imagettftext</methodname>
12
-
<methodparam><type>resource</type><parameter>image</parameter></methodparam>
11
+
<type class="union"><type>array</type><type>false</type></type><methodname>imagettftext</methodname>
12
+
<methodparam><type>GdImage</type><parameter>image</parameter></methodparam>
13
13
<methodparam><type>float</type><parameter>size</parameter></methodparam>
14
14
<methodparam><type>float</type><parameter>angle</parameter></methodparam>
15
15
<methodparam><type>int</type><parameter>x</parameter></methodparam>
16
16
<methodparam><type>int</type><parameter>y</parameter></methodparam>
17
17
<methodparam><type>int</type><parameter>color</parameter></methodparam>
18
-
<methodparam><type>string</type><parameter>fontfile</parameter></methodparam>
18
+
<methodparam><type>string</type><parameter>font_filename</parameter></methodparam>
19
19
<methodparam><type>string</type><parameter>text</parameter></methodparam>
20
+
<methodparam choice="opt"><type>array</type><parameter>options</parameter><initializer>[]</initializer></methodparam>
20
21
</methodsynopsis>
21
22
<para>
22
23
Writes the given <parameter>text</parameter> into the image using TrueType
23
24
fonts.
24
25
</para>
26
+
<note>
27
+
<para>
28
+
Prior to PHP 8.0.0, <function>imagefttext</function> was an extended variant of
29
+
<function>imagettftext</function> which additionally supported the
30
+
<parameter>extrainfo</parameter>.
31
+
As of PHP 8.0.0, <function>imagettftext</function> is an alias of <function>imagefttext</function>.
32
+
</para>
33
+
</note>
25
34
</refsect1>
26
35
<refsect1 role="parameters">
27
36
&reftitle.parameters;
...
...
@@ -76,43 +85,7 @@
76
85
</para>
77
86
</listitem>
78
87
</varlistentry>
79
-
<varlistentry>
80
-
<term><parameter>fontfile</parameter></term>
81
-
<listitem>
82
-
<para>
83
-
The path to the TrueType font you wish to use.
84
-
</para>
85
-
<para>
86
-
Depending on which version of the GD library PHP is using, <emphasis>when
87
-
<parameter>fontfile</parameter> does not begin with a leading
88
-
<literal>/</literal> then <literal>.ttf</literal> will be appended</emphasis>
89
-
to the filename and the library will attempt to search for that
90
-
filename along a library-defined font path.
91
-
</para>
92
-
<para>
93
-
When using versions of the GD library lower than 2.0.18, a <literal>space</literal> character,
94
-
rather than a semicolon, was used as the 'path separator' for different font files.
95
-
Unintentional use of this feature will result in the warning message:
96
-
<literal>Warning: Could not find/open font</literal>. For these affected versions, the
97
-
only solution is moving the font to a path which does not contain spaces.
98
-
</para>
99
-
<para>
100
-
In many cases where a font resides in the same directory as the script using it
101
-
the following trick will alleviate any include problems.
102
-
<programlisting role="php">
103
-
<![CDATA[
104
-
<?php
105
-
// Set the enviroment variable for GD
106
-
putenv('GDFONTPATH=' . realpath('.'));
107
-
108
-
// Name the font to be used (note the lack of the .ttf extension)
109
-
$font = 'SomeFont';
110
-
?>
111
-
]]>
112
-
</programlisting>
113
-
</para>
114
-
</listitem>
115
-
</varlistentry>
88
+
&gd.ttf.fontfile;
116
89
<varlistentry>
117
90
<term><parameter>text</parameter></term>
118
91
<listitem>
...
...
@@ -121,15 +94,14 @@ $font = 'SomeFont';
121
94
</para>
122
95
<para>
123
96
May include decimal numeric character references (of the form:
124
-
&#8364;) to access characters in a font beyond position 127.
125
-
The hexadecimal format (like &#xA9;) is supported.
97
+
<literal>&#8364;</literal>) to access characters in a font beyond position 127.
98
+
The hexadecimal format (like <literal>&#xA9;</literal>) is supported.
126
99
Strings in UTF-8 encoding can be passed directly.
127
100
</para>
128
101
<para>
129
-
Named entities, such as &copy;, are not supported. Consider using
102
+
Named entities, such as <literal>&copy;</literal>, are not supported. Consider using
130
103
<function>html_entity_decode</function>
131
-
to decode these named entities into UTF-8 strings (html_entity_decode()
132
-
supports this as of PHP 5.0.0).
104
+
to decode these named entities into UTF-8 strings.
133
105
</para>
134
106
<para>
135
107
If a character is used in the string which is not supported by the
...
...
@@ -137,6 +109,14 @@ $font = 'SomeFont';
137
109
</para>
138
110
</listitem>
139
111
</varlistentry>
112
+
<varlistentry>
113
+
<term><parameter>options</parameter></term>
114
+
<listitem>
115
+
<para>
116
+
An array with <literal>linespacing</literal> key holding a <type>float</type> value.
117
+
</para>
118
+
</listitem>
119
+
</varlistentry>
140
120
</variablelist>
141
121
</para>
142
122
</refsect1>
...
...
@@ -151,30 +131,29 @@ $font = 'SomeFont';
151
131
Returns &false; on error.
152
132
</para>
153
133
</refsect1>
134
+
154
135
<refsect1 role="changelog">
155
136
&reftitle.changelog;
156
-
<para>
157
-
<informaltable>
158
-
<tgroup cols="2">
159
-
<thead>
160
-
<row>
161
-
<entry>&Version;</entry>
162
-
<entry>&Description;</entry>
163
-
</row>
164
-
</thead>
165
-
<tbody>
166
-
<row>
167
-
<entry>5.2.0</entry>
168
-
<entry>
169
-
It is now possible to specify an hexadecimal entity in
170
-
<parameter>text</parameter>.
171
-
</entry>
172
-
</row>
173
-
</tbody>
174
-
</tgroup>
175
-
</informaltable>
176
-
</para>
137
+
<informaltable>
138
+
<tgroup cols="2">
139
+
<thead>
140
+
<row>
141
+
<entry>&Version;</entry>
142
+
<entry>&Description;</entry>
143
+
</row>
144
+
</thead>
145
+
<tbody>
146
+
<row>
147
+
<entry>8.0.0</entry>
148
+
<entry>
149
+
The <parameter>options</parameter> has been added.
150
+
</entry>
151
+
</row>
152
+
</tbody>
153
+
</tgroup>
154
+
</informaltable>
177
155
</refsect1>
156
+
178
157
<refsect1 role="examples">
179
158
&reftitle.examples;
180
159
<para>
...
...
@@ -187,6 +166,7 @@ $font = 'SomeFont';
187
166
<programlisting role="php">
188
167
<![CDATA[
189
168
<?php
169
+
190
170
// Set the content-type
191
171
header('Content-Type: image/png');
192
172
...
...
@@ -201,6 +181,7 @@ imagefilledrectangle($im, 0, 0, 399, 29, $white);
201
181
202
182
// The text to draw
203
183
$text = 'Testing...';
184
+
204
185
// Replace path by your own font path
205
186
$font = 'arial.ttf';
206
187
...
...
@@ -212,7 +193,7 @@ imagettftext($im, 20, 0, 10, 20, $black, $font, $text);
212
193
213
194
// Using imagepng() results in clearer text compared with imagejpeg()
214
195
imagepng($im);
215
-
imagedestroy($im);
196
+
216
197
?>
217
198
]]>
218
199
</programlisting>
...
...
@@ -228,23 +209,17 @@ imagedestroy($im);
228
209
</refsect1>
229
210
<refsect1 role="notes">
230
211
&reftitle.notes;
231
-
<note>
232
-
<para>
233
-
This function requires both the GD library and the <link
234
-
xlink:href="&url.freetype;">FreeType</link> library.
235
-
</para>
236
-
</note>
212
+
¬e.freetype;
237
213
</refsect1>
238
214
<refsect1 role="seealso">
239
215
&reftitle.seealso;
240
-
<para>
241
-
<simplelist>
242
-
<member><function>imagettfbbox</function></member>
243
-
</simplelist>
244
-
</para>
216
+
<simplelist>
217
+
<member><function>imagettfbbox</function></member>
218
+
<member><function>imagefttext</function></member>
219
+
<member><function>imagestring</function></member>
220
+
</simplelist>
245
221
</refsect1>
246
222
</refentry>
247
-
248
223
<!-- Keep this comment at the end of the file
249
224
Local variables:
250
225
mode: sgml
251
226