Provides precise pixel measurements for blocks of text so that you can determine exactly how high and wide, in pixels, a given block of text will be. Note that when measuring text, it should be plain text and should not contain any HTML, otherwise it may not be measured correctly.
The measurement works by copying the relevant CSS styles that can affect the font related display, then checking the size of an element that is auto-sized. Note that if the text is multi-lined, you must provide a fixed width when doing the measurement.
If multiple measurements are being done on the same element, you create a new instance to initialize to avoid the overhead of copying the styles to the element repeatedly.
The element to bind to.
A fixed width to apply to the measuring element.
Binds this TextMetrics instance to a new element
Binds this TextMetrics instance to a new element
The element
Returns the measured height of the specified text
Returns the measured height of the specified text
The text to measure
height The height in pixels
Only available on the instance returned from createInstance, not on the singleton.
Returns the size of the specified text based on the internal element's style and width properties
The text to measure
An object containing the text's size {width: (width), height: (height)}
Returns the measured width of the specified text
Returns the measured width of the specified text
The text to measure
width The width in pixels
Measures the size of the specified text
Measures the size of the specified text
The element, dom node or id from which to copy existing CSS styles that can affect the size of the rendered text
The text to measure
(optional) If the text will be multiline, you have to set a fixed width in order to accurately measure the text height
An object containing the text's size {width: (width), height: (height)}
Sets a fixed width on the internal measurement element. If the text will be multiline, you have to set a fixed width in order to accurately measure the text height.
The width to set on the element