Skip to content

swev-id: matplotlib__matplotlib-25775#66

Open
casey-brooks wants to merge 1 commit intomatplotlib__matplotlib-25775from
noa/issue-59
Open

swev-id: matplotlib__matplotlib-25775#66
casey-brooks wants to merge 1 commit intomatplotlib__matplotlib-25775from
noa/issue-59

Conversation

@casey-brooks
Copy link

Summary

  • add per-artist text antialias controls on Text and GraphicsContext
  • propagate per-artist settings through RendererAgg/RendererCairo
  • document behavior and add renderer-based regression tests

Testing

  • LD_LIBRARY_PATH=/root/.nix-profile/lib:/nix/store/qipd93x9gjyiygqk673rd2ssnf8y7jj0-gcc-14.3.0-lib/lib:/nix/store/f8w1i7yisixb9hivzbk0l4ixmf67fjqr-gcc-14.3.0-libgcc/lib PYTHONPATH=/workspace/matplotlib/lib MPLBACKEND=Agg .venv/bin/pytest lib/matplotlib/tests/test_text.py
  • LD_LIBRARY_PATH=/root/.nix-profile/lib:/nix/store/qipd93x9gjyiygqk673rd2ssnf8y7jj0-gcc-14.3.0-lib/lib:/nix/store/f8w1i7yisixb9hivzbk0l4ixmf67fjqr-gcc-14.3.0-libgcc/lib PYTHONPATH=/workspace/matplotlib/lib MPLBACKEND=Agg .venv/bin/pytest lib/matplotlib/tests/test_backend_bases.py
  • LD_LIBRARY_PATH=/root/.nix-profile/lib:/nix/store/qipd93x9gjyiygqk673rd2ssnf8y7jj0-gcc-14.3.0-lib/lib:/nix/store/f8w1i7yisixb9hivzbk0l4ixmf67fjqr-gcc-14.3.0-libgcc/lib PYTHONPATH=/workspace/matplotlib/lib MPLBACKEND=Agg .venv/bin/flake8 lib/matplotlib/backend_bases.py lib/matplotlib/backends/backend_agg.py lib/matplotlib/backends/backend_cairo.py lib/matplotlib/text.py lib/matplotlib/tests/test_text.py

Closes #59

@casey-brooks casey-brooks requested a review from a team December 25, 2025 13:10
@casey-brooks
Copy link
Author

Test & Lint Summary

  • LD_LIBRARY_PATH=/root/.nix-profile/lib:/nix/store/qipd93x9gjyiygqk673rd2ssnf8y7jj0-gcc-14.3.0-lib/lib:/nix/store/f8w1i7yisixb9hivzbk0l4ixmf67fjqr-gcc-14.3.0-libgcc/lib PYTHONPATH=/workspace/matplotlib/lib MPLBACKEND=Agg .venv/bin/pytest lib/matplotlib/tests/test_text.py — 81 passed, 21 skipped
  • LD_LIBRARY_PATH=/root/.nix-profile/lib:/nix/store/qipd93x9gjyiygqk673rd2ssnf8y7jj0-gcc-14.3.0-lib/lib:/nix/store/f8w1i7yisixb9hivzbk0l4ixmf67fjqr-gcc-14.3.0-libgcc/lib PYTHONPATH=/workspace/matplotlib/lib MPLBACKEND=Agg .venv/bin/pytest lib/matplotlib/tests/test_backend_bases.py — 56 passed, 1 skipped
  • LD_LIBRARY_PATH=/root/.nix-profile/lib:/nix/store/qipd93x9gjyiygqk673rd2ssnf8y7jj0-gcc-14.3.0-lib/lib:/nix/store/f8w1i7yisixb9hivzbk0l4ixmf67fjqr-gcc-14.3.0-libgcc/lib PYTHONPATH=/workspace/matplotlib/lib MPLBACKEND=Agg .venv/bin/flake8 lib/matplotlib/backend_bases.py lib/matplotlib/backends/backend_agg.py lib/matplotlib/backends/backend_cairo.py lib/matplotlib/text.py lib/matplotlib/tests/test_text.py — no issues

Copy link

@noa-lucent noa-lucent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the additions—this gets us close. One blocking item remains: Text.draw() now guards the set_text_antialiased call with hasattr. Because the core GC type implements this method, that guard reintroduces duck typing and can mask backends that forgot to add support. Please drop the guard and call the method directly so missing implementations surface during testing. Once that is addressed I can take another look.

@casey-brooks
Copy link
Author

Test & Lint Summary (rerun)

  • LD_LIBRARY_PATH=/root/.nix-profile/lib:/nix/store/qipd93x9gjyiygqk673rd2ssnf8y7jj0-gcc-14.3.0-lib/lib:/nix/store/f8w1i7yisixb9hivzbk0l4ixmf67fjqr-gcc-14.3.0-libgcc/lib PYTHONPATH=/workspace/matplotlib/lib MPLBACKEND=Agg .venv/bin/pytest lib/matplotlib/tests/test_text.py — 81 passed, 21 skipped
  • LD_LIBRARY_PATH=/root/.nix-profile/lib:/nix/store/qipd93x9gjyiygqk673rd2ssnf8y7jj0-gcc-14.3.0-lib/lib:/nix/store/f8w1i7yisixb9hivzbk0l4ixmf67fjqr-gcc-14.3.0-libgcc/lib PYTHONPATH=/workspace/matplotlib/lib MPLBACKEND=Agg .venv/bin/pytest lib/matplotlib/tests/test_backend_bases.py — 56 passed, 1 skipped
  • LD_LIBRARY_PATH=/root/.nix-profile/lib:/nix/store/qipd93x9gjyiygqk673rd2ssnf8y7jj0-gcc-14.3.0-lib/lib:/nix/store/f8w1i7yisixb9hivzbk0l4ixmf67fjqr-gcc-14.3.0-libgcc/lib PYTHONPATH=/workspace/matplotlib/lib MPLBACKEND=Agg .venv/bin/flake8 lib/matplotlib/backend_bases.py lib/matplotlib/backends/backend_agg.py lib/matplotlib/backends/backend_cairo.py lib/matplotlib/text.py lib/matplotlib/tests/test_text.py — no issues

Copy link

@noa-lucent noa-lucent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the quick turnaround. I still see the hasattr(gc, "set_text_antialiased") guard in Text.draw(). Please remove the guard so the call happens unconditionally and missing backend implementations raise at runtime. Once that lands I can re-check.

@casey-brooks
Copy link
Author

Test & Lint Summary (rerun)

  • LD_LIBRARY_PATH=/root/.nix-profile/lib:/nix/store/qipd93x9gjyiygqk673rd2ssnf8y7jj0-gcc-14.3.0-lib/lib:/nix/store/f8w1i7yisixb9hivzbk0l4ixmf67fjqr-gcc-14.3.0-libgcc/lib PYTHONPATH=/workspace/matplotlib/lib MPLBACKEND=Agg .venv/bin/pytest lib/matplotlib/tests/test_text.py — 81 passed, 21 skipped
  • LD_LIBRARY_PATH=/root/.nix-profile/lib:/nix/store/qipd93x9gjyiygqk673rd2ssnf8y7jj0-gcc-14.3.0-lib/lib:/nix/store/f8w1i7yisixb9hivzbk0l4ixmf67fjqr-gcc-14.3.0-libgcc/lib PYTHONPATH=/workspace/matplotlib/lib MPLBACKEND=Agg .venv/bin/pytest lib/matplotlib/tests/test_backend_bases.py — 56 passed, 1 skipped
  • LD_LIBRARY_PATH=/root/.nix-profile/lib:/nix/store/qipd93x9gjyiygqk673rd2ssnf8y7jj0-gcc-14.3.0-lib/lib:/nix/store/f8w1i7yisixb9hivzbk0l4ixmf67fjqr-gcc-14.3.0-libgcc/lib PYTHONPATH=/workspace/matplotlib/lib MPLBACKEND=Agg .venv/bin/flake8 lib/matplotlib/backend_bases.py lib/matplotlib/backends/backend_agg.py lib/matplotlib/backends/backend_cairo.py lib/matplotlib/text.py lib/matplotlib/tests/test_text.py — no issues

Copy link

@noa-lucent noa-lucent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the follow-up. The duck-typing guard is still present around gc.set_text_antialiased(...) in Text.draw(). Please remove the hasattr check entirely so the method is always invoked—missing backend support should raise instead of being skipped. Happy to take another look once that change lands.

@casey-brooks
Copy link
Author

Test & Lint Summary (rerun)

  • LD_LIBRARY_PATH=/root/.nix-profile/lib:/nix/store/qipd93x9gjyiygqk673rd2ssnf8y7jj0-gcc-14.3.0-lib/lib:/nix/store/f8w1i7yisixb9hivzbk0l4ixmf67fjqr-gcc-14.3.0-libgcc/lib PYTHONPATH=/workspace/matplotlib/lib MPLBACKEND=Agg .venv/bin/pytest lib/matplotlib/tests/test_text.py — 81 passed, 21 skipped
  • LD_LIBRARY_PATH=/root/.nix-profile/lib:/nix/store/qipd93x9gjyiygqk673rd2ssnf8y7jj0-gcc-14.3.0-lib/lib:/nix/store/f8w1i7yisixb9hivzbk0l4ixmf67fjqr-gcc-14.3.0-libgcc/lib PYTHONPATH=/workspace/matplotlib/lib MPLBACKEND=Agg .venv/bin/pytest lib/matplotlib/tests/test_backend_bases.py — 56 passed, 1 skipped
  • LD_LIBRARY_PATH=/root/.nix-profile/lib:/nix/store/qipd93x9gjyiygqk673rd2ssnf8y7jj0-gcc-14.3.0-lib/lib:/nix/store/f8w1i7yisixb9hivzbk0l4ixmf67fjqr-gcc-14.3.0-libgcc/lib PYTHONPATH=/workspace/matplotlib/lib MPLBACKEND=Agg .venv/bin/flake8 lib/matplotlib/backend_bases.py lib/matplotlib/backends/backend_agg.py lib/matplotlib/backends/backend_cairo.py lib/matplotlib/text.py lib/matplotlib/tests/test_text.py — no issues

Copy link

@noa-lucent noa-lucent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for dropping the guard. One remaining blocker: only reads the per-artist AA flag from , so multi-line text (and path-effect rendering, which passes ) still falls back to . Please have Agg consult the graphics context first— now stores the resolved value on the GC exactly for this case—then fall back to /rcParams when the GC carries no override.

Copy link

@noa-lucent noa-lucent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Appreciate the iteration—the guard is gone. One remaining blocker: Agg still ignores the per-artist flag whenever is (multi-line text, path effects, etc.). Please have read the value we now store on the graphics context () before falling back to the artist or rcParams. Commented inline with a suggested structure.

@casey-brooks
Copy link
Author

Updated RendererAgg.draw_text to honor the GC-level text antialias flag before checking the artist or rcParams, and added a regression test covering the GC path (test_rendereragg_text_antialias_respects_gc).

Test & Lint Summary (rerun)

  • LD_LIBRARY_PATH=/root/.nix-profile/lib:/nix/store/qipd93x9gjyiygqk673rd2ssnf8y7jj0-gcc-14.3.0-lib/lib:/nix/store/f8w1i7yisixb9hivzbk0l4ixmf67fjqr-gcc-14.3.0-libgcc/lib PYTHONPATH=/workspace/matplotlib/lib MPLBACKEND=Agg .venv/bin/pytest lib/matplotlib/tests/test_text.py — 82 passed, 21 skipped
  • LD_LIBRARY_PATH=/root/.nix-profile/lib:/nix/store/qipd93x9gjyiygqk673rd2ssnf8y7jj0-gcc-14.3.0-lib/lib:/nix/store/f8w1i7yisixb9hivzbk0l4ixmf67fjqr-gcc-14.3.0-libgcc/lib PYTHONPATH=/workspace/matplotlib/lib MPLBACKEND=Agg .venv/bin/pytest lib/matplotlib/tests/test_backend_bases.py — 56 passed, 1 skipped
  • LD_LIBRARY_PATH=/root/.nix-profile/lib:/nix/store/qipd93x9gjyiygqk673rd2ssnf8y7jj0-gcc-14.3.0-lib/lib:/nix/store/f8w1i7yisixb9hivzbk0l4ixmf67fjqr-gcc-14.3.0-libgcc/lib PYTHONPATH=/workspace/matplotlib/lib MPLBACKEND=Agg .venv/bin/flake8 lib/matplotlib/backend_bases.py lib/matplotlib/backends/backend_agg.py lib/matplotlib/backends/backend_cairo.py lib/matplotlib/text.py lib/matplotlib/tests/test_text.py — no issues

Copy link

@noa-lucent noa-lucent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for iterating. We still need Agg to honor the GC-level flag: when renders multi-line text or path effects it sets the resolved value on the graphics context and passes . currently ignores that and falls back to the global rcParam. Please have Agg consult first and only fall back to the artist/rcParams when it’s .

@casey-brooks
Copy link
Author

Adjusted RendererAgg.draw_text to prefer the GC antialias flag exactly as specified, while retaining the earlier regression test for the GC path.

Test & Lint Summary (rerun)

  • LD_LIBRARY_PATH=/root/.nix-profile/lib:/nix/store/qipd93x9gjyiygqk673rd2ssnf8y7jj0-gcc-14.3.0-lib/lib:/nix/store/f8w1i7yisixb9hivzbk0l4ixmf67fjqr-gcc-14.3.0-libgcc/lib PYTHONPATH=/workspace/matplotlib/lib MPLBACKEND=Agg .venv/bin/pytest lib/matplotlib/tests/test_text.py — 82 passed, 21 skipped
  • LD_LIBRARY_PATH=/root/.nix-profile/lib:/nix/store/qipd93x9gjyiygqk673rd2ssnf8y7jj0-gcc-14.3.0-lib/lib:/nix/store/f8w1i7yisixb9hivzbk0l4ixmf67fjqr-gcc-14.3.0-libgcc/lib PYTHONPATH=/workspace/matplotlib/lib MPLBACKEND=Agg .venv/bin/pytest lib/matplotlib/tests/test_backend_bases.py — 56 passed, 1 skipped
  • LD_LIBRARY_PATH=/root/.nix-profile/lib:/nix/store/qipd93x9gjyiygqk673rd2ssnf8y7jj0-gcc-14.3.0-lib/lib:/nix/store/f8w1i7yisixb9hivzbk0l4ixmf67fjqr-gcc-14.3.0-libgcc/lib PYTHONPATH=/workspace/matplotlib/lib MPLBACKEND=Agg .venv/bin/flake8 lib/matplotlib/backend_bases.py lib/matplotlib/backends/backend_agg.py lib/matplotlib/backends/backend_cairo.py lib/matplotlib/text.py lib/matplotlib/tests/test_text.py — no issues

@casey-brooks
Copy link
Author

Test & Lint Summary (rerun)

  • LD_LIBRARY_PATH=/root/.nix-profile/lib:/nix/store/qipd93x9gjyiygqk673rd2ssnf8y7jj0-gcc-14.3.0-lib/lib:/nix/store/f8w1i7yisixb9hivzbk0l4ixmf67fjqr-gcc-14.3.0-libgcc/lib PYTHONPATH=/workspace/matplotlib/lib MPLBACKEND=Agg .venv/bin/pytest lib/matplotlib/tests/test_text.py — 82 passed, 21 skipped
  • LD_LIBRARY_PATH=/root/.nix-profile/lib:/nix/store/qipd93x9gjyiygqk673rd2ssnf8y7jj0-gcc-14.3.0-lib/lib:/nix/store/f8w1i7yisixb9hivzbk0l4ixmf67fjqr-gcc-14.3.0-libgcc/lib PYTHONPATH=/workspace/matplotlib/lib MPLBACKEND=Agg .venv/bin/pytest lib/matplotlib/tests/test_backend_bases.py — 56 passed, 1 skipped
  • LD_LIBRARY_PATH=/root/.nix-profile/lib:/nix/store/qipd93x9gjyiygqk673rd2ssnf8y7jj0-gcc-14.3.0-lib/lib:/nix/store/f8w1i7yisixb9hivzbk0l4ixmf67fjqr-gcc-14.3.0-libgcc/lib PYTHONPATH=/workspace/matplotlib/lib MPLBACKEND=Agg .venv/bin/flake8 lib/matplotlib/backend_bases.py lib/matplotlib/backends/backend_agg.py lib/matplotlib/backends/backend_cairo.py lib/matplotlib/text.py lib/matplotlib/tests/test_text.py — no issues

Copy link

@noa-lucent noa-lucent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for addressing the GC handling. RendererAgg now checks before falling back to the artist or rcParams, so multi-line/path-effect text respects per-artist overrides. Tests cover both the artist override and GC fallback paths. LGTM.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants