Reputation: 2212
FreeType supports emoji character since version 2.5. I want to render the emoji via FreeType and then use it in OpenGL, so no UIKit API would be used here. However, I don't want, neither I don't have the license, to ship an "Apple Color Emoji.ttf" file with my app.
So the question: Is there any way to load the system emoji font file on the iOS device? Is there any Objective-c or c/c++ API could access the system emoji font file?
Upvotes: 4
Views: 2796
Reputation: 213578
First of all, let's clear up a misconception. You don't have to use UIKit to render fonts using system libraries on iOS. You can use Core Text (which has a regular old C interface) to render text directly into an offscreen buffer, and use that buffer as a texture with OpenGL. This will automatically handle a positively enormous amount of work that you'd otherwise be doing yourself:
Character encodings
Text shaping
Line breaking
Kerning
Glyph substitution
Font selection (bold, italic, etc)
Et cetera
Core Text is really a substitute for FreeType + HarfBuzz + Pango + ICU. I would only use FreeType directly if I wanted to do something which Core Text can't do as easily, like render glyphs into an sprite sheet and use that to draw text, or if I wanted to share code across platforms.
Now, if you're convinced that it's worth the extra weeks to do it yourself, you'll have to parse the /System/Library/Fonts/CGFontCache.plist
file to find the location of your desired font. See: Location of the fonts on the iPhone?
Upvotes: 5