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 / Using QuickDraw Text


Setting Up the Text-Drawing Environment

You draw text in the current graphics port. You create a distinct graphical environment for every window on the screen by specifying values for the graphics port. Each graphics port has its own complete drawing environment--including its own coordinate system, drawing location, font set, and character attributes.

Because your application can have more than one window open at the same time, QuickDraw routines access the data structures within the current graphics port only. You must keep track of the current graphics port and identify it to QuickDraw when you change windows.

You can use the QuickDraw SetPort procedure, which operates on both types of graphics ports (GrafPort and CGrafPort), to identify the current graphics port. You use the global variable thePort to indicate the current port. In the following example, SetPort identifies the port pointed to by thePort as the current one.

SetPort(thePort);
For more information about the SetPort procedure, see Inside Macintosh: Imaging.

Each time you draw text in a window's graphics port, you need to set the text-related fields of the graphics port to the characteristics of the text that you want to draw, if they differ from the current ones. A graphics port record contains three fields that determine how text is drawn--the font, style, and size of glyphs--and one that specifies how it will be placed in the bit image, the transfer mode. In addition to these fields, a graphics port record contains two fields that let you specify character widths to define how text is to be formatted on a line.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
6 JUL 1996