-
Notifications
You must be signed in to change notification settings - Fork 44
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
Fix font weights #919
Fix font weights #919
Conversation
For comparison, the KivaExplorer script in #905 now displays the following on either agg backend: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor readability suggestion, but LGTM!
kiva/celiagg.py
Outdated
if font.style in (constants.BOLD, constants.BOLD_ITALIC): | ||
weight = agg.FontWeight.Bold | ||
weight = font_weights.get(font._get_weight(), agg.FontWeight.Regular) | ||
style = (font.style in constants.italic_styles) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This bool should still be named italic
, I think. There's no reason why style=True
should mean "this font is italic".
This is a reasonably comprehensive fix for #905 following the suggestions given there. Together with #918 it gives good support for more refined font weights and styles on
qpainter
and both agg backends, as well as consistent behaviour on backends which only support bold and normal weights. It is also backwards compatible with code that usesstyle
for both italic and bold, raising aDeprectationWarning
if thestyle
is bold.In making the changes, this PR also cleans up some of the early Python 2-ish idioms and uses more modern constructs where appropriate.
It includes smoke tests for rendering text in all combinations of font families, weights and styles on each backend, as well as adding tests for the
KivaFont
trait. Documentation is also updated.This PR doesn't attempt to update backends which can potentially support more font weights (eg. quartz) but which haven't exposed it in the C/C++ wrappers. It also doesn't attempt to update or improve the font parsers to understand the new weight types - that should be a different PR.
Fixes #905.