Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Text antialiasing for mathtext (reopen)#26376
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
@check_figures_equal() | ||
def test_text_math_antialiased_on_default_vs_manual(fig_test, fig_ref): | ||
fig_test.text(0.5, 0.5, r"OutsideMath $I\'m \sqrt{2}$", antialiased=True) | ||
mpl.rcParams['text.antialiased'] = True | ||
fig_ref.text(0.5, 0.5, r"OutsideMath $I\'m \sqrt{2}$") | ||
@check_figures_equal() | ||
def test_text_math_antialiased_off_default_vs_manual(fig_test, fig_ref): | ||
fig_test.text(0.5, 0.5, r"OutsideMath $I\'m \sqrt{2}$", antialiased=False) | ||
mpl.rcParams['text.antialiased'] = False | ||
fig_ref.text(0.5, 0.5, r"OutsideMath $I\'m \sqrt{2}$") |
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.
Unfortunately, neither of these tests fail without this PR, so I'm not sure if they are testing what you want?
stevezhang1999Jul 30, 2023 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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.
Yes.
Before this: For math text, whether we are using antialiasing is resolved when rendering (_mathtext.py::Output.to_raster()
). Two test figures are saved after we executing theses codes, resulting two figures resolve to the samercParams
.
After this: When creating the text, antialiasing states are set byTrue
orFalse
if the user specifies the keyword argument. Otherwise, the state resolves torcParams
also at the creation time. That is, we no longer queryrcParams
when rendering.
flake 8 tests failing seems unrelated. |
flake8 issues are fixed in#26414. You can rebase onto |
@functools.lru_cache(50) | ||
def _parse_cached(self, s, dpi, prop): | ||
def _parse_cached(self, s, dpi, prop, antialiased): |
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 also fixes a latent bug where we would incorrectly hit the cache if the rcparam was changed between the first and subsequent calls!
I squash-merged this to make the history a little cleaner. Thank you@stevezhang1999 for following up and getting aliasing fully sorted! I hope we continue to hear from you. |
Thanks! I'm really happy to be part of the community. |
Uh oh!
There was an error while loading.Please reload this page.
Accidentallyclosedthis by force pushing.
As mentioned inthe previous PR, if the text contains math text, antialiasing will use
rcParams["text.antialiased"]
and the parameterantialiased
fortext()
will have no effect. Now this is fixed -antialiased
works for mathtext. Note that only AGG backend support this. Using Cairo we cannot customize antialiasing for math text.