-
Notifications
You must be signed in to change notification settings - Fork 0
/
pycharmap-unicode.py
35 lines (27 loc) · 961 Bytes
/
pycharmap-unicode.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import unicodedata
from fontTools.ttLib import TTFont
import sys
def display_available_glyphs(font_path):
# Load the font
font = TTFont(font_path)
# Get the set of code points available in the font
cmap = font.getBestCmap()
print(f"Available glyphs in the font {font_path}:")
print("=" * 40)
# Iterate through all available code points
for code_point in sorted(cmap.keys()):
char = chr(code_point)
try:
name = unicodedata.name(char)
except ValueError:
name = "Unknown"
# Display glyph information
print(f"U+{code_point:04X} | {char} | {name}")
print("=" * 40)
print(f"Total available glyphs: {len(cmap)}")
if __name__ == "__main__":
if len(sys.argv) != 2:
print("Usage: python unicode_glyph_checker.py <font_file_path>")
sys.exit(1)
font_path = sys.argv[1]
display_available_glyphs(font_path)