Remotion
Tegaki integrates with Remotion for programmatic video rendering. Because Remotion drives time via useCurrentFrame(), the trick is to put Tegaki in controlled progress mode and map frame / durationInFrames to a 0–1 progress value.
Installation
Section titled “Installation”npm install tegaki remotion @remotion/cli react react-dompnpm add tegaki remotion @remotion/cli react react-domyarn add tegaki remotion @remotion/cli react react-dombun add tegaki remotion @remotion/cli react react-domBasic example
Section titled “Basic example”The unit: 'progress' option interprets value as a 0–1 ratio of the total animation duration, so you don’t need to know Tegaki’s computed timeline length: Remotion’s composition length drives the mapping directly.
Loading fonts
Section titled “Loading fonts”Tegaki’s font bundles (tegaki/fonts/caveat, tegaki/fonts/italianno, etc.) load their own font: the engine creates a FontFace and registers it with document.fonts. Remotion waits on document.fonts.ready before capturing each frame, so no loadFont call is required. Pass the bundle to TegakiRenderer.
Webpack override for Remotion Studio
Section titled “Webpack override for Remotion Studio”Rendering with remotion render needs no setup, but Remotion Studio’s dev server serves the TTF URL incorrectly because the bundled path escapes the studio’s root (webpack emits ../../node_modules/tegaki/fonts/caveat/caveat.ttf, which the SPA catch-all intercepts and returns HTML).
The fix is to tell webpack to inline .ttf files as data URLs. Add a remotion.config.ts at the root of your Remotion project:
This works in both the studio and in render/build mode. The bundled font is ~60–250 kB depending on the family, which is negligible for a video bundle.
Controlling timing
Section titled “Controlling timing”By default, progress = frame / durationInFrames spreads the handwriting animation across the entire composition. Two common variations:
Finish drawing before the end of the composition, e.g. to hold the finished text for the last second:
Start drawing after a delay:
Effects, plugins and the seed
Section titled “Effects, plugins and the seed”Wobble, gradients and plugins such as variationPlugin draw their randomness from the renderer’s seed. It defaults to 0, so every frame matches, including frames rendered in parallel tabs. To give a video a different look, pass another fixed number (seed={7}). Never pass seed="random" in a composition, because each rendering tab would pick its own seed and the handwriting would jump between frames.
boilPlugin picks its drawing from the time you pass, so it renders the same every time too. It follows the timeline’s seconds, so pass the time in seconds rather than as progress if the boil should run at video speed and go on after the text is written:
Time past the end keeps the text finished, and the boil keeps cycling.
Natural pacing
Section titled “Natural pacing”unit: 'progress' stretches or squeezes the writing to fit the composition. To keep Tegaki’s own pace (its per-stroke timing, as on a web page), pass the time in seconds and size the composition from the timeline with calculateMetadata:
Pass computeTimeline the same timing you give the renderer (as its third argument), or the durations won’t match. The timeline’s entries also give each character’s start and duration, and strokeInstances each stroke’s, for syncing sound effects or cuts to the pen.
Arabic, Devanagari and other complex scripts
Section titled “Arabic, Devanagari and other complex scripts”Shaping is opt-in. Fonts that need it (joining, ligatures, reordering: amiri, tillana, atma, suez-one) need the harfbuzz shaper registered once, and a composition sized from the shaped timeline, which can differ from the unshaped one by a third:
The shaper loads asynchronously. To be sure no frame is captured before it (and the font) are ready, hold the render on TegakiEngine.preload(bundle) with Remotion’s delayRender / continueRender.
Using your own font
Section titled “Using your own font”The pre-built bundles (tegaki/fonts/*) are convenient but you can use any font generated by the Tegaki generator. See Generating Font Data.