Skip to content

Use a database object to manage fonts#714

Merged
jwiggins merged 4 commits into
masterfrom
refactor/font-database
Mar 16, 2021
Merged

Use a database object to manage fonts#714
jwiggins merged 4 commits into
masterfrom
refactor/font-database

Conversation

@jwiggins
Copy link
Copy Markdown
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.

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

paths = []
self.default_family = "sans-serif"
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 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.

Comment thread kiva/fonttools/font_manager.py
Comment thread kiva/fonttools/font_manager.py
Comment thread kiva/fonttools/tests/test_font_manager.py
@rahulporuri rahulporuri self-requested a review March 15, 2021 04:47
Comment thread kiva/fonttools/_database.py
Comment thread kiva/fonttools/_database.py
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.

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
Copy Markdown
Member Author

Thanks for the review

@jwiggins jwiggins merged commit 48d9772 into master Mar 16, 2021
@jwiggins jwiggins deleted the refactor/font-database branch March 16, 2021 09:41
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