Skip to content
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

Merged
merged 3 commits into from
Mar 10, 2021

Conversation

jwiggins
Copy link
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

@rahulporuri rahulporuri added this to In progress in Enthought OSS Q1 2021 Mar 9, 2021
Copy link
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
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
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
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
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.

kiva/fonttools/_scanner.py Outdated Show resolved Hide resolved
)


def create_font_list(fontfiles, fontext="ttf"):
Copy link
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
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
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
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.

kiva/fonttools/_scanner.py Outdated Show resolved Hide resolved
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
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
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
Enthought OSS Q1 2021 automation moved this from In progress to Done Mar 10, 2021
@jwiggins
Copy link
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
@rahulporuri rahulporuri moved this from Done to Sprint 4 : March 1 - March 12 2021 in Enthought OSS Q1 2021 Mar 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Enthought OSS Q1 2021
Sprint 4 : March 1 - March 12 2021
Development

Successfully merging this pull request may close these issues.

None yet

2 participants