字体在 iPhone 上的位置?

2024-02-29

我正在 iPhone 项目中使用 FreeType2 库,并且如果可能的话,我尝试简单地从系统加载 TTF 文件。

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 */

该错误似乎是因为找不到文件。 /System/Library/Fonts 不是字体的位置吗?或者,iPhone 应用程序根本没有对该目录的任何读取访问权限吗?

Thanks!


要查找设备上安装的字体,请加载字体清单(plist):

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

解析它后,您将找到您的字体的条目:

Helvetica = "/System/Library/Fonts/Cache/Helvetica.ttf";
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

字体在 iPhone 上的位置? 的相关文章

随机推荐