Constructor
new SVGMeasurementProvider()
Members
(private) _svgRoot :SVGSVGElement
The root SVG element.
Type:
- SVGSVGElement
(private) _svgText :SVGTextElement
The leaf SVG element used for text measurement.
Type:
- SVGTextElement
Methods
(private) _init()
Create a simple SVG containing a text node, hide it, and attach it to the DOM. The text node will be used to collect text measurements. The SVG must be attached to the DOM: otherwise measurements will generally be zero.
beginMeasurementSession()
Called by the TextWrapper before a batch of zero or more calls to measureText().
dispose()
Detach the hidden SVG element from the DOM and forget all references to it and its children.
endMeasurementSession()
Called by the TextWrapper after a batch of zero or more calls to measureText().
measureText(text) → {number}
Measure a whole string as one unit.
Parameters:
Name | Type | Description |
---|---|---|
text |
string | the text to measure. |
Returns:
- the length of the string.
- Type
- number