mirror of
https://github.com/php/doc-ja.git
synced 2026-03-26 08:02:15 +01:00
289 lines
8.7 KiB
XML
289 lines
8.7 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: 9960a09a5705102bf4dd0ce63e03d9ec716d0015 Maintainer: hirokawa Status: ready -->
|
|
<!-- CREDITS: shimooka,mumumu -->
|
|
<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>options</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>
|
|
PHP が使用している GD ライブラリのバージョンにも依存しますが、
|
|
<emphasis><parameter>font_filename</parameter> の先頭に <literal>/</literal>
|
|
がついていない場合はファイル名の末尾に
|
|
<literal>.ttf</literal> を追加</emphasis>して GD
|
|
のフォントパスからファイルを探そうとすることもあります。
|
|
</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>
|
|
この関数は、長方形の 4 つの角を表す点の配列を返します。
|
|
最初が左下の位置で、そこから反時計回りに回ります。
|
|
<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';
|
|
|
|
// フォントサイズ 13 で 'PHP Manual' というテキストを描画します
|
|
imagefttext($im, 13, 0, 105, 55, $black, $font_file, 'PHP Manual');
|
|
|
|
// 画像をブラウザに出力します
|
|
header('Content-Type: image/png');
|
|
|
|
imagepng($im);
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
<refsect1 role="notes">
|
|
&reftitle.notes;
|
|
¬e.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
|
|
-->
|