From 21e2143e20d797a142709a8a53d3aeca1a42ed8b Mon Sep 17 00:00:00 2001 From: dalthviz Date: Thu, 20 Oct 2022 14:22:06 -0500 Subject: [PATCH 1/2] Handle per user font installation failing due to missing/not available registry keys --- qtawesome/iconic_font.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/qtawesome/iconic_font.py b/qtawesome/iconic_font.py index 8214d27e..96f40fde 100644 --- a/qtawesome/iconic_font.py +++ b/qtawesome/iconic_font.py @@ -632,8 +632,15 @@ def _install_fonts(self, fonts_directory): GFRI_ISTRUETYPE) if is_truetype: fontname += ' (TrueType)' - with winreg.OpenKey(winreg.HKEY_CURRENT_USER, FONTS_REG_PATH, 0, - winreg.KEY_SET_VALUE) as key: - winreg.SetValueEx(key, fontname, 0, winreg.REG_SZ, filename) + try: + with winreg.OpenKey(winreg.HKEY_CURRENT_USER, FONTS_REG_PATH, 0, + winreg.KEY_SET_VALUE) as key: + winreg.SetValueEx(key, fontname, 0, winreg.REG_SZ, filename) + except FileNotFoundError: + # Needed to support older Windows version where + # font installation per user is not possible/related registry + # entry is not available + # See spyder-ide/qtawesome#214 + return fonts_directory return user_fonts_dir From c20d090def283e0ab354e09a603e573b0f813df5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Althviz=20Mor=C3=A9?= Date: Thu, 20 Oct 2022 14:55:21 -0500 Subject: [PATCH 2/2] Capture more general OSError instead of FileNotFoundError when trying to install fon --- qtawesome/iconic_font.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qtawesome/iconic_font.py b/qtawesome/iconic_font.py index 96f40fde..dd8c3776 100644 --- a/qtawesome/iconic_font.py +++ b/qtawesome/iconic_font.py @@ -636,7 +636,7 @@ def _install_fonts(self, fonts_directory): with winreg.OpenKey(winreg.HKEY_CURRENT_USER, FONTS_REG_PATH, 0, winreg.KEY_SET_VALUE) as key: winreg.SetValueEx(key, fontname, 0, winreg.REG_SZ, filename) - except FileNotFoundError: + except OSError: # Needed to support older Windows version where # font installation per user is not possible/related registry # entry is not available