Vcl.Graphics.TCustomCanvas.TextHeight

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

function TextHeight(const Text: string): Integer;

C++

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

Properties

Type Visibility Source Unit Parent
function public
Vcl.Graphics.pas
Vcl.Graphics.hpp
Vcl.Graphics TCustomCanvas

Description

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