Drawing a text line

To draw a text line, simply call the TTextLineLayout Draw function. The Draw function takes the graf port into which to draw the line and a Boolean value specifying whether to draw the line using fixed line-height values. By default this value is False. The line is drawn according to the natural ascent and descent of its characters and their associated styles. Thus, to draw one of the lines created in the examples in "Creating TTextLineLayout instances" above into a TGrafPort thePort, call the Draw function as follows:

    line.Draw( thePort );
A second implementation of the TTextLineLayout Draw function also takes a resolution, of the type TGrafMatrix. If you don't specify a resolution, the Draw function uses the preferred resolution of the TGrafPort.

Device dependency issues
Because a system can have many different devices connected to it, at differing resolutions, you need to determine what device you want text to be idealized for. Many of the TTextLineLayout functions take a resolution in the form of a TGrafMatrix. Generally you should create the TGrafMatrix based on a particular TGrafPort. A TGrafPort has a preferred resolution, set either by an end user or heuristically. However, nothing prevents you from passing a resolution that differs from the resolution of the TGrafPort. Be aware that any time the resolution changes, TTextLineLayout may regenerate the line. TTextLineLayout always caches a line layout for a single resolution, allowing fast drawing to a single monitor or to multiple monitors of the same resolution. Regenerating the line is an expensive operation in terms of performance.


[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker