Cocoa应用程序中的自定义字体 [英] Custom font in a Cocoa application

查看:124
本文介绍了Cocoa应用程序中的自定义字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道你可以通过使用Interface Builder并选择字体来自定义字体。但是,我很好奇,如果我可以使用系统上默认不包括的自定义字体。有没有办法在我的应用程序中包含自定义字体?

I know you can customize fonts by using Interface Builder and selecting a font. However, I'm curious if I can use a custom font that's not included by default on systems. Is there a way to include a custom font in my application?

推荐答案

虽然手动字体激活过程是一个选项,还要考虑 ATSApplicationFontsPath Info.plist键:

While the manual font activation procedure is one option, you might also consider the ATSApplicationFontsPath Info.plist key:

信息属性列表键参考


ATSApplicationFontsPath String - Mac
OS X)标识
软件包 Resources 目录中
字体文件或字体目录的位置,如果
存在,Mac OS X激活
捆绑应用程序使用的指定路径下的字体
。字体
仅对捆绑的
应用程序激活,而不是系统
路径本身应该是
指定为
的相对目录bundle的Resources目录。对于
示例,如果字体目录是
在路径
/Applications/MyApp.app/Contents/Resources/Stuff/MyFonts /
你应该为这个
键的值指定字符串
Stuff / MyFonts /

"ATSApplicationFontsPath (String - Mac OS X) identifies the location of a font file or directory of fonts in the bundle’s Resources directory. If present, Mac OS X activates the fonts at the specified path for use by the bundled application. The fonts are activated only for the bundled application and not for the system as a whole. The path itself should be specified as a relative directory of the bundle’s Resources directory. For example, if a directory of fonts was at the path /Applications/MyApp.app/Contents/Resources/Stuff/MyFonts/, you should specify the string Stuff/MyFonts/ for the value of this key."

我一定要仔细检查,但我相信这个功能是在OS X 10.5.x中添加的)。

I'd be sure to double-check, but I believe this functionality was added in OS X 10.5.x (which the code posted by Jinhyung Park targets).

这篇关于Cocoa应用程序中的自定义字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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