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

This section describes the routines that you use to set the text characteristics of the graphics port drawing environment, measure and draw text, lay out lines of text, and determine where to position the caret and which glyphs to highlight in a range of text. It also describes two low-level routines that you can use to measure and draw text.

Four parameters that are common to a number of routines are described in detail here. These parameters are also listed and defined briefly in the each routine.

The slop Parameter

The DrawJustified, MeasureJustified, PixelToChar, and CharToPixel routines take a slop parameter. The value of this parameter is the number of pixels by which the width of the text segment is to be changed, after the text has been scaled. The slop is a signed value that specifies how much the text is to be extended or condensed. The slop is derived from the calculations made using the proportion returned from the PortionLine function for a style run. To measure or draw text that is not to be extended or condensed, pass a slop value of 0.

The styleRunPosition Parameter

The PortionLine, MeasureJustified, DrawJustified, PixelToChar, and CharToPixel routines take a styleRunPosition parameter. This parameter specifies the position of the style run on the display line, and is used to

The style run position parameter is meaningful only for those script systems that use intercharacter spacing for justification. For all other script systems, the parameter exists for future extensibility. Although the style run position parameter is not used, for example, for justifying text in the Roman script system, to allow for future compatibility, you should always specify the appropriate value for it for all calls that take it.

For those script systems that do use intercharacter spacing, space between style runs may be allocated differently depending upon whether the style run is leftmost, rightmost, or between two other style runs. For example, depending on the script system, if a style run occurs at the beginning or end of a line, extra space may not be added to the outer edge of the outermost glyph, whereas if a style run is interior to a line, all of the glyphs of the text may be treated the same: extra space is allocated to both sides of every glyph including those at either end of the style run.

Note
The current implementations of simple script systems such as Roman and Cyrillic do not justify a line of text by changing the width of nonspace characters. Instead, they rely solely on the use of space characters: the same amount of extra width is added to (or subtracted from) every space whether the space is at the beginning or end of the line or interior to it.
Use one of the following constants (defined as type JustStyleCode) in
the styleRunPosition parameter.
ConstantValueMeaning
onlyStyleRun0Only style run on the line
leftStyleRun1Leftmost of multiple style runs on the line
rightStyleRun2Rightmost of multiple style runs on the line
middleStyleRun3Interior style run: neither leftmost nor rightmost

The numer and denom Parameters

The PortionLine, DrawJustified, MeasureJustified, PixelToChar, CharToPixel, StdText, and StdTxMeas routines take numer and denom parameters. Both numer and denom are point values: numer specifies the numerator for the horizontal and vertical scaling factors, and denom specifies the denominator for
the horizontal and vertical scaling factors. Together, these values specify the scaling factors for the text: numer.v over denom.v gives the vertical scaling (height), and numer.h over denom.h gives the horizontal scaling factors (width). For routines that take these parameters, you need to specify values for numer and denom even if you are not scaling the text. For unscaled text, you can specify scaling factors of 1, 1.

For all routines except StdTxtMeas that take these parameters, numer and denom are input parameters only. For StdTxtMeas, numer and denom are reference parameters. On output, these parameters contain additional scaling to be applied to the text. Use of the output values is explained in the description of "StdTxMeas" on page 3-96.


Subtopics
The slop Parameter
The styleRunPosition Parameter
The numer and denom Parameters
Setting Text Characteristics
Drawing Text
Measuring Text
Laying Out a Line of Text
Determining the Caret Position, and Selecting and Highlighting Text
Low-Level QuickDraw Text Routines

Previous Book Contents Book Index Next

© Apple Computer, Inc.
6 JUL 1996