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

Use a database object to manage fonts #714

Merged
merged 4 commits into from
Mar 16, 2021
Merged

Conversation

jwiggins
Copy link
Member

This will be useful to #711 (for avoiding duplicate additions).

Instead of using lists inside of FontManager to hold collections of FontEntry objects, this PR introduces a FontDatabase class which ensures all known entries are unique and provides a way to query entries by file path or font family in order to pare down the number of fonts that need to be scored by FontManager.findfont.


def __init__(self, size=None, weight="normal"):
self._version = self.__version__

self.__default_weight = weight
self.default_size = size if size is not None else 12.0

paths = []
self.default_family = "sans-serif"
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 is basically equivalent to the previous value. Bitstream Vera and Helvetica are both sans-serif families. But since not every system may have them, we can use the generic family name for the default and get good results thanks to the preferred_fonts dictionary listing several options for sans-serif.

@rahulporuri rahulporuri self-requested a review March 15, 2021 04:47
@rahulporuri rahulporuri added this to In progress in Enthought OSS Q1 2021 Mar 15, 2021
kiva/fonttools/_database.py Outdated Show resolved Hide resolved
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.

LGTM. Thanks for the multiple self reviews, which helped my review in the end. I don't have any comments apart from what you already added in your self review.

@jwiggins
Copy link
Member Author

Thanks for the review

@jwiggins jwiggins merged commit 48d9772 into master Mar 16, 2021
Enthought OSS Q1 2021 automation moved this from In progress to Done Mar 16, 2021
@jwiggins jwiggins deleted the refactor/font-database branch March 16, 2021 09:41
@rahulporuri rahulporuri moved this from Done to Sprint 5 : 15 March - 2 April 2021 in Enthought OSS Q1 2021 Apr 5, 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 5 : 15 March - 2 April 2021
Development

Successfully merging this pull request may close these issues.

None yet

2 participants