Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Merged

Conversation

stevezhang1999
Copy link
Contributor

@stevezhang1999stevezhang1999 commentedJul 22, 2023
edited
Loading

Accidentallyclosedthis by force pushing.

As mentioned inthe previous PR, if the text contains math text, antialiasing will usercParams["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.

Comment on lines +967 to +980
@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}$")
Copy link
Member

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?

Copy link
ContributorAuthor

@stevezhang1999stevezhang1999Jul 30, 2023
edited
Loading

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.

@stevezhang1999
Copy link
ContributorAuthor

flake 8 tests failing seems unrelated.

@timhoffm
Copy link
Member

flake8 issues are fixed in#26414. You can rebase ontomain to get rid of them.


@functools.lru_cache(50)
def _parse_cached(self, s, dpi, prop):
def _parse_cached(self, s, dpi, prop, antialiased):
Copy link
Member

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!

@tacaswelltacaswell merged commit98007a5 intomatplotlib:mainAug 2, 2023
@tacaswell
Copy link
Member

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.

@stevezhang1999
Copy link
ContributorAuthor

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.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@tacaswelltacaswelltacaswell left review comments

@QuLogicQuLogicQuLogic left review comments

@jklymakjklymakjklymak left review comments

@timhoffmtimhoffmtimhoffm approved these changes

@anntzeranntzerAwaiting requested review from anntzer

@oscargusoscargusAwaiting requested review from oscargus

Assignees
No one assigned
Projects
None yet
Milestone
v3.8.0
Development

Successfully merging this pull request may close these issues.

6 participants
@stevezhang1999@timhoffm@tacaswell@QuLogic@jklymak@ksunden

[8]ページ先頭

©2009-2025 Movatter.jp