PHP Conference Kansai 2025

ps_stringwidth

(PECL ps >= 1.1.0)

ps_stringwidth文字列の幅を取得する

説明

ps_stringwidth(
    resource $psdoc,
    string $text,
    int $fontid = 0,
    float $size = 0.0
): float

指定されたフォントとサイズで出力した場合に、 文字列の幅が何ポイントになるかを計算します。 正確な幅を計算するため、この関数には Adobe のフォントメトリックファイルが必要です。カーニングが有効になっている場合、 それも考慮して計算します。

パラメータ

psdoc

ps_new() が返す、postscript ファイルのリソース ID。

text

幅を計算するテキスト。

fontid

使用するフォントの ID。フォントが指定されていない場合は、 現在のフォントが使用されます。

size

フォントのサイズ。指定されていない場合は現在のサイズが使用されます。

戻り値

文字列の幅をポイント数で返します。

参考

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top

Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant