Skip to content

Don't try to find TeX-only fonts when layouting TeX text. #13170

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
Jan 14, 2019

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Jan 12, 2019

PR Summary

Text.is_math_text is only ever called with self.get_usetex() as second
argument, so just change it to a private method (Text._preprocess_math)
that calls self.get_usetex() internally; deprecate is_math_text which
is clearly a private internal helper. This also helps clarifying that
usetex mode is only ever called if self.get_usetex() is True (in the
textobj.is_math_text(...) line, textobj is actually the same object(!)
as self so shares the same get_usetex() value).
(#13166 also clarifies the situation with get_usetex()).

In Text._get_layout, if self.get_usetex() is True (and only in that
case), self._fontproperties can refer to a TeX-only font (e.g. "Computer
Modern Roman"). If that's the case, don't try to call
renderer.get_text_width_height_descent with ismath=False, as that would
trigger a font resolution that can fail (perhaps there's no "Computer
Modern Roman" font available in the font cache; it may only be available
to TeX) and cause a spurious warning.

Goes on top of #12951 to avoid a rebase.
Closes (probably) #13139, at least #13139 (comment).

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

@tacaswell tacaswell added this to the v3.1 milestone Jan 13, 2019
Copy link
Member

@tacaswell tacaswell left a comment

Choose a reason for hiding this comment

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

@anntzer mild preference that you do the (hopefully trivial) rebase to drop the now-merged commit from #12951

@anntzer
Copy link
Contributor Author

anntzer commented Jan 13, 2019

done

Text.is_math_text is only ever called with self.get_usetex() as second
argument, so just change it to a private method (Text._preprocess_math)
that calls self.get_usetex() internally; deprecate is_math_text which
is clearly a private internal helper.  This also helps clarifying that
usetex mode is only ever called if self.get_usetex() is True (in the
textobj.is_math_text(...) line, textobj is actually the same object(!)
as self so shares the same get_usetex() value).

In Text._get_layout, if self.get_usetex() is True (and only in that
case), self._fontproperties can refer to a TeX-only font (e.g. "Computer
Modern Roman").  If that's the case, don't try to call
renderer.get_text_width_height_descent with ismath=False, as that would
trigger a font resolution that can fail (perhaps there's no "Computer
Modern Roman" font available in the font cache; it may only be available
to TeX) and cause a spurious warning.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants