在Cocoa中为NSMenuItem获取默认字体名称? [英] Get default font name in Cocoa for NSMenuItem?

查看:230
本文介绍了在Cocoa中为NSMenuItem获取默认字体名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用NSAttributed NSString在我的NSMenuItem,但它的字体更改为比较默认字体,我想使用默认字体的属性字符串。

I am using NSAttributed NSString in my NSMenuItem, but it's Font is changed as compare to default font, I wants to use default font for Attributed string.

一个解释,如何找到或获取默认的字体NSMenuItems。

Can any one explain, how to find or fetch the default Font for NSMenuItems.

现在我使用这个:

Right now I am using this :

 NSDictionary *attributes = @{
                                 NSFontAttributeName: [NSFont fontWithName:@"Helvetica" size:14],
                                 NSForegroundColorAttributeName: [NSColor blackColor],
                                 NSParagraphStyleAttributeName:paragraphStyle

                                 };

感谢

推荐答案

我得到了解决方案,我使用这个

I got the solution, I used this

NSFont *oldFont = [menu font];
NSLog(@"%@",oldFont.familyName);

并像这样使用

NSDictionary *attributes = @{
                                 NSFontAttributeName:[NSFont fontWithName:@"Lucida Grande" size:14],
                                 NSForegroundColorAttributeName: [NSColor blackColor],
                                 NSParagraphStyleAttributeName:paragraphStyle

                                 };

这篇关于在Cocoa中为NSMenuItem获取默认字体名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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