在 iOS 8+ 中使用什么字体来显示这些 un​​icode 字符

Tus*_*har 3 unicode xcode fonts ios swift

我正在使用系统中可用的 Arial 字体来显示一些 unicode 字符,并且能够显示大多数字符,除了以下属于箭头类别的符号:

?, ?, ?

对应的unicodes是:\u{27FC}、\u{290E}、\u{290F}

我在 UIButton 上显示它们。知道什么字体在 iOS 8 及更高版本上支持这些 un​​icode 字符吗?

它显示问号,因为 Arial 不支持这些字形,这是一个屏幕截图:

在此处输入图片说明

感谢任何帮助。谢谢你的时间。

Ash*_*lls 5

答案……恐怕没有。

至少不是根据这个非常hacky的测试......

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)")
        }
    }
})
Run Code Online (Sandbox Code Playgroud)
Copperplate-Light supports A
Copperplate-Light does not support ?
Copperplate-Light does not support ?
Copperplate-Light does not support ?

etc
Run Code Online (Sandbox Code Playgroud)

编辑:

检查 macOS 中的字符输入窗口,似乎这些特殊字形在STIXGeneral-RegularApple Symbols字体可用。也许您可以将其中一种作为自定义字体添加到您的 iOS 应用程序中?

在此处输入图片说明