简体   繁体   English

是否可以在应用程序中使用iOS 7的修改版Helvetica?

[英]Is it possible to use iOS 7's modified Helvetica in apps?

For iOS 7, Apple made a special modified version of Helvetica Thin/Light that has rounded periods and colons: 对于iOS 7,Apple制作了特殊的Helvetica Thin / Light修改版,该版本具有圆角和冒号:

在此处输入图片说明

Compare this to using Helvetica-Neue Thin or Helvetica-Neue Light in Xcode: 与在Xcode中使用Helvetica-Neue Thin或Helvetica-Neue Light进行比较:

在此处输入图片说明

Is it possible to develop apps with the special modified version with the rounded colons and periods? 是否可以使用带有修改后的冒号和句号的特殊修改版来开发应用程序?

EDIT : Turns out these round colons and periods are not custom designed by Apple, they are "character alternates" and you can see them in your favorite font glyph viewer. 编辑 :原来这些圆形冒号和句点不是Apple定制设计的,它们是“字符替代”,您可以在自己喜欢的字体字形查看器中看到它们。

Here's how to do it. 这是操作方法。 Even reading the documentation, it's very unclear. 即使阅读文档,也不清楚。

First, you have to get the characteristics of a font, which will give you the constants to use in your UIFontDescriptorFeatureSettingsAttribute . 首先,您必须获取字体的特征,这将为您提供要在UIFontDescriptorFeatureSettingsAttribute使用的UIFontDescriptorFeatureSettingsAttribute I got mine from this post . 我从这个职位上得到了我。

This gives you feature type identifier keys, and your options for their values, the feature selector identifier keys. 这为您提供了特征类型标识符键,以及它们的值选项,特征选择器标识符键。

NSArray *timerDisplaySettings = @[
                                      @{ UIFontFeatureTypeIdentifierKey: @(6),
                                        UIFontFeatureSelectorIdentifierKey: @(1)
                                     },
                                      @{ UIFontFeatureTypeIdentifierKey: @(17),
                                        UIFontFeatureSelectorIdentifierKey: @(1)
                                        }];

then you create a font descriptor by adding to a descriptor - this way you can specify the font name and family via UIFont : 然后通过添加一个描述符来创建字体描述符-这样,您可以通过UIFont指定字体名称和字体:

UIFont *font = [UIFont fontWithName:@"HelveticaNeue-UltraLight" size:32];

UIFontDescriptor *originalDescriptor = [font fontDescriptor];
UIFontDescriptor *timerDescriptor =[originalDescriptor fontDescriptorByAddingAttributes: @{ UIFontDescriptorFeatureSettingsAttribute: timerDisplaySettings }];

Then, close the loop and create the font with your descriptor. 然后,关闭循环并使用描述符创建字体。 (The size "0.0" simply means we aren't scaling it from its original size of 32. (大小“ 0.0”仅表示我们并未将其从原始大小32缩放。

UIFont *timerFont = [UIFont fontWithDescriptor: timerDescriptor size:0.0];

For the sake of future readers, to see the font features array, in Objective-C it is: 为了将来的读者,在Objective-C中查看字体特征数组是:

@import CoreText;

and

- (void)fontFeatures:(UIFont *)font {
    NSArray *features = CFBridgingRelease(CTFontCopyFeatures((__bridge CTFontRef)font));

    if (features) {
        NSLog(@"%@: %@", font.fontName, features);
    }
}

For HelveticaNeue-UltraLight that yields: 对于HelveticaNeue-UltraLight ,它产生:

HelveticaNeue-UltraLight: (
        {
        CTFeatureTypeIdentifier = 1;
        CTFeatureTypeName = Ligatures;
        CTFeatureTypeNameID = 258;
        CTFeatureTypeSelectors =         (
                        {
                CTFeatureSelectorDefault = 1;
                CTFeatureSelectorIdentifier = 2;
                CTFeatureSelectorName = "Common Ligatures";
                CTFeatureSelectorNameID = 259;
            }
        );
    },
        {
        CTFeatureTypeExclusive = 1;
        CTFeatureTypeIdentifier = 6;
        CTFeatureTypeName = "Number Spacing";
        CTFeatureTypeNameID = 262;
        CTFeatureTypeSelectors =         (
                        {
                CTFeatureSelectorDefault = 1;
                CTFeatureSelectorIdentifier = 0;
                CTFeatureSelectorName = "No Change";
                CTFeatureSelectorNameID = 264;
            },
                        {
                CTFeatureSelectorIdentifier = 1;
                CTFeatureSelectorName = "Proportional Numbers";
                CTFeatureSelectorNameID = 263;
            }
        );
    },
        {
        CTFeatureTypeExclusive = 1;
        CTFeatureTypeIdentifier = 17;
        CTFeatureTypeName = "Character Alternatives";
        CTFeatureTypeNameID = 265;
        CTFeatureTypeSelectors =         (
                        {
                CTFeatureSelectorDefault = 1;
                CTFeatureSelectorIdentifier = 0;
                CTFeatureSelectorName = "No Change";
                CTFeatureSelectorNameID = 264;
            },
                        {
                CTFeatureSelectorIdentifier = 1;
                CTFeatureSelectorName = "Time Punctuation";
                CTFeatureSelectorNameID = 266;
            },
                        {
                CTFeatureSelectorIdentifier = 2;
                CTFeatureSelectorName = "Compass Punctuation";
                CTFeatureSelectorNameID = 267;
            },
                        {
                CTFeatureSelectorIdentifier = 3;
                CTFeatureSelectorName = "Weather Punctuation";
                CTFeatureSelectorNameID = 268;
            },
                        {
                CTFeatureSelectorIdentifier = 4;
                CTFeatureSelectorName = "Round Lowercase Punctuation";
                CTFeatureSelectorNameID = 269;
            }
        );
    }
)

Thus, in iOS 8, for HelveticaNeue-UltraLight , key 17 is "Character Alternatives", and value 1 is "Time Punctuation". 因此,在iOS 8中,对于HelveticaNeue-UltraLight ,键17为“字符替代”,值1为“时间标点”。


To see these features in Swift, it is: 要在Swift中查看这些功能,它是:

import CoreText

and

func fontFeatures(font: UIFont) {
    if let features = CTFontCopyFeatures(font) as NSArray! {
        println("\(font.fontName): \(features)")
    }
}

Yes, these features are accessible to you via iOS 7's new Dynamic Type system. 是的,您可以通过iOS 7的新Dynamic Type系统访问这些功能。 http://tirania.org/monomac/archive/2013/Sep-25.html http://tirania.org/monomac/archive/2013/Sep-25.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 是否可以在运行时检测旁加载、重新签名或修改的 iOS 应用程序? - Is it possible to detect sideloaded, re-signed, or modified iOS apps at runtime? iOS 7和Helvetica Neue UltraLight:用作旧版iOS的默认设置 - iOS 7 and Helvetica Neue UltraLight: use as default for older iOS versions Helvetica Neue Light,iOS - Helvetica Neue Light,iOS 是否可以使用iOS私有API从应用程序内部修改限制? - Is it possible to use an iOS private API to modify restrictions from within apps? 我可以为 APK 等 iOS 应用程序使用自定义证书吗 - Can i use custom certificate for iOS apps like APK's 如何在程序中使用Xcode在iOS中使用自定义字体(例如:Helvetica CY.ttf) - How to use custom font in iOS ( Eg: Helvetica CY.ttf ) with Xcode programatically iOS7:我们可以使用除动态类型的Helvetica Neue字体以外的其他字体吗? - iOS7: Can we use other than Helvetica Neue fonts with Dynamic Type? 我可以在没有许可证的情况下构建的商业 iOS 应用程序中使用 Helvetica 字体吗? - Can I use the Helvetica font in a commercial iOS app that I am building without a license? 在Cordova混合应用程序中使用Helvetica Neue - Using Helvetica Neue in Cordova Hybrid Apps 是否可以在 ios 中获取已安装的应用程序 - Is it possible to get installed apps in ios
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM