blockly > utils > dom > getFastTextWidth

utils.dom.getFastTextWidth() 関数

getTextWidth よりも高速なメソッドを使用して、テキスト要素の幅を取得します。このメソッドでは、テキスト要素のフォント ファミリーとサイズを事前に把握しておく必要があります。getTextWidth と同様に、計算した幅をキャッシュに保存します。

署名:

export declare function getFastTextWidth(textElement: SVGTextElement, fontSize: number, fontWeight: string, fontFamily: string): number;

パラメータ

パラメータ 種類 説明
textElement SVGTextElement SVG の「テキスト」要素。
fontSize 数値 使用するフォントサイズ。
fontWeight string 使用するフォントの太さ。
fontFamily string 使用するフォント ファミリー。

戻り値:

数値

要素の幅。