Important: The information in this document is obsolete and should not be used for new development.
PortionLine
ThePortionLine
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 usePortionLine
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 thePortionLine
function once for each style run on the line. ThePortionLine
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 thatPortionLine
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:
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
- Call
PortionLine
for each style run on the line.- Add the returned values together.
- 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.- 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.
styleRunPosition
parameter and the values it takes.
- Note
- Be sure to pass the same values for
styleRunPosition
and the scaling factors (numer
anddenom
) toPortionLine
that you pass to any of the other justification routines for this style run.