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

New, more modern KivaFont trait #929

Merged
merged 10 commits into from
Apr 28, 2022
Merged

New, more modern KivaFont trait #929

merged 10 commits into from
Apr 28, 2022

Conversation

corranwebster
Copy link
Contributor

This creates a KivaFont TraitType, which is:

  • in enable, rather than Kiva, meaning Kiva can potentially not need traits
  • has a better font parser that supports more weight types
  • the font parser can be swapped out for something better easily
  • uses the new KivaFontEditor, which is available for Qt
  • converts Pyface Fonts to Kiva Fonts

This requires #928 to be merged before it is.

In conjunction with #924 this closes #417
It also closes #922 and closes #896 and closes #471

This font editor is laregly toolkit independent - it embeds a Window with a
Label component to display the font and the simple editor uses the Pyface
font dialog to get new font values.

Some functionality is broken out into experimental base classes for building
editors with components.
This creates a KivaFont TraitType, which is:
- in enable, rather than Kiva, meaning Kiva can potentially not need traits
- has a better font parser that supports more weight types
- the font parser can be swapped out for something better easily
- uses the new KivaFontEditor, which is available for Qt
- converts Pyface Fonts to Kiva Fonts
@mdickinson
Copy link
Member

I'll wait on review until #924 and #928 have been merged into main (and from there into this branch).

Copy link
Member

@jwiggins jwiggins left a comment

Choose a reason for hiding this comment

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

Some preliminary comments

enable/tests/trait_defs/test_kiva_font_trait.py Outdated Show resolved Hide resolved
enable/trait_defs/api.py Show resolved Hide resolved
enable/trait_defs/kiva_font_trait.py Show resolved Hide resolved
enable/trait_defs/kiva_font_trait.py Outdated Show resolved Hide resolved
@@ -10,181 +10,7 @@
""" Trait definition for a wxPython-based Kiva font.
"""

import logging
from enable.trait_defs.kiva_font_trait import KivaFont as _KivaFont
Copy link
Member

Choose a reason for hiding this comment

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

Are you sure we want to import from enable here?

Copy link
Contributor Author

@corranwebster corranwebster Apr 26, 2022

Choose a reason for hiding this comment

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

Yes, I think so. It's preliminary to getting rid of kiva.trait_defs.

As long as we don't have circularity of imports it should be fine.

@corranwebster
Copy link
Contributor Author

@mdickinson if you have time to review, this would be great.

@mdickinson
Copy link
Member

mdickinson commented Apr 26, 2022

Will review first thing tomorrow. Please could you fix the conflicts first?

@corranwebster
Copy link
Contributor Author

Please could you fix the conflicts first?

Hopefully done - I'm at the point today where I am messing things up.

@corranwebster
Copy link
Contributor Author

corranwebster commented Apr 27, 2022

Looks like some imports got mangled/moved in the merge. Not entirely sure how the tests are passing right now.

Edit: because tests for trait defs weren't in a package (no __init__.py)

Copy link
Member

@mdickinson mdickinson left a comment

Choose a reason for hiding this comment

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

Done with first-pass review. Lots of comments, mostly at nitpick level.

At some point, it would be great to get flake8-style checks up and running on this repository; it's more efficient at catching things like NameErrors than humans are.

@@ -18,7 +18,7 @@ the form of an HTML color name ("blue" or "#0000FF").

font_trait
----------
:class:`~.font_trait` is a synonym for :class:`kiva.trait_defs.api.KivaFont`.
:class:`~.font_trait` is a synonym for :class:`enable.trait_defs.kiva_font_trait.KivaFont`.
Copy link
Member

Choose a reason for hiding this comment

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

Nits:

  • Rewrap to avoid long lines? The rest of the file seems to be limited to width 80.
  • The statement seems misleading: font_trait is an instance of KivaFont, rather than a synonym for it. Worth rephrasing?

enable/examples/demo/enable/editors/font_editor.py Outdated Show resolved Hide resolved
enable/label.py Outdated Show resolved Hide resolved
enable/label.py Show resolved Hide resolved
enable/tests/trait_defs/test_kiva_font_trait.py Outdated Show resolved Hide resolved
kiva/fonttools/font.py Outdated Show resolved Hide resolved
kiva/fonttools/font.py Outdated Show resolved Hide resolved
kiva/fonttools/font.py Show resolved Hide resolved
kiva/fonttools/font.py Show resolved Hide resolved
kiva/trait_defs/tests/test_kiva_font_trait.py Show resolved Hide resolved
kiva/fonttools/font.py Outdated Show resolved Hide resolved
corranwebster and others added 2 commits April 27, 2022 10:21
Co-authored-by: Mark Dickinson <mdickinson@enthought.com>
@corranwebster
Copy link
Contributor Author

I think that's everything addressed; assuming tests pass, this is ready for re-review.

@mdickinson

This comment was marked as outdated.

@mdickinson
Copy link
Member

Aargh; sorry. I was somehow seeing out-of-date code in GitHub. All looks good.

Copy link
Member

@mdickinson mdickinson left a comment

Choose a reason for hiding this comment

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

LGTM

@corranwebster corranwebster merged commit 74536e0 into main Apr 28, 2022
@corranwebster corranwebster deleted the enh/new-font-trait branch April 28, 2022 07:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants