Tushar
Tushar

Reputation: 3052

What font to use to display these unicode characters in iOS 8+

I'm using Arial font available in the system to display some unicode characters and able to display most of the characters except the following symbols which are part of arrow category :

⟼, ⤎, ⤏

The corresponding unicodes are: \u{27FC}, \u{290E}, \u{290F}

I'm displaying them on UIButton. Any idea what font supports these unicode characters on iOS 8 and above ?

It shows question mark as Arial doesn't support the glyphs for these, Here is a screenshot:

enter image description here

Appreciate any help. Thanks for your time.

Upvotes: 4

Views: 3198

Answers (1)

Ashley Mills
Ashley Mills

Reputation: 53101

The answer… none, I'm afraid.

At least not according to this pretty hacky test…

extension unichar {
    func isSupportedBy(fontName: String) -> Bool {
        let characters = [self]
        var glyphs: [CGGlyph] = []
        let ctFont = CTFontCreateWithName(fontName as CFString, 15, nil)
        return CTFontGetGlyphsForCharacters(ctFont, characters, &glyphs, 1)
    }
}

UIFont.familyNames.map({
    UIFont.fontNames(forFamilyName: $0)
}).joined().forEach({
    for string in ["A", "\u{27FC}", "\u{290E}", "\u{290F}"].map({$0.utf16}){
        if let char = string.first {
            if char.isSupportedBy(fontName: $0) {
                print("\($0) supports \(string)")
            } else {
                print("\($0) does not support \(string)")
            }
        } else {
            print("invalid char \(string)")
        }
    }
})

Copperplate-Light supports A
Copperplate-Light does not support ⟼
Copperplate-Light does not support ⤎
Copperplate-Light does not support ⤏

etc

EDIT:

Checking the character input window in macOS, it seems that these particular glyphs are available in STIXGeneral-Regular and Apple Symbols fonts. Maybe you could add one of these as a custom font to your iOS app?

enter image description here

Upvotes: 6

Related Questions