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 / Drawing Text


DrawJustified

The DrawJustified procedure draws the specified text at the current pen location in the current graphics port, taking into account the adjustment necessary to condense or extend the text by the slop value, appropriately for the script system.

PROCEDURE DrawJustified (textPtr: Ptr; textLength: LongInt;
                         slop: Fixed; 
                         styleRunPosition: JustStyleCode;
                         numer, denom: Point);
textPtr
A pointer to the memory location of the beginning of the text to be drawn.
textLength
The number of bytes of text to be drawn.
slop
The amount of slop for the text to be drawn. A positive value extends the text segment; a negative value condenses the text segment.
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
The DrawJustified procedure is similar to the DrawText procedure, except that you use it to draw text that is expanded or condensed by the number of pixels specified by slop. The DrawJustified procedure is most commonly used to draw a line of justified text.

The DrawJustified procedure draws the specified text in the font, size, and style of the current graphics port, taking into account any scaling factors, and it distributes the slop appropriately for the script system. Regardless of the line direction of the text to be drawn, you place the pen at the left edge of the line before calling DrawJustified for the first style run. For all subsequent style runs on that line, QuickDraw advances the pen appropriately.

If DrawJustified changes the width of spaces, it temporarily resets the space extra (spExtra) value. It adds to the current value of the field, if any, the amount of extra space to be applied to each space character within the range of text in order to justify the text, based on calculations that take into account the slop value and all of the text characteristics. On exit, DrawJustified restores the original value.

For the slop parameter, pass DrawJustified the value assessed for this style run based on the proportion returned for it from PortionLine. For more information, see "The numer and denom Parameters" on page 3-64.

Note
Be sure to pass the same values for styleRunPosition and the scaling factors (numer and denom) to DrawJustified that you pass to PortionLine.
See "The styleRunPosition Parameter" on page 3-63 for a description of this parameter and the values it takes. See "The slop Parameter" on page 3-63 for more information about the slop parameter.

For more information about how to use DrawJustified in conjunction with the other routines used to prepare to draw a line of justified text, see"Measuring and Drawing Lines of Text," beginning on page 3-29.

SPECIAL CONSIDERATIONS
The DrawJustified procedure works with text in all script systems. For example, to depict justified Arabic text, DrawJustified uses extension bars to create the additional width that is distributed as slop within a style run.

For 1-byte complex script systems, DrawJustified substitutes the proper ligatures, reversals, and compound characters as needed.

For 2-byte script systems that do not use space characters to delimit words, DrawJustified distributes the slop value in a manner appropriate to the script system. For script systems, such as Japanese, that use ideographic characters, DrawJustified distributes the additional screen pixel width appropriately for the text representation.

Note that textLength is the number of bytes to be drawn, not the number of characters. Because 2-byte script systems also include characters consisting of only 1 byte, do not simply multiply the number of characters by 2 to determine this value; you must determine and specify the correct number of bytes.

The DrawJustified procedure may move memory; do not call this procedure at interrupt time.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
6 JUL 1996