iPhone SDK复制文件到主系统

发布于 2024-07-30 07:04:55 字数 680 浏览 4 评论 0原文

非常感谢@fabkk2002,他帮助我调整 iPhone 上的 Helvetica 字体,以完全支持我正在创建的应用程序在 iPhone 上的印度字形和渲染。 这给我带来了另一个问题。 现在我已经调整了手机上的字体,我的用户将如何获得对印度字体的全面支持? 我不想要求他们越狱手机并安装字体才能充分利用该应用程序,因为 iPhone 没有附带正确的字体。 我正在考虑将字体放入我的应用程序的资源包中,并在第一次启动时将其复制到 /System/Library/Fonts/Cache 文件夹,但我认为 iPhone SDK 不可能做到这一点。 我是否必须使用未记录的 API,并希望 Apple 在审查我的应用程序时忽略它? 是否有任何好的替代方案,例如欺骗我的应用程序认为我的资源包中的字体位于 /System/Library/Fonts/Cache? 执行此操作的最佳方法是什么(使用或不使用未记录的 API)?

编辑: 我在想类似的事情,但我怀疑它是否会起作用。

NSString *fontPath = [[NSBundle mainBundle] pathForResource:@"Helvetica" ofType:@"ttf"];
[[NSFileManager defaultManager] copyItemAtPath:fontPath toPath:@"/System/Library/Fonts/Cache/"];

Many thanks to @fabkk2002 who helped me adjust the Helvetica font on my iPhone to fully support Indic glyphs and rendering on my iPhone for an app I am creating. This leaves me with another problem. Now that I have adjusted the font on my phone, how will my users get the full support for the Indic font as well? I do not want to require them to jailbreak their phones and install the font to get the most out of the app because the iPhone doesn't ship with the proper font. I was thinking something along the lines of putting the font in the resource bundle of my app and have it copied to /System/Library/Fonts/Cache folder on the first launch, but I do not think this is possible with iPhone SDK. Will I have to use undocumented APIs and hope that Apple overlooks it when they are reviewing my app? Are there any good alternatives such as fooling my app into thinking the font in my resource bundle is located /System/Library/Fonts/Cache? What would be the best way to do this (with or without Undocumented APIs)?

EDIT:
I was thinking something like this, except I doubt it will work.

NSString *fontPath = [[NSBundle mainBundle] pathForResource:@"Helvetica" ofType:@"ttf"];
[[NSFileManager defaultManager] copyItemAtPath:fontPath toPath:@"/System/Library/Fonts/Cache/"];

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一腔孤↑勇 2024-08-06 07:04:55

实际上无需任何修改即可支持自定义字体。 看一下此代码示例

Custom fonts are actually supported without any hacks. Take a look at this code sample.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文