Skip to content

deviceTest: the example rendered no text at all - #1667

Merged
obiot merged 1 commit into
masterfrom
fix/devicetest-text
Sep 14, 2026
Merged

obiot merged 1 commit into
masterfrom
fix/devicetest-text

Conversation

@obiot

@obiot obiot commented Sep 14, 2026

Copy link
Copy Markdown
Member

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 Font blitter signature:

this.font.draw(renderer, `Gamma: ${device.gamma}`, 10, 0);

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 no text — at (0, 0).

Fix

A Text is a renderable, so each readout is positioned and then drawn:

private line(renderer, text, x, y) {
    this.font.pos.x = x;
    this.font.pos.y = y;
    this.font.setText(text);
    this.font.draw(renderer);
}

pos.x / pos.y per component, because pos.set(x, y) is the 2-argument form and zeroes z — which is depth.

Two faults only visible once text rendered

  • the default textBaseline put the first line at y = 0 mostly above the canvas, so it never appeared — now top, with the lines starting at 30
  • the bottom message at height - 30 was clipped — now height - 40

This also depends on the Text positioning 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 (Gammaorientation, plus the motion-detection message), no page errors. Types clean, pnpm lint 0 errors.

No CHANGELOG entry — examples aren't part of the published package.

🤖 Generated with Claude Code

https://claude.ai/code/session_01NGvtaUNATVCVxD2qcbiY4t

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
Copilot AI lite review requested due to automatic review settings September 14, 2026 23:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@obiot
obiot merged commit 3f1e30d into master Sep 14, 2026
6 checks passed
@obiot
obiot deleted the fix/devicetest-text branch September 14, 2026 23:30
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