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​)​

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.