gyrojeff commited on
Commit
8f19579
1 Parent(s): 32b45ca

fix: bug fix in `char_in_font` detection

Browse files
Files changed (1) hide show
  1. font_dataset/helper.py +9 -6
font_dataset/helper.py CHANGED
@@ -5,9 +5,12 @@ __all__ = ["char_in_font"]
5
 
6
 
7
  def char_in_font(unicode_char, font_path):
8
- font = TTFont(font_path)
9
- for cmap in font["cmap"].tables:
10
- if cmap.isUnicode():
11
- if ord(unicode_char) in cmap.cmap:
12
- return True
13
- return False
 
 
 
 
5
 
6
 
7
  def char_in_font(unicode_char, font_path):
8
+ try:
9
+ font = TTFont(font_path, fontNumber=0)
10
+ for cmap in font["cmap"].tables:
11
+ if cmap.isUnicode():
12
+ if ord(unicode_char) in cmap.cmap:
13
+ return True
14
+ return False
15
+ except Exception as e:
16
+ return False