I'm trying to use a font that has small caps. I found a UIFont extension on some guy's website that claimed it would do small caps but alas, no luck. Any ideas?
extension UIFont {
func smallCapsFontVariant(smallCapsForUppercase: Bool = true) -> UIFont {
var features = [
[UIFontFeatureTypeIdentifierKey: kLowerCaseType,
UIFontFeatureSelectorIdentifierKey: kLowerCaseSmallCapsSelector]
]
if smallCapsForUppercase {
features.append([UIFontFeatureTypeIdentifierKey: kUpperCaseType,
UIFontFeatureSelectorIdentifierKey: kUpperCaseSmallCapsSelector])
}
let smallCapsFontDescriptor = fontDescriptor().fontDescriptorByAddingAttributes([
UIFontDescriptorFeatureSettingsAttribute : features
])
return UIFont(descriptor: smallCapsFontDescriptor, size: 0d)
}