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

Fix SCRIPT font family in Kiva #975

Merged
merged 2 commits into from
Aug 8, 2022
Merged

Fix SCRIPT font family in Kiva #975

merged 2 commits into from
Aug 8, 2022

Conversation

corranwebster
Copy link
Contributor

@corranwebster corranwebster commented Aug 4, 2022

Fix is a matter of having Font.familymap map to the right thing. This is a very old bug.

This is the benchmark rendering in the agg backend after the fix (note the "script" column):
image

Fixes #971.

@corranwebster corranwebster marked this pull request as ready for review August 4, 2022 17:06
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.

Basically LGTM

Comment on lines +211 to +212
self.assertIn(query_family, font_family_aliases)
self.assertIn(query_family, preferred_fonts)
Copy link
Member

Choose a reason for hiding this comment

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

There are items in font_family_aliases which are not keys in preferred_fonts. Perhaps you should only check against preferred_fonts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We want to check it is in both, because of this line here:

if family1 in font_family_aliases:

If it is not on font_family_aliases then preferred_fonts will never be accessed.

Copy link
Member

Choose a reason for hiding this comment

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

I'm saying that query_family in font_family_aliases can be True at the same time that query_family in preferred_fonts is False.

The more complete snippet from score_family...

if family1 in font_family_aliases:
if family1 in {"sans", "sans serif", "modern"}:
family1 = "sans-serif"

... is not really being tested here because converting from the integer Kiva family constants via Font.familymap will never result in the values "sans", "sans serif", or "modern".

Is the point of this test to keep Font.familymap values in sync with font_family_aliases and preferred_fonts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The entries in familymap need to be in both, yes (and that's what I care about for this PR).

font_family_aliases (and presumably preferred_fonts) can have extra values which come from the face_name (this is what derailed #977). Eg. if someone names a font "sans" (ie. Font("sans", 12)) it will also go through the above codepath. That likely needs some re-engineering at some point, but it is outside the scope of this PR)

@corranwebster corranwebster merged commit e62f176 into main Aug 8, 2022
@corranwebster corranwebster deleted the fix/script-font-query branch August 8, 2022 10:27
corranwebster added a commit that referenced this pull request Aug 8, 2022
* Add a test for #971

This should fail CI.

* Fix bug and clean-up style.
corranwebster added a commit that referenced this pull request Aug 12, 2022
* Use the "sphinx-copybutton" extension in documentation (#948)

* DOC: Use the sphinx-copybutton extension in documentation

	modified:   ci/edmtool.py
	modified:   docs/source/conf.py
	modified:   enable/__init__.py

* Update ci/edmtool.py

* Get things working on wxPython again (#950)

Addresses these warnigns/exceptions:
- TypeError: BitmapFromImage() got an unexpected keyword argument 'depth'
- AttributeError: 'PaintDC' object has no attribute 'BeginDrawing'
- wxPyDeprecationWarning: Call to deprecated item EmptyImage. Use :class:`Image` instead.
    image = wx.EmptyImage(*sz)
- wxPyDeprecationWarning: Call to deprecated item BitmapFromImage. Use :class:`wx.Bitmap` instead
    bmp = wx.BitmapFromImage(image, depth=-1)

See https://forums.wxwidgets.org/viewtopic.php?t=39930 why the Begin/EndDrawing calls can simply be removed.

Related issues: #798 and #531

* Add SWIG to pyproject.toml build dependencies (#954)

* Experiment with installing SWIG from PyPI

* Update the EDM-based workflow

* Remove restriction on SWIG version

* Add Cython back as a development dependency; remove verify_swig_install

* Remove generated C++ file. (#958)

* Fix Kiva Quartz backend string encoding (#966)

* Add regression test for Enable #964.

* Properly decode strings in Kiva Quartz font code.

* Properly guard against running Quartz tests on non-Mac systems.

* Ensure Wx Quartz test terminates.

* Make test success externally visible.

* Fix tests, use UTF-8.

* Add a github workflow that publishes to sdists to PyPI on release (#967)

* Add a github workflow that publishes to sdists to PyPI on release.

* Use build to build the sdist.

* Take into account all font features when drawing SVG text. (#980)

* Fix Quartz font rendering (#978)

* Use font family in quartz when no font name given.

* Render quartz text with fill color rather than stroke color.

* Fix `SCRIPT` font family in Kiva (#975)

* Add a test for #971

This should fail CI.

* Fix bug and clean-up style.

* Correct first point and orientation of Kiva QPainter arcs (#970)

* Correct first point and orientation of Kiva QPainter arcs.

This fixes #962 but not #960.

* Update kiva/qpainter.py

* Render font families better in QPainter backend (#973)

* Fall back to kiva.fonttools if Qt can't come up with a font name.

* Add a comment about setFamilies()

* Fix WEIGHT_EXTRAHEAVY on Qt6 (#990)

Some changes to tests to make sure eveything is tested correctly.

* Fix the rendering of polygons in basecore2d-based backends (#987)

* Fix the rendering of polygons in basecore2d-based backends

This:

- consistently uses Nx2 numpy arrays to store path points
- doesn't create a new subpath after a LINES function

A driveby fix gives a default implementation for show_text_at_point().

* Clean-up comments.

* Fix some unused imports.

* Some of the unused imports are in fact used.

* Improve the situation of line_state_equal a bit.

* Ensure all subpath arguments are numpy arrays.

* Ensure all backends implement `arc_to` and `quad_curve_to` (#988)

* Ensure all backends implement arc_to and quad_curve_to.

* Fix 'infomration' typo in comments in multiple files.

* Fixes suggested from PR review.

Co-authored-by: Poruri Sai Rahul <rporuri@enthought.com>
Co-authored-by: Brecht Machiels <brecht@mos6581.org>
Co-authored-by: Mark Dickinson <mdickinson@enthought.com>
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.

Script font family not supported in font queries
2 participants