File size: 391 Bytes
61d733d
 
 
10fb84b
61d733d
 
 
8f19579
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from fontTools.ttLib import TTFont


__all__ = ["char_in_font"]


def char_in_font(unicode_char, font_path):
    try:
        font = TTFont(font_path, fontNumber=0)
        for cmap in font["cmap"].tables:
            if cmap.isUnicode():
                if ord(unicode_char) in cmap.cmap:
                    return True
        return False
    except Exception as e:
        return False