From 7f83c49112658831d1a3830f6cf133328f5f7593 Mon Sep 17 00:00:00 2001 From: moi15moi Date: Sat, 30 Sep 2023 23:49:26 -0400 Subject: [PATCH] Adapt get_missing_glyphs with symbol font --- font_collector/font.py | 10 ++++++++++ font_collector/font_parser.py | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/font_collector/font.py b/font_collector/font.py index 3cfba26..a147033 100644 --- a/font_collector/font.py +++ b/font_collector/font.py @@ -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: diff --git a/font_collector/font_parser.py b/font_collector/font_parser.py index 6ee4be4..4f54f08 100644 --- a/font_collector/font_parser.py +++ b/font_collector/font_parser.py @@ -52,7 +52,7 @@ class FontParser: 0: "mac_roman", }, 3: { # Microsoft - 0: "unicode", + 0: "unknown", 1: "unicode", 2: "cp932", 3: "cp936",