Remove redundant code from kiva.fonttools.font_manager#707
Conversation
|
Better yet, the coverage report from 5.0.1: |
|
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. |
aaronayres35
left a comment
There was a problem hiding this comment.
LGTM as well. Just had a couple very minor questions
|
|
||
| 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.
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.
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.
I see you've opened #709, thank you! This can be addressed separately from this PR
|
@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,fontManageranddefault_font_manageras the things we're [sort of] OK with people importing. Really, everyone should just useFontand don't peek under the covers (unless writing a Kiva backend).Additionally,
kiva.fonttools.afmis 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.fonttoolsmodules. 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.
masterbranch:This branch: [Note that
kiva.fonttools._scan_sysactually has better coverage, but it's hard to capture that on a single OS]