Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Small cleanups around TexManager usage. #22547

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

Merged
merged 1 commit into from
Mar 6, 2022
Merged

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Feb 23, 2022

Mostly take advantage of the fact that TexManager() now always returns
the same instance, so get_texmanager isn't really needed anymore. Still
keep RendererBase.get_texmanager as backcompat for now as inheriting
renderers (e.g. mplcairo) may be using that to also support older
versions where there was no singleton logic); OTOH probably(?) no one is
inheriting from TextToPath (which is mostly the text_to_path singleton)
so we can deprecate its get_texmanager.

PR Summary

PR Checklist

Tests and Styling

  • Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (install flake8-docstrings and run flake8 --docstring-convention=all).

Documentation

  • New features are documented, with examples if plot related.
  • New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented in doc/api/next_api_changes/ (follow instructions in README.rst there).
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).

Mostly take advantage of the fact that TexManager() now always returns
the same instance, so get_texmanager isn't really needed anymore.  Still
keep RendererBase.get_texmanager as backcompat for now as inheriting
renderers (e.g. mplcairo) may be using that to also support older
versions where there was no singleton logic); OTOH probably(?) no one is
inheriting from TextToPath (which is mostly the text_to_path singleton)
so we can deprecate *its* get_texmanager.
@anntzer anntzer added this to the v3.6.0 milestone Feb 23, 2022
@@ -605,13 +606,12 @@ def get_text_width_height_descent(self, s, prop, ismath):
to the baseline), in display coords, of the string *s* with
`.FontProperties` *prop*.
"""
fontsize = prop.get_size_in_points()
Copy link
Member

@oscargus oscargus Feb 24, 2022

Choose a reason for hiding this comment

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

I guess this was defined multiple times as the second return does not depend on it. But with the very simple function, it should not be a factor.

The similar change in textpath has no potential drawback at all though.

Edit: deleted confused follow-up... Hard to remember the difference between a PR and what I get if I search my local copy...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

both returns depend on fontsize?

Copy link
Member

Choose a reason for hiding this comment

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

Not this:

        if ismath:
            dims = self._text2path.mathtext_parser.parse(s, dpi, prop)
            return dims[0:3]  # return width, height, descent

but no big deal.

@timhoffm timhoffm merged commit 6d3a068 into matplotlib:main Mar 6, 2022
@anntzer anntzer deleted the tm branch March 6, 2022 21:33
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.

3 participants