20 Drawing Text with Attributes

In Chapter 17, we covered drawing shapes with NSBezierPath. A natural progression from there would be to draw text. In this chapter you will add support for drawing text on the die face to extend the range to [0, 9]. At the end of this chapter, your application will look like Figure 20.1.

Figure 20.1  Completed application

Completed application

NSFont

Overall, the class NSFont has only two types of methods:

  1. class methods for getting the font you want

  2. methods for getting metrics on the font, such as letter height

The following are commonly used methods in NSFont:

 ​ ​c​l​a​s​s​ ​f​u​n​c​ ...

Get Cocoa Programming for OS X: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.