Don't try to find TeX-only fonts when layouting TeX text. #13170
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