DrawString
DrawString
Draw a length-prefixed string of characters Str255 theString ; address of Pascal-style string a specified string. No line-formatting is performed.
Notes: The string is drawn in the current font, size, style, and transfer mode, as
defined in the current GrafPort structure. Each character is drawn with its base line on the current vertical coordinate of the pen location (see
MoveTo). After the text is drawn, the pen is positioned after the last character drawn; i.e., ready for writing the next character. See
If you use scaled or fractional-width fonts while drawing a string,
DrawString may draw a string with a length different from the length that repeatedly calling CharWidth computes and different from the length of the string that reapeatedly calling DrawChar draws. However, StringWidth always computes the proper length of the string that DrawString draws. The differences are due to rounding errors, since QuickDraw uses fixed-point math. For example, if the current size is 11
but the System file doesn't contain an 11-point version of that font, the
System will scale the 12-point version down and will probably en counter
rounding errors.
Before drawing a character, make sure the current GrafPort is big enough to contain it. If the GrafPort is not as wide as the character, your program will crash with an address error.
This function does no special line-formatting. Linefeeds, carriage returns,
tab characters, etc., are treated like other characters and will probably be
displayed as the font's "missing" symbol. Drawing is clipped to the existing
clipping regions.
It may be advantageous to use DrawText, which does not require a length-prefixed string; however, most C compilers let you define a
Pascal-style string by prefixing it with \p; e.g.:
Str255 theMsg = "\pThis is a message";
Also, your compiler probably has a library function such as CtoPstr to aid
in such con versions: