-
Notifications
You must be signed in to change notification settings - Fork 45
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
Move the font scanning code into private modules #693
Conversation
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like we're not including this license file with the sdists.
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 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤷♂️ 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
im not entirely sure what's a generic platform - does generic here mean linux?
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.
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_manager
and cover it with tests. In a future PR, we'll actually start using this code.Tangentially related to #391 and #555