Skip to content

Pin that drawText leaves the surface visible around the glyphs - #53

Merged
dmccoystephenson merged 1 commit into
mainfrom
test/pin-draw-text-transparent-background
Oct 18, 2026
Merged

dmccoystephenson merged 1 commit into
mainfrom
test/pin-draw-text-transparent-background

Conversation

@dmccoystephenson

Copy link
Copy Markdown
Member

Summary

  • A characterization test, test_draw_text_leaves_the_surface_visible_around_the_glyphs, is added. It pins that drawText paints only the glyphs: the rest of the rendered text's rectangle keeps whatever was already on the surface.
  • This behavior was previously unguarded. Every existing text test (including the drawButton label tests, whose ink filter excludes black) draws onto a black background, where rendering with an opaque black background looks identical. drawButton relies on the transparent background to show its label over colorBox.
  • The test draws a . (which inks only the bottom of its line) onto a green surface and requires the top row of the centered text rectangle to stay green.
  • No production code is changed.

Test plan

  • python3 -m pytest -q → 64 passed (63 before).
  • python3 -m py_compile src/main/python/preponderous/graphik/graphik.py succeeds.
  • Sensitivity confirmed empirically: with drawText temporarily changed to myFont.render(text, True, color, (0, 0, 0)), only the new test fails (1 failed, 63 passed); with the change reverted, all 64 pass.

Triage notes (skipped issues)

This cycle was a Stage B (unit-test expansion) cycle, because every open issue is gated:

This PR description was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).

🤖 Generated with Claude Code


drafted by Claude on behalf of Daniel Stephenson

Every other text test draws onto a black background, where rendering
with an opaque black background looks identical, so nothing caught a
drawText that painted a box behind its text. Draw onto green instead
and require the untouched part of the text rectangle to stay green.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dmccoystephenson

Copy link
Copy Markdown
Member Author

Self-review rubric (performed inline; no independent reviewer is configured — --add-reviewer Copilot failed to resolve):

Judgment note: src/test/python/preponderous/graphik/test_graphik.py:596 — the expected rectangle is rebuilt from a separate pygame.font.Font("freesansbold.ttf", size) instead of being read from Graphik's cache, so the test hard-codes the font file drawText uses. If the font ever changes, the rectangle could drift. Since . inks only the bottom of its line, a small drift would still leave the top row free of glyph pixels, so this was accepted.

This review comment was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).


drafted by Claude on behalf of Daniel Stephenson

@dmccoystephenson
dmccoystephenson merged commit efbf5bd into main Oct 18, 2026
5 checks passed
@dmccoystephenson
dmccoystephenson deleted the test/pin-draw-text-transparent-background branch October 18, 2026 12:21
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.

1 participant