From 35d43d5e6e9f6fc21d155c9e88f7622f05644cac Mon Sep 17 00:00:00 2001 From: Carlos Cordoba Date: Sun, 1 Jan 2017 22:51:51 -0500 Subject: [PATCH 1/3] Improve verification that our fonts are not empty and/or missing --- qtawesome/iconic_font.py | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/qtawesome/iconic_font.py b/qtawesome/iconic_font.py index 473c9c89..574425a5 100644 --- a/qtawesome/iconic_font.py +++ b/qtawesome/iconic_font.py @@ -199,6 +199,21 @@ def hook(obj): directory = os.path.join( os.path.dirname(os.path.realpath(__file__)), 'fonts') + # Load font + id_ = QFontDatabase.addApplicationFont(os.path.join(directory, + ttf_filename)) + loadedFontFamilies = QFontDatabase.applicationFontFamilies(id_) + if(loadedFontFamilies): + self.fontname[prefix] = loadedFontFamilies[0] + else: + raise FontError(u"Font at '{0}' appears to be empty. " + "If you are on Windows 10, please read " + "https://support.microsoft.com/en-us/kb/3053676 " + "to know how to prevent Windows from blocking " + "the fonts that come with QtAwesome.".format( + os.path.join(directory, ttf_filename))) + + # Verify that font is not corrupt with open(os.path.join(directory, charmap_filename), 'r') as codes: self.charmap[prefix] = json.load(codes, object_hook=hook) @@ -217,21 +232,6 @@ def hook(obj): raise FontError(u"Font is corrupt at: '{0}'".format( os.path.join(directory, ttf_filename))) - id_ = QFontDatabase.addApplicationFont(os.path.join(directory, - ttf_filename)) - - loadedFontFamilies = QFontDatabase.applicationFontFamilies(id_) - - if(loadedFontFamilies): - self.fontname[prefix] = loadedFontFamilies[0] - else: - raise FontError(u"Font at '{0}' appears to be empty. " - "If you are on Windows 10, please read " - "https://support.microsoft.com/en-us/kb/3053676 " - "to know how to prevent Windows from blocking " - "the fonts that come with QtAwesome.".format( - os.path.join(directory, ttf_filename))) - def icon(self, *names, **kwargs): """ Return a QIcon object corresponding to the provided icon name. From ed81f053e12d87940f3fd5dade5468c96c9a0622 Mon Sep 17 00:00:00 2001 From: Carlos Cordoba Date: Sun, 1 Jan 2017 22:59:45 -0500 Subject: [PATCH 2/3] Fix style error --- qtawesome/iconic_font.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/qtawesome/iconic_font.py b/qtawesome/iconic_font.py index 574425a5..e41b7ae2 100644 --- a/qtawesome/iconic_font.py +++ b/qtawesome/iconic_font.py @@ -233,9 +233,7 @@ def hook(obj): os.path.join(directory, ttf_filename))) def icon(self, *names, **kwargs): - """ - Return a QIcon object corresponding to the provided icon name. - """ + """Return a QIcon object corresponding to the provided icon name.""" options_list = kwargs.pop('options', [{}] * len(names)) general_options = kwargs From b3f23cb7705f13cec713d796ba8905a5973b4c0a Mon Sep 17 00:00:00 2001 From: Carlos Cordoba Date: Sun, 1 Jan 2017 23:00:18 -0500 Subject: [PATCH 3/3] Testing: Don't use Pylint in ciocheck --- .ciocheck | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.ciocheck b/.ciocheck index cf746b1f..32511d3a 100644 --- a/.ciocheck +++ b/.ciocheck @@ -6,7 +6,7 @@ branch = origin/master diff_mode = commited file_mode = lines -check = pep8,pydocstyle,flake8,pylint +check = pep8,pydocstyle,flake8 enforce = pep8,pydocstyle,flake8 # Python (pyformat) @@ -104,4 +104,4 @@ exclude_lines = # ----------------------------------------------------------------------------- [pytest] addopts = -rfew --durations=10 -python_functions = test_* \ No newline at end of file +python_functions = test_*