mirror of
https://github.com/php/doc-ja.git
synced 2026-04-24 08:28:13 +02:00
227 lines
6.7 KiB
XML
227 lines
6.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.imageftbbox" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>imageftbbox</refname>
|
|
<refpurpose>freetype2 によるフォントを用いたテキストを囲む箱を取得する</refpurpose>
|
|
</refnamediv>
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type class="union"><type>array</type><type>false</type></type><methodname>imageftbbox</methodname>
|
|
<methodparam><type>float</type><parameter>size</parameter></methodparam>
|
|
<methodparam><type>float</type><parameter>angle</parameter></methodparam>
|
|
<methodparam><type>string</type><parameter>font_filename</parameter></methodparam>
|
|
<methodparam><type>string</type><parameter>string</parameter></methodparam>
|
|
<methodparam choice="opt"><type>array</type><parameter>options</parameter><initializer>[]</initializer></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
この関数は FreeType テキスト用のバウンディングボックスをピクセル単位で算出し、
|
|
それを返します。
|
|
</para>
|
|
<note>
|
|
<para>
|
|
PHP 8.0.0 より前のバージョンでは、
|
|
<function>imageftbbox</function> は、
|
|
<function>imagettfbbox</function> を拡張したものでした。
|
|
追加で <parameter>options</parameter> をサポートしていました。
|
|
PHP 8.0.0 以降では、
|
|
<function>imagettfbbox</function> は
|
|
<function>imageftbbox</function> のエイリアスになっています。
|
|
</para>
|
|
</note>
|
|
</refsect1>
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>size</parameter></term>
|
|
<listitem>
|
|
<para>&gd.font.size;</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>angle</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
<parameter>string</parameter> を取得する角度。
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>font_filename</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
TrueType フォントのファイル名 (URL も可)。
|
|
PHP が使用している GD ライブラリのバージョンにも依存しますが、
|
|
先頭に '/' がついていないファイル名を渡した場合は
|
|
ファイル名の末尾に '.ttf' を追加して GD
|
|
のフォントパスからファイルを探そうとすることもあります。
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>string</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>
|
|
<function>imageftbbox</function> は 8 つの要素からなる配列を返します。
|
|
これが、テキストを囲む箱の 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>
|
|
これらの点は、<parameter>angle</parameter> の値にかかわらず
|
|
<emphasis>text</emphasis> からの相対位置になります。
|
|
つまり「左上」とは、そのテキストが水平になるように見たときの左上ということです。
|
|
</para>
|
|
<para>
|
|
失敗した場合には、&false; を返します。
|
|
</para>
|
|
</refsect1>
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title><function>imageftbbox</function> の例</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
// 300x150 の画像を作成します
|
|
$im = imagecreatetruecolor(300, 150);
|
|
$black = imagecolorallocate($im, 0, 0, 0);
|
|
$white = imagecolorallocate($im, 255, 255, 255);
|
|
|
|
// 背景色を白に設定します
|
|
imagefilledrectangle($im, 0, 0, 299, 299, $white);
|
|
|
|
// フォントファイルへのパス
|
|
$font = './arial.ttf';
|
|
|
|
// まずバウンディングボックスを作成します
|
|
$bbox = imageftbbox(10, 0, $font, 'The PHP Documentation Group');
|
|
|
|
// X 座標および Y 座標
|
|
$x = $bbox[0] + (imagesx($im) / 2) - ($bbox[4] / 2) - 5;
|
|
$y = $bbox[1] + (imagesy($im) / 2) - ($bbox[5] / 2) - 5;
|
|
|
|
imagefttext($im, 10, 0, $x, $y, $black, $font, 'The PHP Documentation Group');
|
|
|
|
// ブラウザに出力します
|
|
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>imagefttext</function></member>
|
|
<member><function>imagettfbbox</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
|
|
-->
|