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 / Setting Text Characteristics


TextMode

The TextMode procedure sets the transfer mode for drawing text in the current
graphics port.

PROCEDURE TextMode (mode: Integer);
mode
The transfer mode to be used to draw the text.
DESCRIPTION
The TextMode procedure sets the transfer mode in the graphics port txMode field. The transfer mode determines the interplay between what an application is drawing (the source) and what already exists on the display device (the destination), resulting in the text display.

There are two basic kinds of modes: pattern (pat) and source (src). Source is the kind that you use for drawing text. There are four basic Boolean operations: Copy, Or, Xor, and Bic (bit clear), each of which has an inverse variant in which the source is inverted before the transfer, yielding eight operations in all. Original QuickDraw supports these eight transfer modes. Color QuickDraw enables your application to achieve color effects within those basic transfer modes, and offers an additional set of transfer modes that perform arithmetic operations on the RGB values of the source and destination pixels. See the chapter "Color QuickDraw" in Inside Macintosh: Imaging for a complete discussion of the arithmetic transfer modes. Other transfer modes are grayishTextOr, transparent mode, and text mask mode.

Table 3-1 shows the eight basic transfer modes and their effects on the destination pixels.
Table 3-1 Effects of the basic transfer modes
SourceAction on the destination pixel
 If black sourceIf white source
srcCopyForce blackForce white
srcOrForce blackLeave alone
srcXOrInvertLeave alone
srcBicForce whiteLeave alone
NotSrcCopyForce whiteForce black
NotSrcOrLeave aloneForce black
NotSrcXOrLeave aloneInvert
NotSrcBicLeave aloneForce white

This is how color affects these transfer modes when the source pixels are either all black (all 1's) or white (all 0's).

Copy

The Copy mode applies the foreground color to the black part of the source (the part containing 1's) and the background color to the white part of the source (the part containing 0's), and replaces the destination with the colored source.

Or

The Or mode applies the foreground color to the black part of the source and replaces the destination with the colored source. The white part of the source isn't transferred
to the destination. If the foreground is black, the drawing will be faster. Copying to a white background always reproduces the source image, regardless of the pixel depth.

Xor

The Xor mode complements the bits in the destination corresponding to the bits equal to 1 in the source. When used on a colored destination, the color of the inverted destination isn't defined.

Bic

The Bic mode applies the background color to the black part of the source and
replaces the destination with the colored source. The white part of the source isn't transferred to the destination. The black part of the source is erased, resulting in white
in the destination.

NotCopy

The NotCopy mode applies the foreground color to the white part of the source and the background color to the black part of the source, and replaces the destination with the colored source. It thus has the effect of reversing the foreground and background colors.

NotOr

The NotOr mode applies the foreground color to the white part of the source and replaces the destination with the colored source. The black part of the source isn't transferred to the destination. If the foreground is black, the drawing will be faster.

NotXor

The NotXor mode inverts the bits that are 0 in the source. When used on a colored destination, the color of the inverted destination isn't defined.

NotBic

The NotBic mode applies the background color to the white part of the source and replaces the destination with the colored source. The black part of the source isn't transferred to the destination.

The arithmetic transfer modes are addOver, addPin, subOver, subPin, adMax, adMin, and blend. For color, the arithmetic modes change the destination pixels by performing arithmetic operations on the source and destination pixels. Arithmetic transfer modes calculate pixel values by adding, subtracting, or averaging the RGB components of the source and destination pixels. They are most useful for 8-bit color, but they work on 4-bit and 2-bit color also. When the destination bitmap is one bit deep, the mode reverts to the basic transfer mode that best approximates the arithmetic mode requested.

The grayishTextOr transfer mode draws dimmed text on the screen. You can use it for black-and-white or color graphics ports. The grayishTextOr transfer mode is not considered a standard transfer mode because currently it is not stored in pictures, and printing with it is undefined. (It does not pass through the QuickDraw bottleneck routines.)

The transparent mode replaces the destination pixel with the source pixel if the source pixel isn't equal to the background color. This mode is most useful in 8-bit, 4-bit, or 2-bit color modes.

Note
Multibit fonts may have a specific color. Some transfer modes may not produce the desired results with a multibit font. However, the arithmetic modes, transparent mode, and hilite mode work equally well with single bit and multibit fonts. Multibit fonts draw quickly in srcOr mode only if the foreground is white. Single bit fonts draw quickly in srcOr mode only if the foreground is black. Grayscale fonts produce a spectrum of colors, rather than just the foreground and background colors. The following table shows transfer mode constants and
their selectors.
Table 3-2 Transfer mode constants and selectors
Transfer modeSelectorTransfer modeSelector
srcCopy0addPin33
srcOr1addOver34
srcXor2subPin35
srcBic3transparent36
notSrcCopy4adMax37
notSrcOr5subOver38
notSrcXor6adMin39
notSrcBic7grayishTextOr49
blend32mask64

For more information about transfer modes, see the chapters "QuickDraw Drawing" and "Color QuickDraw" in Inside Macintosh: Imaging.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
6 JUL 1996