Location of the fonts on the iPhone?

╄→гoц情女王★ 提交于 2019-12-21 17:39:27

问题


I'm using the FreeType2 library in an iPhone project, and I'm trying to simply load a TTF file from the system, if possible.

FT_Library  library;
FT_Face face;
int error;


error = FT_Init_FreeType( &library );

if ( error == 0 )
     printf("Initialized FreeType2\r\n");   /* Prints */

error = FT_New_Face(library, "/System/Library/Fonts/Helvetica.ttf", 0, &face);

if ( error ==  FT_Err_Cannot_Open_Resource )
    printf("Font not found\r\n");         /* Prints */

That error seems to be for file not found. Is /System/Library/Fonts not the location of the fonts? Or, do iPhone apps simply not have any read access at all to that directory.

Thanks!


回答1:


To find the fonts installed on your device, load the font manifest (a plist):

NSDictionary *cgFonts = [NSDictionary dictionaryWithContentsOfFile:@"/System/Library/Fonts/CGFontCache.plist"];

Once you parse it, you'll find the entry for your font:

Helvetica = "/System/Library/Fonts/Cache/Helvetica.ttf";



回答2:


They're either in /System/Library/Fonts/ or /System/Library/Fonts/Cache. However, I suspect that you may not have the required permissions to access those directories.



来源:https://stackoverflow.com/questions/2556874/location-of-the-fonts-on-the-iphone

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!