FIX: KeyError while parsing ttfFontProperty#365
Conversation
TST: Add test font file from matplotlib
FIX: Correct test method name
FIX: Add missing imports
FIX: Remove __main__ block
|
the travis job for python 2.7 and |
|
Interesting...
Interesting... That is failing on one of the few lines in |
|
Note that apart from the |
Codecov Report
@@ Coverage Diff @@
## master #365 +/- ##
==========================================
+ Coverage 32.91% 33.37% +0.46%
==========================================
Files 206 206
Lines 18303 18302 -1
Branches 2415 2416 +1
==========================================
+ Hits 6024 6108 +84
+ Misses 11893 11807 -86
- Partials 386 387 +1
Continue to review full report at Codecov.
|
|
I think I found the bug. I had the |
|
I also changed some |
|
|
||
| font = fontManager.findfont(self) | ||
| return getPropDict(TTFont(six.text_type(font))['name']) | ||
| return getPropDict(TTFont(six.text_type(font)))['name'] |
There was a problem hiding this comment.
do you think it will help readability if you change the formatting here to
return getPropDict(
TTFont(six.text_type(font))
)['name']
or something of that sort?
There was a problem hiding this comment.
Maybe even breaking that out of the return altogether to make it more readable. Something like:
prop_dict = getPropDict(TTFont(six.text_type(font))
return prop_dict['name']
What do you think @rahulporuri ?
|
Code changes LGTM; I'm running into bandwidth issues with local testing, though. |
|
Local test results LGTM, too. |
|
Thanks all for the reviews! |
FIX: KeyError while parsing ttfFontProperty
I think this might help the
KeyErrors that were exposed when logging was introduced inttfFontProperty. It continues searching through the names until one can be decoded with eitherutf-8orutf-16-be. Rather than using theplatformID,platEncID,langID, andnameID, this only uses thenameID. It also removes thesfnt2prop. AFAICT, it wasn't actually needed.style = 'normal'would be set regardless.I would prefer to get a font in the repo to test on that was producing the
KeyError, but testing locally withcreateFontList(findSystemFonts())on OSX, Windows, and Ubuntu ends up with all fonts parsed without raising an exception.Let me know what you think.
Closes #363