Skip to content

Commit

Permalink
Adapt get_missing_glyphs with symbol font
Browse files Browse the repository at this point in the history
  • Loading branch information
moi15moi committed Oct 1, 2023
1 parent 2d692d5 commit 7f83c49
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions font_collector/font.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,16 @@ def get_missing_glyphs(self, text: Sequence[str]) -> Set[str]:
if cmap_encoding == "unicode":
codepoint = ord(char)
else:
if cmap_encoding == "unknown" and platform_id == 3 and encoding_id == 0:
cmap_encoding = FontParser.get_symbol_cmap_encoding(face)

if cmap_encoding is None:
# Fallback if guess fails
cmap_encoding = "cp1252"
else:
# cmap not supported
continue

try:
codepoint = int.from_bytes(char.encode(cmap_encoding), "big")
except UnicodeEncodeError:
Expand Down
2 changes: 1 addition & 1 deletion font_collector/font_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class FontParser:
0: "mac_roman",
},
3: { # Microsoft
0: "unicode",
0: "unknown",
1: "unicode",
2: "cp932",
3: "cp936",
Expand Down

0 comments on commit 7f83c49

Please sign in to comment.