Skip to content

Fix font weights#919

Merged
corranwebster merged 15 commits into
mainfrom
fix/font-bold-weight
Mar 29, 2022
Merged

Fix font weights#919
corranwebster merged 15 commits into
mainfrom
fix/font-bold-weight

Conversation

@corranwebster
Copy link
Copy Markdown
Contributor

@corranwebster corranwebster commented Mar 25, 2022

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 uses style for both italic and bold, raising a DeprectationWarning if the style 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.

@corranwebster
Copy link
Copy Markdown
Contributor Author

corranwebster commented Mar 25, 2022

For comparison, the KivaExplorer script in #905 now displays the following on either agg backend:
image

Copy link
Copy Markdown
Member

@rkern rkern left a 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!

Comment thread 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)
Copy link
Copy Markdown
Member

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".

@corranwebster corranwebster merged commit f2fcc5c into main Mar 29, 2022
@corranwebster corranwebster deleted the fix/font-bold-weight branch March 29, 2022 09:54
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.

Font queries ignore Font.weight

2 participants