封鎖 >utils >數字 >getFastTextWidthWithSizeString
utils.dom.getFastTextWidthWithSizeString() 函式
使用比 getTextWidth 更快的方法取得文字元素的寬度。這種方法需要事先瞭解文字元素的字型系列和大小。與 getTextWidth 類似,我們會快取計算出的寬度。這個方法與 getFastTextWidth 類似,但會預期字型大小參數是字串。
Signature:
export declare function getFastTextWidthWithSizeString(textElement: SVGTextElement, fontSize: string, fontWeight: string, fontFamily: string): number;
參數
| 參數 | 類型 | 說明 |
|---|---|---|
| textElement | SVGTextElement | SVG 的「文字」元素。 |
| fontSize | 字串 | 要使用的字型大小。 |
| fontWeight | 字串 | 要使用的字型粗細。 |
| fontFamily | 字串 | 要使用的字型系列。 |
傳回:
數字
元素的寬度。