I was trying to draw some text with a downloaded font. I looked at API documentation and searched the Web. I found a solution, but the problem is that it’s applicable to only the CoreGraphics level framework. So I searched for a way to convert CGFont to UIFont, but there was no way to do this.
I realized UIFont and CGFont/CTFont are separated completely, even though they’re created from same font file. CGFont and CTFont are convertible from/to each other, but for UIFont, the only way is recreating with its attributes like name and size. And applicable codes are also separated.
For instance, CATextLayer accepts only CGFont/CTFont — no UIFont. But all UIKit controls accept only UIFont.
Why does this separation exist? Or am I wrong? (Any way to use a downloaded font in UIKit classes?)
The short answer : “Only Apple folks knows”
The more detailed answer, after digging (reversing) frameworks a bit:
UIKit.frameworkdoesn’t use at allCGFonttypeUIKit.frameworkuse instead CoreTextCTFontandGSFont…GSFontcomes from… theGraphicsServicesprivate frameworkGraphicsServices… useCGFontSo here is my guess (Might be completely wrong) :
UIFont>GSFont(Private) >CGFontUIKit>GraphicsServices>CoreGraphics:iOS>iOS(Private) >Mac OSX:About using custom fonts with
UIKit, you might be interested reading this.