mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-26 05:48:57 +00:00

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@137938 c90b9560-bf6c-de11-be94-00142212c4b1
122 lines
4.6 KiB
XML
122 lines
4.6 KiB
XML
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!-- $Revision: 1.8 $ -->
|
|
<!-- splitted from ./en/functions/image.xml, last change in rev 1.2 -->
|
|
<refentry id="function.imagettftext">
|
|
<refnamediv>
|
|
<refname>imagettftext</refname>
|
|
<refpurpose>Write text to the image using TrueType fonts</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<methodsynopsis>
|
|
<type>array</type><methodname>imagettftext</methodname>
|
|
<methodparam><type>resource</type><parameter>image</parameter></methodparam>
|
|
<methodparam><type>int</type><parameter>size</parameter></methodparam>
|
|
<methodparam><type>int</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>fontfile</parameter></methodparam>
|
|
<methodparam><type>string</type><parameter>text</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
<function>imagettftext</function> draws the string
|
|
<parameter>text</parameter> in the image identified by
|
|
<parameter>image</parameter>, starting at coordinates
|
|
<parameter>x</parameter>, <parameter>y</parameter> (top left is 0, 0), at
|
|
an angle of <parameter>angle</parameter> in color
|
|
<parameter>color</parameter>, using the TrueType font file identified by
|
|
<parameter>fontfile</parameter>. Depending on which version of the GD
|
|
library that PHP is using, when <parameter>fontfile</parameter> does not
|
|
begin with a leading '/', '.ttf' will be appended to the filename and
|
|
the library will attempt to search for that filename along a
|
|
library-defined font path.
|
|
</para>
|
|
<para>
|
|
The coordinates given by <parameter>x</parameter>,
|
|
<parameter>y</parameter> will define the basepoint of the first
|
|
character (roughly the lower-left corner of the character). This
|
|
is different from the <function>imagestring</function>, where x,
|
|
y define the upper-right corner of the first character.
|
|
</para>
|
|
<para>
|
|
<parameter>angle</parameter> is in degrees, with 0 degrees being
|
|
left-to-right reading text (3 o'clock direction), and higher
|
|
values representing a counter-clockwise rotation. (i.e., a value
|
|
of 90 would result in bottom-to-top reading text).
|
|
</para>
|
|
<para>
|
|
<parameter>fontfile</parameter> is the path to the TrueType font
|
|
you wish to use.
|
|
</para>
|
|
<para>
|
|
<parameter>text</parameter> is the text string which may include
|
|
UTF-8 character sequences (of the form: &#123;) to access
|
|
characters in a font beyond the first 255.
|
|
</para>
|
|
<para>
|
|
<parameter>color</parameter> is the color index. Using the
|
|
negative of a color index has the effect of turning off
|
|
antialiasing.
|
|
</para>
|
|
<para>
|
|
<function>imagettftext</function> returns an array with 8
|
|
elements representing four points making the bounding box of the
|
|
text. The order of the points is lower left, lower right, upper
|
|
right, upper left. The points are relative to the text
|
|
regardless of the angle, so "upper left" means in the top
|
|
left-hand corner when you see the text horizontallty.
|
|
</para>
|
|
<para>
|
|
This example script will produce a black JPEG 400x30 pixels, with
|
|
the words "Testing..." in white in the font Arial.
|
|
<example>
|
|
<title><function>imagettftext</function> example</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
header("Content-type: image/jpeg");
|
|
$im = imagecreate(400,30);
|
|
$white = imagecolorallocate($im, 255,255,255);
|
|
$black = imagecolorallocate($im, 0,0,0);
|
|
|
|
// Replace path by your own font path
|
|
imagettftext($im, 20, 0, 10, 20, $black, "/path/arial.ttf",
|
|
"Testing... Omega: &#937;");
|
|
imagejpeg($im);
|
|
imagedestroy($im);
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
This function requires both the GD library and the <ulink
|
|
url="&url.freetype;">FreeType</ulink> library.
|
|
</para>
|
|
<para>
|
|
See also <function>imagettfbbox</function>.
|
|
</para>
|
|
</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:"../../../../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
|
|
-->
|