在iOS上,我可以访问系统提供的字体的TTF文件吗? [英] On iOS, can I access the system-provided font's TTF file

查看:192
本文介绍了在iOS上,我可以访问系统提供的字体的TTF文件吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试 FTGLES 在iOS上的OpenGL-ES上以任意字体动态显示文本(请参见我的SO问题此处).该库似乎需要直接访问TTF文件才能使用该字体.使用洁净方法,可以通过路径直接访问iOS上的系统字体文件吗?我已经RTFM了,找不到任何东西.

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.

除此以外,有谁知道是否经Apple批准将系统字体复制到您的应用程序中(提交之前).

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

推荐答案

我的解决方案受到了Skia的启发.

My solution was inspired by skia.

尽管不能直接访问系统内置字体文件,但我们仍然可以采用间接方式:

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

使用所需的字体名称创建一个CGFont,只需调用CGFontCopyTableTags()和CGFontCopyTableForTag()即可访问此CGFont的SFNT表的所有内容.

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().

然后可以使用这些表来构建ttf/otf字体数据,将新创建的字体保存到磁盘中,以后可以在FTGL ES中使用它.

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.

这篇关于在iOS上,我可以访问系统提供的字体的TTF文件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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