Move the font scanning code into private modules#693
Conversation
rahulporuri
left a comment
There was a problem hiding this comment.
Mostly LGTM with a few comments/questions.
| Copyright : John Hunter (2004,2005), Paul Barrett (2004,2005) | ||
| License : matplotlib license (PSF compatible) | ||
| The font directory code is from ttfquery, | ||
| see license/LICENSE_TTFQUERY. |
There was a problem hiding this comment.
looks like we're not including this license file with the sdists.
There was a problem hiding this comment.
I can't find that license in the matplotlib repo...
| """ A class for storing Font properties. It is used when populating | ||
| the font lookup dictionary. | ||
| """ | ||
| def __init__(self, fname="", name="", style="normal", variant="normal", |
There was a problem hiding this comment.
not sure what the difference between looking at the rest of the class, it's clear that fname and name is.fname is the filepath and name is the font name. Would it be possible to rename fname to filepath or will that break backwards compatibility?
There was a problem hiding this comment.
🤷♂️ This one is probably OK. I don't think any external code is dealing directly with FontEntry instances.
| ) | ||
|
|
||
|
|
||
| def create_font_list(fontfiles, fontext="ttf"): |
There was a problem hiding this comment.
Is it necessary to specify that this function only handles fontext - ttf and afm? Or does it also implicitly handle looking at more code in this module, looks like ttc font files?ttf and ttc are handled by the same function
There was a problem hiding this comment.
I don't think so. This function is decidedly internal to the font manager.
| @@ -0,0 +1,538 @@ | |||
| # (C) Copyright 2005-2021 Enthought, Inc., Austin, TX | |||
There was a problem hiding this comment.
correct me if im wrong but it looks like this module has two distinct functions - FontEntry and the code to create FontEntry instances from font files and the code to scan system fonts.
Is it overkill to split these two functions into separate modules?
There was a problem hiding this comment.
I'll look into this, but I won't do it in this PR.
| data_dir = resource_filename("kiva.fonttools.tests", "data") | ||
| is_macos = (sys.platform == "darwin") | ||
| is_windows = (sys.platform in ("win32", "cygwin")) | ||
| is_generic = not (is_macos or is_windows) |
There was a problem hiding this comment.
im not entirely sure what's a generic platform - does generic here mean linux?
There was a problem hiding this comment.
Generic unix? Anything not macOS or Windows with X11, basically. That could be a lot of platforms, but in practice it's linux and freebsd (and solaris?).
|
There's more to come here, so I'm going to merge now and keep moving. Thanks for the feedback! |
NOTE: This does not yet modify the behavior of
FontManager.This PR is intended to isolate the font file scanning code currently in
kiva.fonttools.font_managerand cover it with tests. In a future PR, we'll actually start using this code.Tangentially related to #391 and #555