使用Storyboard在Mac SDK中自定义字体 [英] Custom fonts in Mac sdk using storyboard

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

问题描述

如何在Mac App开发中向故事板添加自定义字体.我浏览了一些博客,尝试添加字体书,并使用情节提要使用此自定义字体开发了一个NStextfield.但这取决于系统.我创建了DMG,并使用默认字体将其安装在另一台计算机上.我是以编程方式完成的,但我的要求是通过情节提要. 请帮助我

How to add a custom font to storyboard in Mac app development. I went through some blogs and tried by adding font book and develop one NStextfield using this custom font using storyboard. But it is system dependent. I created the DMG and install in another computer it uses the default font. I did it programmatically, but my requirement is through storyboard. Please help me on this

推荐答案

我花了一些时间试图弄清楚这一点,发现此相关问题的解决方案.

I spent a bit of time trying to figure this out and found the solution in this related question.

在您的info.plist文件中,您可以通过以下网址使用该文件

In your info.plist file, which you made available to me at

事实证明,您可以放心地摆脱应用程序提供的字体"部分(它是iOS特定的键,macOS会将其忽略).

It turns out you can safely get rid of the "Fonts Provided By Application" section (it's an iOS specific key and is ignored by macOS).

对于应用程序字体资源路径",请确保将字体放入字体"文件夹(或应用程序捆绑包的资源"文件夹中的某些子文件夹).

And for "Application Fonts resource path", make certain you have the font going into a "Fonts" folder (or some subfolder within your application bundle's Resources folder).

最后,执行一个自定义副本构建阶段,如下所示:

Lastly, do a custom copy build phase like this:

这会将字体复制到应用程序字体资源路径"中指定的字体"子文件夹中.您不需要字体在资源"文件夹中,但是想要在资源"下面的子文件夹中使用.

This is copying the font into the "Fonts" subfolder specified in your "Application Fonts resource path". You don't want the font in your Resources folder, but you do want it in a subfolder underneath Resources.

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

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