From RAD Studio API Documentation
Jump to: navigation, search


function TextHeight(const Text: string): Integer;


int __fastcall TextHeight(const System::UnicodeString Text);


Type Visibility Source Unit Parent
function public
Vcl.Graphics TCustomCanvas


Returns the height, in pixels, of a string rendered in the current font.

Use TextHeight to determine the height a string will occupy in the image. Other elements in the image such as lines, boxes, or additional lines of text can be positioned to accommodate the height of the text. TextHeight returns the height of the font, the ascenders and the descenders, not the actual height of the specified string. If the height of the font is negative, then TextHeight is calculated by summing the absolute value of the font's height with the internal leading of the font; otherwise, TextHeight equals to the height of the font.

You can use TextExtent to obtain the same value.

See Also

Code Examples