Clear Up
SharpKit Reference

TextMetrics Class

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.

Namespace: Ext.util

Base Types

Methods

Name Description
bind(object) Binds this TextMetrics instance to a new element
getHeight(JsString) Returns the measured height of the specified text
getSize(JsString) Returns the size of the specified text based on the internal element's style and width properties
getWidth(JsString) Returns the measured width of the specified text
measure(object, JsString, object) Measures the size of the specified text
setFixedWidth(JsNumber) 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.
© Copyright 2005-2011 SharpKit. All rights reserved.