O'Reilly logo

Cocoa Programming for OS X: The Big Nerd Ranch Guide by Aaron Hillegass, Adam Preble, Nate Chandler

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

For the More Curious: NSFontManager

Sometimes, you will find a font that is good but would be perfect if it were bold or italicized or condensed. NSFontManager can be used to make this sort of conversion. You can also use a font manager to change the size of the font.

For example, imagine that you have a font and would like a similar font but bold. Here is the code:

l​e​t​ ​f​o​n​t​M​a​n​a​g​e​r​ ​=​ ​N​S​F​o​n​t​M​a​n​a​g​e​r​.​s​h​a​r​e​d​F​o​n​t​M​a​n​a​g​e​r​(​)​
l​e​t​ ​b​o​l​d​F​o​n​t​ ​=​ ​f​o​n​t​M​a​n​a​g​e​r​.​c​o​n​v​e​r​t​F​o​n​t​(​s​o​m​e​F​o​n​t​,​
 ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​t​o​H​a​v​e​T​r​a​i​t​:​ ​N​S​F​o​n​t​T​r​a​i​t​M​a​s​k​.​B​o​l​d​F​o​n​t​M​a​s​k​)​

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required