Measuring lines
TTextLineLayout provides a set of functions you can use to retrieve measurement information about the line. Use these functions to retrieve information to use for line-breaking. Information used to position a line should be computed by the TLinePlacement object for the line.
TTextLineLayout computes the following information:
- Ascent and descent--the amount above and below the origin that the line extends. You can use this information in pagination to help determine the Y coordinate for the successive line.
- Height--the sum of the ascent and the descent.
- Width--the distance between the left and right edge of the line minus any overhanging white space.
Retrieve this information with the functions GetAscentAndDescent, GetHeight, and GetWidth. The GetMeasurements function returns all this information.
TTextLineLayout also provides the following measurement functions:
- GetBounds returns a bounding TGRect for the line, including all white space to the left and right of the line. You can use this information, for example, to invalidate a section of the display before a line is redrawn.
- GetRangeWidth calculates the width of a specified range of text within the line. A second implementation also returns the maximum ascent and descent values for that range. Use this information to help determine where to break lines. These functions return approximate width values. You must create a new TTextLineLayout to compute exact widths.
- GetMaximumFittingOffset takes an initial text offset and a width and returns the furthest offset for which the resulting range will fit within the specified width. You can use this information, for example, to determine an offset prior to which the line must be broken to fit within a given width.
You should pass ideal resolutions to the TTextLineLayout measurement functions. See the online class and member function descriptions for more information about these functions.
[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