iPhone SDK复制文件到主系统
非常感谢@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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
实际上无需任何修改即可支持自定义字体。 看一下此代码示例。
Custom fonts are actually supported without any hacks. Take a look at this code sample.