• 判断Emoji在当前系统版本能否正常显示


    1. /// 当前系统是否支持emoji展示,以下两个判断条件
    2. /// 1.必须字体库支持 2.展示时不能被分割成多个emoji
    3. private var isEmojiSupported: Bool {
    4. // 字符数不应该超过1
    5. guard count == 1 else {
    6. return false
    7. }
    8. let uniChars = Array(utf16)
    9. let font = CTFontCreateWithName("AppleColorEmoji" as CFString, 0.0, nil)
    10. var glyphs: [CGGlyph] = [0, 0]
    11. let visible = CTFontGetGlyphsForCharacters(font, uniChars, &glyphs, uniChars.count)
    12. let emojiWidth = ceil(self.size(withAttributes: [.font: UIFont.systemFont(ofSize: 12)]).width)
    13. let standardEmojiWidth = ceil("😊".size(withAttributes: [.font: UIFont.systemFont(ofSize: 12)]).width)
    14. let unseparated = emojiWidth == standardEmojiWidth
    15. return visible && unseparated
    16. }

  • 相关阅读:
    Linux 回收内存
    Go基础-2
    [C++]多态
    python开发MYSQL代理服务器
    ios环境搭建
    一、react简介
    机器学习必修课 - 使用管道 Pipeline
    centos 通过yum安装nginx
    stm32HAL_GPIO输入
    chrome浏览器插件开发
  • 原文地址:https://blog.csdn.net/fang20180409/article/details/127702455