-
-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Deprecate MathTextParser("bitmap") and associated APIs. #18591
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
Conversation
| self._mathtext_parser = mathtext.MathTextParser('bitmap') | ||
| img, _ = self._mathtext_parser.parse(lev, dpi=72, | ||
| prop=self.labelFontProps) | ||
| self._mathtext_parser = mathtext.MathTextParser('agg') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this specific use is going away via #16171.
8e370a2 to
0bc633b
Compare
|
It appears that |
|
You could wrap the call to |
|
Yes, that should go in the deprecation note, maybe as a longer example. |
|
done |
0bc633b to
ef15c5a
Compare
`MathTextParser("bitmap")` is rather low-level APIs to convert text
strings to images. Instead, one can use a much more generic method,
namely directly drawing to a new Figure() and saving with
`bbox_inches="tight"`. Alternatively, if one really wants a single
function call, there's still `mathtext.math_to_image`.
Also fix the wx example to use light text colors when so directed by the
system theme.
ef15c5a to
5ce4ff2
Compare
| from matplotlib.transforms import IdentityTransform | ||
|
|
||
|
|
||
| def text_to_rgba(s, *, dpi, **kwargs): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use math_to_image here?
tacaswell
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Why not use math_to_image in both of the examples?
|
Because it's a super-specialized API which I don't think is particularly interesting to demonstrate (or even to expose), whereas drawing on a figure and saving with tight bbox works for basically anything you may want to draw -- including text, but not only that! |
MathTextParser("bitmap")is rather low-level APIs to convert textstrings to images. Instead, one can use a much more generic method,
namely directly drawing to a new Figure() and saving with
bbox_inches="tight". Alternatively, if one really wants a singlefunction call, there's still
mathtext.math_to_image.Also fix the wx example to use light text colors when so directed by the
system theme.
PR Summary
PR Checklist
pytestpasses).flake8on changed files to check).flake8-docstringsandpydocstyle<4and runflake8 --docstring-convention=all).doc/users/next_whats_new/(follow instructions in README.rst there).doc/api/next_api_changes/(follow instructions in README.rst there).