Getting text metric information

You can use the TextFormat.getTextExtent() method to obtain detailed text measurements for a text string with specific formatting applied. For example, suppose you need to create, at runtime, a new TextField object containing an arbitrary amount of text that is formatted with a 24-point, bold, Arial font, and a 5-pixel indent. You need to determine how wide or high the new TextField object must be to display all of the text. The getTextExtent() method provides measurements such as ascent, descent, width, and height.

For more information, see TextFormat.getTextExtent().