User:Alexandrab/Text Layout Features

From RAD Studio
Jump to: navigation, search

Go Up to FireMonkey Applications Guide


FireMonkey provides methods to render text quickly using TTextLayout. Each OS has his own specific implementations for rendering text. On Windows versions lower than Vista SP1 text rendering is performed by GDI+ API, otherwise is used DirectWrite API . On Mac OS X and iOS text rendering is suported by the means of Core Text framework .

All text layout engines do the following:

  • Fit text with specified atributes, font, alignment
  • Allow calculation of font metrics
  • Render text on given graphics context
  • Perform conversion of text to vector paths

Both DirectWrite and Core Text operate with similar concepts but although the are details. For more information about using FireMonkey Text Layout features, see Using FireMonkey Text Layout Features.

TTextLayout provides basic abstraction for the OS specific implementations for rendering text components.

Note: When changing several properties of the layout at the same time, it is recomended to use BeginUpdate and EndUpdate procedures. It is not necessary to use BeginUpdate/EndUpdate when changing a single property.
The following image shows text layout position on canvas and its properties meanings:
TTextLayout Canvas.png
To assign text block properties, like TTextRange and TTextAttribute, use the AddAttribute method.
Note: On text rendering supported by DirectWrite the Color can be changed only for the whole layout. On text rendering supported by GDI+ there is no support for text atributes.
  • Text metrics allow to get cursor by point coordinates and coordinates of text region.
To get the position in text by position's coordinates use the PositionAtPoint method. To get the array of rectangles surrounding the range of the text specified in ARange use RegionForRange

Note: Under the iOS platform, Trimming works only when WordWrap = False.

See Also