Don't try to find TeX-only fonts when layouting TeX text.#13170
Merged
timhoffm merged 1 commit intomatplotlib:masterfrom Jan 14, 2019
Merged
Don't try to find TeX-only fonts when layouting TeX text.#13170timhoffm merged 1 commit intomatplotlib:masterfrom
timhoffm merged 1 commit intomatplotlib:masterfrom
Conversation
8962946 to
8cbd618
Compare
timhoffm
approved these changes
Jan 13, 2019
8cbd618 to
71fc568
Compare
Contributor
Author
|
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.
71fc568 to
dc50d2d
Compare
This was referenced Jan 14, 2019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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