Skip to content

fix(kit): load the faces a page uses only on a canvas before the first frame - #100

Merged
umiyosh merged 1 commit into
masterfrom
fix/issue-90-canvas-fonts
Nov 18, 2026
Merged

umiyosh merged 1 commit into
masterfrom
fix/issue-90-canvas-fonts

Conversation

@umiyosh

@umiyosh umiyosh commented Nov 17, 2026

Copy link
Copy Markdown
Owner

Fixes #90. Part of #87.

Summary

A film that draws text only on a canvas now has its fonts loaded before the first frame. Before this, check could fail with "the frame changes after seeking back" even though the film draws from the time alone.

Cause

The player loaded the optional hand-written face (Klee One) only when an element's computed style used it. A canvas uses no element, so the face was not loaded. The first frame drew in a fallback font, and a frame drawn again after seeking back used the real one. The glyphs to load also came only from document.body.textContent, which leaves out scripts in <head>.

Change

kit/player.js:

  • A face counts as used when the page's own markup or scripts name it, for example ctx.font = "600 40px 'Klee One'".
  • The glyphs to load come from the whole document's text, scripts included.

Test

  • New test in tests/html-film.test.ts. The page draws its text only when Klee One is already loaded, and only before 1 s, so the first frame differs from the bare one only if the player loaded the face up front. It failed before the change and passes after.
  • make check passes.

@umiyosh
umiyosh merged commit aa2f72d into master Nov 18, 2026
1 of 2 checks passed
@umiyosh
umiyosh deleted the fix/issue-90-canvas-fonts branch November 18, 2026 15:26
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.

kit: canvas-only text is drawn before its font loads, so check fails on seeking back

1 participant