-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix font family lookup calculation #2771
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
Fix font family lookup calculation #2771
Conversation
['cmmi10', 'Bitstream Vera Sans']}): | ||
font = findfont( | ||
FontProperties(family=["sans-serif"])) | ||
assert os.path.basename(font) == 'cmmi10.ttf' |
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.
Is this file going to be available on all distros?
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.
It ships with matplotlib and is required for mathtext support (that's why I chose it). Some distros still monkey around with not including required fonts, of course.
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.
I should mention that using assert_equal is much nicer, as when it fails, it has enough context to tell you why they are different.
The test failiure is genuine on 2.6:
|
The test failure is random. It necessarily changes global state, so when running the tests in parallel, there are problems. I think I need to look into how to "lock" this test so it doesn't run in parallel. |
I'm very surprised - surely these tests are being run in multiple processes rather than multiple threads, so surely we're not impacted by changing globals? I'm sure I've missed something here though... |
@@ -1071,7 +1071,7 @@ def score_family(self, families, family2): | |||
if family2 in options: | |||
idx = options.index(family2) | |||
return ((0.1 * (float(idx) / len(options))) * | |||
(float(i) / float(len(families)))) | |||
(float(i + 1) / float(len(families)))) |
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.
shouldn't `from future_import division remove the need for all of this casting to float?
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.
True. I think this code was written prior to that. Will fix.
list (e.g. font.sans-serif) would be considered a perfect match whenever the selected font alias is the first in the font.family list. This broke the priority ordering of font names.
3.2 (as normal it seems) still has issues. |
Frustratingly, I can't reproduce it locally -- seems to be Travis-specific. |
Fix font family lookup calculation
@mdboom It seems to have passed last time it ran, I am going to merge it. |
As reported in mailing list thread "font setting in matplotlib 1.3.1"