Skip to content

Break out the font scoring methods and test them#704

Merged
jwiggins merged 2 commits into
masterfrom
feature/split-font-scores
Mar 11, 2021
Merged

Break out the font scoring methods and test them#704
jwiggins merged 2 commits into
masterfrom
feature/split-font-scores

Conversation

@jwiggins
Copy link
Copy Markdown
Member

Ok, I'm pretty sure that along with #700, I'm really done breaking things out of kiva.fonttools.font_manager. The next PR is the big one.

This PR moves the font scoring methods to their own module and covers them liberally with tests. A bug in score_size was fixed (trying to call a dict instance).

The font scoring methods are used by FontManager.findfont to compare FontEntry instances with FontProperties instances to determine their similarity.

@jwiggins
Copy link
Copy Markdown
Member Author

I went ahead and actually deleted the old methods from FontManager.

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.

I did a quick search through the enthought codebases on GitHub to see if there are any uses of the methods - and I don't see any. None whatsoever. Searching in general on GitHub raises a lot of false negatives - uses of the method on the matplotlib font manager.

I'm confident that removing the methods won't cause much (if any) pain.

Comment thread kiva/fonttools/_score.py
Comment on lines +22 to +23
# Each of the scoring functions below should return a value between
# 0.0 (perfect match) and 1.0 (terrible match)
Copy link
Copy Markdown
Contributor

@rahulporuri rahulporuri Mar 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bikeshed : that seems backwards to me. but i guess it also makes sense in terms of distance between fonts and 0.0 means perfect match/zero distance and 1.0 is scaled worst match/infinite distance.

@jwiggins
Copy link
Copy Markdown
Member Author

Thanks for the review!

@jwiggins jwiggins merged commit 0676682 into master Mar 11, 2021
@jwiggins jwiggins deleted the feature/split-font-scores branch March 11, 2021 12:49
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