Important: The information in this document is obsolete and should not be used for new development.
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
andCGrafPort
), to identify the current graphics port. You use the global variablethePort
to indicate the current port. In the following example,SetPort
identifies the port pointed to bythePort
as the current one.
SetPort(thePort);For more information about theSetPort
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.