Created
September 12, 2023 12:17
-
-
Save michaelevensen/c72133612bf2c7538df152250a970753 to your computer and use it in GitHub Desktop.
This is how you can use font features in Swift.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static let book: Font = { | |
// Font features | |
let fontFeatureSettings: [CFDictionary] = [ | |
[ | |
kCTFontFeatureTypeIdentifierKey: kTypographicExtrasType, | |
kCTFontFeatureSelectorIdentifierKey: kSlashedZeroOnSelector | |
] as CFDictionary | |
] | |
// Font description | |
let fontDescriptor = CTFontDescriptorCreateWithAttributes([ | |
kCTFontFeatureSettingsAttribute: fontFeatureSettings | |
] as CFDictionary) | |
let font = CTFontCreateWithName("SuisseIntl-Book" as CFString, 18, nil) | |
let fontWithFeatures = CTFontCreateCopyWithAttributes(font, 18, nil, fontDescriptor) | |
return Font(fontWithFeatures) | |
}() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment