【问题标题】:How to use italic LucidaGrande font for a Cocoa App如何为 Cocoa 应用程序使用斜体 LucidaGrande 字体
【发布时间】:2010-12-17 05:54:24
【问题描述】:

最近我正在为我的应用程序进行 Carbon 到 Cocoa 的转换。

我的App使用的字体是“LucidaGrande”,我是通过这个方法得到的:

myUIFont = [NSFont systemFontOfSize: [NSFont systemFontSize]];

有时我的应用想在其 UI 中显示斜体样式字体,所以我称之为:

myUIFont = [[NSFontManager sharedFontManager] convertFont:myUIFont toHaveTrait:NSItalicFontMask];

但此转换失败。我发现这是因为“LucidaGrande”字体没有斜体样式。我可以通过调用来验证这一点:

NSArray* availableNames = [[NSFontManager sharedFontManager] availableFontNamesWithTraits:NSItalicFontMask];

availableNames 中没有“LucidaGrande”。这很好奇,因为我可以在我的 Carbon 应用程序中使用斜体“LucidaGrande”字体。是否有任何解决方案可以为 Cocoa App 获取斜体“LucidaGrande”字体?或者我怎样才能得到一个类似的斜体?

非常感谢!

【问题讨论】:

    标签: cocoa fonts


    【解决方案1】:

    Lucida Grande 本身没有斜体版本。碳文本 API 通过倾斜常规版本来伪造它。 Lucida Sans 和 Lucida Sans Unicode(常规)在它们的拉丁子集中是相同的,并且有斜体版本,但不随操作系统提供。

    【讨论】:

    • 另请注意,如果要求 WebKit 显示斜体,Lucida Grande 将改为使用 Helvetica Italic。
    • 谢谢!现在我知道为什么 Carbon App 可以有斜体 LucidaGrande 字体了。我还发现这个链接对我非常有用:stackoverflow.com/questions/1724647/…
    猜你喜欢
    • 2016-11-02
    • 1970-01-01
    • 2022-09-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多