Properties Methods Events Direct Link

# Class Ext.util.TextMetrics

Package: | Ext.util
Defined In: | TextMetrics.js
Class: | TextMetrics
Extends: | Object

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.
This class is a singleton and cannot be created directly.

## Public Properties

This class has no public properties.

## Public Methods

Method | Defined By
--- | ---
| bind( `String/HTMLElement el` ) : void Only available on the instance returned from createInstance, not on the singleton. Binds this TextMetrics instance to... Only available on the instance returned from createInstance, not on the singleton. Binds this TextMetrics instance to an element from which to copy existing CSS styles that can affect the size of the rendered text Parameters: `el` : String/HTMLElement The element, dom node or id Returns: void | TextMetrics
| createInstance( `String/HTMLElement el`, [`Number fixedWidth`] ) : Ext.util.TextMetrics.Instance Return a unique TextMetrics instance that can be bound directly to an element and reused. This reduces the overhead ... Return a unique TextMetrics instance that can be bound directly to an element and reused. This reduces the overhead of multiple calls to initialize the style properties on each measurement. Parameters: `el` : String/HTMLElement The element, dom node or id that the instance will be bound to `fixedWidth` : Number (optional) If the text will be multiline, you have to set a fixed width in order to accurately measure the text height Returns: `Ext.util.TextMetrics.Instance` instance The new instance | TextMetrics
| getHeight( `String text` ) : Number Only available on the instance returned from createInstance, not on the singleton. Returns the measured height of the... Only available on the instance returned from createInstance, not on the singleton. Returns the measured height of the specified text. For multiline text, be sure to call setFixedWidth if necessary. Parameters: `text` : String The text to measure Returns: `Number` height The height in pixels | TextMetrics
| getSize( `String text` ) : Object Only available on the instance returned from createInstance, not on the singleton. Returns the size of the specified ... 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 Parameters: `text` : String The text to measure Returns: `Object` An object containing the text's size {width: (width), height: (height)} | TextMetrics
| getWidth( `String text` ) : Number Only available on the instance returned from createInstance, not on the singleton. Returns the measured width of the ... Only available on the instance returned from createInstance, not on the singleton. Returns the measured width of the specified text Parameters: `text` : String The text to measure Returns: `Number` width The width in pixels | TextMetrics
| measure( `String/HTMLElement el`, `String text`, [`Number fixedWidth`] ) : Object Measures the size of the specified text Measures the size of the specified text Parameters: `el` : String/HTMLElement The element, dom node or id from which to copy existing CSS styles that can affect the size of the rendered text `text` : String The text to measure `fixedWidth` : Number (optional) If the text will be multiline, you have to set a fixed width in order to accurately measure the text height Returns: `Object` An object containing the text's size {width: (width), height: (height)} | TextMetrics
| setFixedWidth( `Number width` ) : void Only available on the instance returned from createInstance, not on the singleton. Sets a fixed width on the internal... Only available on the instance returned from createInstance, not on the singleton. 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. Parameters: `width` : Number The width to set on the element Returns: void | TextMetrics

## Public Events

This class has no public events.