-
-
Notifications
You must be signed in to change notification settings - Fork 109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PR: Add validation to raise exception when fonts are empty or corrupt #60
Conversation
if ttf_filename == 'fontawesome-webfont.ttf': | ||
ttf_hash_code = 'a3de2170e4e9df77161ea5d3f31b2668' | ||
elif ttf_filename == 'elusiveicons-webfont.ttf': | ||
ttf_hash_code = '207966b04c032d5b873fd595a211582e' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make this a dictionary for clarity, like this:
md5_hashes = {'fontawesome-webfont.ttf': 'a3de2170e4e9df77161ea5d3f31b2668',
'elusiveicons-webfont.ttf': '207966b04c032d5b873fd595a211582e'}
ttf_hash_code = 'a3de2170e4e9df77161ea5d3f31b2668' | ||
elif ttf_filename == 'elusiveicons-webfont.ttf': | ||
ttf_hash_code = '207966b04c032d5b873fd595a211582e' | ||
if ttf_hash_code != None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we use a dictionary for hashes then this has to be
ttf_hash = md5_hashes.get(ttf_filename, None)
if ttf_hash is not None:
...
And yes, please use ttf_hash
instead of ttf_hash_code
for this variable.
@dalthviz, this looks good to me. I just left a couple of comments to improve readability ;-) Also, please merge with master to fix the Travis errors. |
|
||
loadedFontFamilies = QFontDatabase.applicationFontFamilies(id_) | ||
|
||
if(loadedFontFamilies): | ||
self.fontname[prefix] = loadedFontFamilies[0] | ||
else: | ||
print('Font is empty') | ||
raise FontError(u"Font is empty at: '{0}'".format( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to improve this error message for people that uses QtAwesome on Windows 10. Please rephrase it for something like
"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."
md5_hashes = {'fontawesome-webfont.ttf': | ||
'a3de2170e4e9df77161ea5d3f31b2668', | ||
'elusiveicons-webfont.ttf': | ||
'207966b04c032d5b873fd595a211582e'} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please format this better:
md5_hashes = {'fontawesome-webfont.ttf':
'a3de2170e4e9df77161ea5d3f31b2668',
'elusiveicons-webfont.ttf':
'207966b04c032d5b873fd595a211582e'}
Thanks @dalthviz, merging now :-) |
This is part of an effort to improve the management of errors that cause a Spyder crash when trying to load fonts from the
.ttf
files in the fonts directory and these are corrupt.