Skip to content

Move the font scanning code into private modules#693

Merged
jwiggins merged 3 commits into
masterfrom
refactor/font-scanning
Mar 10, 2021
Merged

Move the font scanning code into private modules#693
jwiggins merged 3 commits into
masterfrom
refactor/font-scanning

Conversation

@jwiggins
Copy link
Copy Markdown
Member

@jwiggins jwiggins commented Mar 9, 2021

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

Copy link
Copy Markdown
Contributor

@rahulporuri rahulporuri left a 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.
Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Member Author

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",
Copy link
Copy Markdown
Contributor

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 fname and name is. looking at the rest of the class, it's clear that 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?

Copy link
Copy Markdown
Member Author

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.

Comment thread kiva/fonttools/_scanner.py Outdated
)


def create_font_list(fontfiles, fontext="ttf"):
Copy link
Copy Markdown
Contributor

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 ttc font files? looking at more code in this module, looks like ttf and ttc are handled by the same function

Copy link
Copy Markdown
Member Author

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
Copy link
Copy Markdown
Contributor

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?

Copy link
Copy Markdown
Member Author

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.

Comment thread kiva/fonttools/_scanner.py Outdated
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)
Copy link
Copy Markdown
Contributor

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?

Copy link
Copy Markdown
Member Author

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?).

@jwiggins jwiggins merged commit 11ca213 into master Mar 10, 2021
@jwiggins
Copy link
Copy Markdown
Member Author

There's more to come here, so I'm going to merge now and keep moving. Thanks for the feedback!

@jwiggins jwiggins deleted the refactor/font-scanning branch March 10, 2021 09:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants