iPhone上的字体的位置? [英] Location of the fonts on the iPhone?

查看:170
本文介绍了iPhone上的字体的位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果可能的话,我正在试图从系统中加载一个TTF文件。

  FT_Library库; 
FT_Face脸;
int错误;


error = FT_Init_FreeType(& library);

if(error == 0)
printf(Initialized FreeType2 \r\\\
); / *打印* /

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

if(error == FT_Err_Cannot_Open_Resource)
printf(Font not found \r\\\
); / *打印* /

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

谢谢!

解决方案

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

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

分析完成后,您会发现字体的条目:

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


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!

解决方案

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";

这篇关于iPhone上的字体的位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆