-
Notifications
You must be signed in to change notification settings - Fork 44
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
Remove redundant code from kiva.fonttools.font_manager #707
Conversation
Better yet, the coverage report from 5.0.1:
|
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.
Nothing? Really? |
:D Not really. I was going to ask if we could flake8 I guess the only thing i can say is - given the amount of time you've spend digging into I guess we could ask internally if anyone has qualms with the refactor/cleanup. It couldn't hurt. I guess? so, tl; dr |
You might want to mess around a bit more with the font_manager.py module docstring - possibly move the historical copyright and author info to block comments and change it to be a bit more oriented towards inclusion in autogenerated API docs. But also not a big issue if you have more changes in the pipe for the font manager. |
A good question. I would say "Yes", but only because that's how things normally go. That said, I think with the tests and logically separating the parts out into modules probably means that I could understand this code in six months when I've lost the context. That's my hope at least. In the meantime, it might be nice to see if Kit has the time to take a look and give her opinion on the state of things. There is still one big fix I'd like to address. That's the bad fallback font selection. |
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.
LGTM as well. Just had a couple very minor questions
|
||
def __init__(self, size=None, weight="normal"): | ||
self._version = self.__version__ | ||
|
||
self.__default_weight = weight | ||
self.default_size = size | ||
self.default_size = size if size is not None else 12.0 |
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.
why not set size=12.0
in the method signature?
Also why size and default_size? it seems in the rest of the code for the class default_size is used
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'm glad you brought this up because I forgot about it. It's because of this code: https://github.com/enthought/enable/pull/704/files#diff-07c82150ae0bd465451ecaaaf02e959e718f46ea5e494d84dfd2ed81e6194316L1216-L1217.
That line of code in score_size
gets run if you pass a a FontProperties
instance to FontManager.findfont
with its size
attribute explicitly set to one of the strings in font_scalings
. That's basically never. I know, because nobody complained about it in the 11 years that it had a bug that would raise an exception.
I fixed that bug, but now score_size
must be called with a valid default size. That means that FontManager
needs to have a non-None value set to .default_size
. But it gets worse. _load_from_cache_or_rebuild
explicitly sets FontManager.default_size
back to None after loading it from the cache! We should probably stop doing that, but the fact that it's done implies that messing with the default_size
was somehow the expected interface?
I'm not sure what to do.
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 see you've opened #709, thank you! This can be addressed separately from this PR
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.
#709 opened to track
@corranwebster |
#710 opened to track the default font issue. |
Thanks for the feedback everyone. I'm going to merge now, but there's still some scattered work to do which should be covered by open issues. |
I was wondering if we should document what all previously public stuff from |
Resolves #391
At last we've arrived. This PR removes a ton of code from
kiva.fonttools.font_manager
, leaving onlyFontManager
,fontManager
anddefault_font_manager
as the things we're [sort of] OK with people importing. Really, everyone should just useFont
and don't peek under the covers (unless writing a Kiva backend).Additionally,
kiva.fonttools.afm
is being removed completely now that #700 has been merged.This PR will break any code which explicitly tries to muck about with the creation of the system font cache. A nice API for this will arrive with the resolution of #555. This PR will also break any code which was calling functions that have been moved to the new private
kiva.fonttools
modules. Searching all of GitHub didn't turn up a lot of external code which has these behaviors, so I'm not too worried (though I might reach out to some of those projects to give them a heads up).Test coverage is a bit better in this new world.
master
branch:This branch: [Note that
kiva.fonttools._scan_sys
actually has better coverage, but it's hard to capture that on a single OS]