blockly > utils > dom > getFastTextWidth

utils.dom.getFastTextWidth() function

Gets the width of a text element using a faster method than getTextWidth. This method requires that we know the text element's font family and size in advance. Similar to getTextWidth, we cache the width we compute.


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


Parameter Type Description
textElement SVGTextElement An SVG 'text' element.
fontSize number The font size to use.
fontWeight string The font weight to use.
fontFamily string The font family to use.



Width of element.