deviceTest: the example rendered no text at all - #1667
Merged
Merged
Conversation
Nine calls used `font.draw(renderer, text, x, y)` — the old `Font` blitter signature. `Text#draw()` takes the renderer and nothing else, so the last three arguments were dropped on every call and the same label, constructed with no text, was drawn at (0, 0) each time. On screen: a red ball on black and nothing else. A `Text` is a renderable, so each readout is positioned and then drawn. `pos.x` / `pos.y` are assigned per component because `pos.set(x, y)` is the 2-argument form and zeroes z, which is `depth`. Two faults only became visible once text actually rendered: the default `textBaseline` put the first line at y = 0 mostly above the canvas, and the bottom message at `height - 30` was clipped. The baseline is now `top`, the lines start at 30, and the message sits at `height - 40`. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NGvtaUNATVCVxD2qcbiY4t
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Opening the Device Test example showed a red ball on black and nothing else — none of the eight readouts.
Cause
Nine calls used the old
Fontblitter signature:Text#draw()takes the renderer and nothing else, so the last three arguments were dropped on every call. Each one drew the same label — constructed with notext— at (0, 0).Fix
A
Textis a renderable, so each readout is positioned and then drawn:pos.x/pos.yper component, becausepos.set(x, y)is the 2-argument form and zeroes z — which isdepth.Two faults only visible once text rendered
textBaselineput the first line aty = 0mostly above the canvas, so it never appeared — nowtop, with the lines starting at 30height - 30was clipped — nowheight - 40This also depends on the
Textpositioning fix from #1662: repositioning a label between draws used to leave the glyphs at the old spot, which is exactly what this helper does eight times a frame.Verification
Captured in Chrome: all eight readouts render (
Gamma…orientation, plus the motion-detection message), no page errors. Types clean,pnpm lint0 errors.No CHANGELOG entry — examples aren't part of the published package.
🤖 Generated with Claude Code
https://claude.ai/code/session_01NGvtaUNATVCVxD2qcbiY4t