Drawing Simple Strings


The API of a CGContext includes a few routines that allow you to draw simple strings. These routines handle the entire text pipeline from character to glyph mapping, all the way to drawing in the context. Unfortunately, these routines are only useful for drawing strings in the MacRoman encoding. If your application needs to draw text in any other encoding, you should probably use the higher-level text mechanisms.

The most basic routine in this category is CGContextShowText. This routine simply accepts a pointer to a string and a length and draws that string at the current text position using the current text settings. You can also use the routine CGContextShowTextAtPoint, which allows you to specify a location for the string as parameters rather than relying on the current text position.

These text routines are the ones that were used in the Ace of Hearts bakery example in Chapter 3, "Introduction to Quartz 2D." Our needs for that sample were very basic, and all the text used was MacRoman, which made the simple string routines a perfect choice for that simple example.




Quartz 2D Graphics for Mac OS X Developers
Quartz 2D Graphics for Mac OS X Developers
ISBN: 0321336631
EAN: 2147483647
Year: 2006
Pages: 100

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net