調査アンケート: Blockly のご利用体験についてお聞かせください
アンケートを開始
ブロックする >utils >ドメイン >getFastTextWidth
utils.dom.getFastTextWidth() 関数
getTextWidth
よりも高速なメソッドを使用して、テキスト要素の幅を取得します。この方法では、テキスト要素のフォント ファミリーとフォントサイズを事前に把握しておく必要があります。getTextWidth
と同様に、計算した幅をキャッシュに保存します。
署名:
export declare function getFastTextWidth(textElement: SVGTextElement, fontSize: number, fontWeight: string, fontFamily: string): number;
パラメータ
パラメータ |
型 |
説明 |
textElement |
SVGTextElement |
SVG の「テキスト」要素です。 |
fontSize |
数値 |
使用するフォントサイズ。 |
fontWeight |
文字列 |
使用するフォントの太さ。 |
fontFamily |
文字列 |
使用するフォント ファミリー。 |
戻り値:
数値
要素の幅。
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2024-09-12 UTC。
[null,null,["最終更新日 2024-09-12 UTC。"],[[["`utils.dom.getFastTextWidth` calculates the width of an SVG text element more quickly than `getTextWidth` by pre-requiring font information and caching results."],["The function requires the SVG text element, font size, font weight, and font family as input to calculate and return the element's width."]]],[]]