From eef06fb9865691145cb76dee3159dc41d500b167 Mon Sep 17 00:00:00 2001 From: Andy Date: Sun, 9 Nov 2025 23:19:12 +0000 Subject: [PATCH] fix: suppress verbose fontTools logging when scanning system fonts --- unshackle/core/utilities.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/unshackle/core/utilities.py b/unshackle/core/utilities.py index dae0dc6..4892c24 100644 --- a/unshackle/core/utilities.py +++ b/unshackle/core/utilities.py @@ -463,8 +463,18 @@ def extract_font_family(font_path: Path) -> Optional[str]: Returns: Font family name if successfully extracted, None otherwise """ + # Suppress verbose fontTools logging during font table parsing + import io + + logging.getLogger("fontTools").setLevel(logging.ERROR) + logging.getLogger("fontTools.ttLib").setLevel(logging.ERROR) + logging.getLogger("fontTools.ttLib.tables").setLevel(logging.ERROR) + logging.getLogger("fontTools.ttLib.tables._n_a_m_e").setLevel(logging.ERROR) + stderr_backup = sys.stderr + sys.stderr = io.StringIO() + try: - font = ttLib.TTFont(font_path) + font = ttLib.TTFont(font_path, lazy=True) name_table = font["name"] # Try to get family name (nameID 1) for Windows platform (platformID 3) @@ -479,8 +489,9 @@ def extract_font_family(font_path: Path) -> Optional[str]: return record.toUnicode() except Exception: - # Silently ignore font parsing errors (corrupted fonts, etc.) pass + finally: + sys.stderr = stderr_backup return None