Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

On iOS, can I access the system-provided font's TTF file

I'm trying out FTGLES to dynamically display text in arbitrary fonts on OpenGL-ES on iOS (cf. my SO question here). That library seems to require direct access to the TTF file to use the font. Using kosher methods, can one directly access -- by path -- the system font files on iOS? I've RTFM'd and couldn't find anything.

Barring that, does anyone know if it is Apple-approved to copy the system fonts into your app (before submission).

like image 662
Clay Bridges Avatar asked Sep 11 '10 21:09

Clay Bridges


1 Answers

My solution was inspired by skia.

Though cannot access system built-in font files directly, we still have an indirect way:

Create a CGFont with your wanted font name, all contents of SFNT table of this CGFont can be accessed by simply calling CGFontCopyTableTags() and CGFontCopyTableForTag().

A ttf/otf font data can then be constructed by using these tables, save the new created font to disk, you can use it in FTGL ES later.

like image 81
EXphinx Avatar answered Sep 26 '22 05:09

EXphinx