Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: Text /
Chapter 3 - QuickDraw Text / QuickDraw Text Reference
Routines / Laying Out a Line of Text


PortionLine

The PortionLine function determines the correct proportion of extra space to apply to the specified style run in a line of justified text.

FUNCTION PortionLine(textPtr: Ptr; textLen: LongInt; 
                        styleRunPosition: JustStyleCode; 
                        numer: Point; denom: Point) : Fixed;
textPtr
A pointer to the style run.
textLen
The number of bytes in the text of the style run.
styleRunPosition
The position on the line of this style run. The style run can be the only one on the line, the leftmost on the line, the rightmost on the line, or one between two other style runs.
numer
A point giving the numerator for the horizontal and vertical
scaling factors.
denom
A point giving the denominator for the horizontal and vertical
scaling factors.
DESCRIPTION
You use PortionLine in formatting a line of justified text. It helps you determine how to distribute the slop for a line among its style runs. When you know the total slop for a line of text, you need to determine what portion of it to attribute to each style run. To do this, you call the PortionLine function once for each style run on the line. The PortionLine function computes the portion of extra space for a style run, taking into account the font, size, style, and scaling factors of the style run. It returns a number that represents the portion of the slop to be applied to the style run for which it is called. You use the value that PortionLine returns to determine the percentage of slop that you should attribute to a style run.

To determine the percentage of slop to allocate to each style run, you compute what percentage each portion is of the sum of all portions. To determine the actual slop value in pixels for each style run, you apply the percentage to the total slop value. The following steps summarize this process:

  1. Call PortionLine for each style run on the line.
  2. Add the returned values together.
  3. Calculate the percentage of the slop value for each style run using the ratio of the value returned by PortionLine for that style run and the total of the values returned for all of the style runs on the line.
  4. Calculate the number of pixels to be added to each style run by multiplying the percentage of the slop for each style run by the total number of pixels.

For more information about the scaling factors, see "The numer and denom Parameters" on page 3-64. See "The styleRunPosition Parameter" on page 3-63 for a description of the styleRunPosition parameter and the values it takes.

Note
Be sure to pass the same values for styleRunPosition and the scaling factors (numer and denom) to PortionLine that you pass to any of the other justification routines for this style run.

Previous Book Contents Book Index Next

© Apple Computer, Inc.
6 JUL 1996