我有一个Mac应用程序,其中具有自定义字体,而我的Mac上的应用程序文件夹的自定义字体簿中没有该自定义字体.
因此,当应用启动时,我使用以下代码检查了是否在Mac中安装了字体.
NSArray *fonts = [[NSFontManager sharedFontManager] availableFontFamilies]; if ([fonts containsObject:@"Square721 BT"]) { NSLog(@"Fonts Available"); } else { NSLog(@"No fonts"); }现在,如果尚未安装该字体,该如何以编程方式安装它?
解决方案
请参阅: developer.apple/library/mac/documentation/General/Reference/InfoPlistKeyReference/Articles/GeneralPurposeKeys.html#//apple_ref/doc/uid/TP40009253-SW8
这是一个相关的堆栈溢出答案: stackoverflow/a/29003792/3342547
I am having a mac app in which I have custom font which is not there in my custom font book of application folder in my mac.
So, when an app launches, I checked it that if a font is installed in mac or not with the below code.
NSArray *fonts = [[NSFontManager sharedFontManager] availableFontFamilies]; if ([fonts containsObject:@"Square721 BT"]) { NSLog(@"Fonts Available"); } else { NSLog(@"No fonts"); }Now, if the font is not already installed, how can I install it programmatically?
解决方案See: developer.apple/library/mac/documentation/General/Reference/InfoPlistKeyReference/Articles/GeneralPurposeKeys.html#//apple_ref/doc/uid/TP40009253-SW8
And here's a relevant Stack Overflow answer: stackoverflow/a/29003792/3342547
更多推荐
如何在MacOS中以编程方式在Mac中安装自定义字体
发布评论