Imagick::queryFontMetrics引用元:PHP(http://www.php.net/manual/ja/imagick.queryfontmetrics.php)
(PECL imagick 2.0.0)
Imagick::queryFontMetrics — フォントメトリクスを表す配列を返す
説明
array Imagick::queryFontMetrics ( ImagickDraw $properties , string $text [, bool $multiline ] )
フォントメトリクスを表す、多次元配列を返します。
$multilineはtrueで有効、falseで無効、省略すると自動で検出。
例)
$image = new Imagick();$text = 'g';$draw = new ImagickDraw();$draw->setFont('Calibri');$draw->setFontSize(140);$draw->setFillColor('black');$draw->setTextAntialias(1);metrics = $image->queryFontMetrics($draw, $text, true);print_r($metrics);
実行結果)
Array
(
[characterWidth] => 140
[characterHeight] => 140
[ascender] => 105
[descender] => -35
[textWidth] => 62
[textHeight] => 140
[maxHorizontalAdvance] => 186
[boundingBox] => Array
(
[x1] => 4
[y1] => -25
[x2] => 62
[y2] => 66
)
[originX] => 66
[originY] => 0
)
characterWidth/characterHeight…フォントのポイント数。
ascender…アセンダライン(英小文字のb、d、fなど上に突き出ている文字の上端に引かれる水平線)までの距離。
descender…ディセンダライン(英小文字のg、j、pなど下に突き出ている文字の下端に引かれる水平線)までの距離。
textWidth…文字列の幅。
textHeight…文字列の高さ。
maxHorizontalAdvance…文字の初めから次の文字までの最大距離。
boundingBox…バウンディングボックス
x1…左下のx座標 y1…左下のy座標
x2…右上のx座標 y2…右上のy座標
originX…X軸の基点? 基点x0からX軸方向に移動した距離? 概ねtextWidth+x1の値が返される。
originY…Y軸の基点? 基点y0からX軸方向に移動した距離?