【问题标题】:Location of the fonts on the iPhone?iPhone上字体的位置?
【发布时间】:2011-02-03 03:41:05
【问题描述】:

我在一个 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 应用程序根本没有对该目录的任何读取权限。

谢谢!

【问题讨论】:

  • 还有,所以大家都知道。我确实继续在我的项目中添加了一个 .ttf 以查看它是否会加载它,是的,它确实如此。我只是不确定系统字体是否指定错误,或者我无权访问它。
  • 出于可移植性的原因,我想使用 FreeType。

标签: iphone fonts filesystems freetype2


【解决方案1】:

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

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

一旦你解析它,你会找到你的字体的条目:

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

【讨论】:

【解决方案2】:

它们位于/System/Library/Fonts//System/Library/Fonts/Cache。但是,我怀疑您可能没有访问这些目录所需的权限。

【讨论】:

    猜你喜欢
    • 2017-02-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-27
    • 2010-10-01
    相关资源
    最近更新 更多