Skip to content

World's first open-source, agentic video production system. 12 production pipelines, 100+ tools, 700+ agent skill and production-knowledge files. Turn your AI coding assistant into a full video production studio.

feat(remotion): bundle the webfonts locally so a render needs no network (#663)

mynetfocus7157ce165189
diff --git a/remotion-composer/src/CinematicRenderer.tsx b/remotion-composer/src/CinematicRenderer.tsx
index 926c59c7..5f0245bc 100644
--- a/remotion-composer/src/CinematicRenderer.tsx
+++ b/remotion-composer/src/CinematicRenderer.tsx
@@ -1,5 +1,5 @@
import React from "react";
-import { loadFont } from "@remotion/google-fonts/SpaceGrotesk";
+import { loadSpaceGrotesk } from "./lib/localFonts";
import {
AbsoluteFill,
Audio,
@@ -18,10 +18,7 @@ import { resolveAsset } from "./lib/resolveAsset";
const FPS = 30;
-const { fontFamily } = loadFont("normal", {
- weights: ["400", "500", "700"],
- subsets: ["latin"],
-});
+const { fontFamily } = loadSpaceGrotesk(["400", "500", "700"]);
const toneGradient = (tone: CinematicTone) => {
switch (tone) {
@@ -120,6 +117,8 @@ const SignalTexture: React.FC<{
lineCount: number;
}> = ({ accent, intensity, lineCount }) => {
const frame = useCurrentFrame();
+ // The frame width, not a hardcoded 1920: odd lines sit on the right edge.
+ const { width: frameWidth } = useVideoConfig();
return (
<AbsoluteFill style={{ pointerEvents: "none" }}>
@@ -128,7 +127,7 @@ const SignalTexture: React.FC<{
const opacity = (0.025 + pulse * 0.07) * intensity;
const width = 18 + ((index * 37) % 56);
const top = 140 + index * 42;
- const left = index % 2 === 0 ? 0 : 1920 - width;
+ const left = index % 2 === 0 ? 0 : frameWidth - width;
return (
<div
diff --git a/remotion-composer/src/CollageBurst.tsx b/remotion-composer/src/CollageBurst.tsx
index 77cf0c74..fa00330f 100644
--- a/remotion-composer/src/CollageBurst.tsx
+++ b/remotion-composer/src/CollageBurst.tsx
@@ -10,17 +10,11 @@ import {
useVideoConfig,
} from "remotion";
import React from "react";
-import { loadFont as loadPlayfair } from "@remotion/google-fonts/PlayfairDisplay";
+import { loadPlayfair } from "./lib/localFonts";
import { resolveAsset } from "./lib/resolveAsset";
-const { fontFamily: playfairFamily } = loadPlayfair("normal", {
- weights: ["400", "700"],
- subsets: ["latin"],
-});
-const { fontFamily: playfairItalic } = loadPlayfair("italic", {
- weights: ["400", "700"],
- subsets: ["latin"],
-});
+const { fontFamily: playfairFamily } = loadPlayfair("normal", ["400", "700"]);
+const { fontFamily: playfairItalic } = loadPlayfair("italic", ["400", "700"]);
export type CollageTransition =
| "pop"
diff --git a/remotion-composer/src/Explainer.tsx b/remotion-composer/src/Explainer.tsx
index 99dd6370..707e6db3 100644
--- a/remotion-composer/src/Explainer.tsx
+++ b/remotion-composer/src/Explainer.tsx
@@ -9,7 +9,7 @@ import {
useCurrentFrame,
useVideoConfig,
} from "remotion";
-import { loadFont } from "@remotion/google-fonts/SpaceGrotesk";
+import { loadSpaceGrotesk } from "./lib/localFonts";
import { TextCard } from "./components/TextCard";
import { StatCard } from "./components/StatCard";
import { CalloutBox } from "./components/CalloutBox";
@@ -35,10 +35,7 @@ import type { ParticleType } from "./components/ParticleOverlay";
import { resolveTheme, type ThemeConfig, DEFAULT_THEME } from "./Root";
// Load Space Grotesk font for cinematic typography
-const { fontFamily } = loadFont("normal", {
- weights: ["400", "700"],
- subsets: ["latin"],
-});
+const { fontFamily } = loadSpaceGrotesk(["400", "700"]);
// ---------------------------------------------------------------------------
// Animated Background — Gradient Mesh + Floating Orbs
diff --git a/remotion-composer/src/LyricOverlay.tsx b/remotion-composer/src/LyricOverlay.tsx
index 287110f7..0ac68c41 100644
--- a/remotion-composer/src/LyricOverlay.tsx
+++ b/remotion-composer/src/LyricOverlay.tsx
@@ -7,13 +7,10 @@ import {
useVideoConfig,
} from "remotion";
import React from "react";
-import { loadFont as loadPlayfair } from "@remotion/google-fonts/PlayfairDisplay";
+import { loadPlayfair } from "./lib/localFonts";
import { resolveAsset } from "./lib/resolveAsset";
-const { fontFamily: playfairItalic } = loadPlayfair("italic", {
- weights: ["400", "700"],
- subsets: ["latin"],
-});
+const { fontFamily: playfairItalic } = loadPlayfair("italic", ["400", "700"]);
export interface Lyric {
text: string;
diff --git a/remotion-composer/src/TitledVideo.tsx b/remotion-composer/src/TitledVideo.tsx
index 0f710cae..f1cd3672 100644
--- a/remotion-composer/src/TitledVideo.tsx
+++ b/remotion-composer/src/TitledVideo.tsx
@@ -9,15 +9,12 @@ import {
useVideoConfig,
} from "remotion";
import { getVideoMetadata } from "@remotion/media-utils";
-import { loadFont } from "@remotion/google-fonts/PlayfairDisplay";
+import { loadPlayfair } from "./lib/localFonts";
import { resolveAsset } from "./lib/resolveAsset";
// Editorial serif for the tagline — Playfair Display at its boldest weight.
// Loaded once at module scope so every render reuses the same font face.
-const { fontFamily } = loadFont("normal", {
- weights: ["400", "700", "900"],
- subsets: ["latin"],
-});
+const { fontFamily } = loadPlayfair("normal", ["400", "700", "900"]);
export type TitledVideoProps = {
videoSrc: string;
diff --git a/remotion-composer/src/fonts/PlayfairDisplay-Italic-latin.woff2 b/remotion-composer/src/fonts/PlayfairDisplay-Italic-latin.woff2
new file mode 100644
index 00000000..8ae1f1f7
Binary files /dev/null and b/remotion-composer/src/fonts/PlayfairDisplay-Italic-latin.woff2 differ
diff --git a/remotion-composer/src/fonts/PlayfairDisplay-OFL.txt b/remotion-composer/src/fonts/PlayfairDisplay-OFL.txt
new file mode 100644
index 00000000..13153890
--- /dev/null
+++ b/remotion-composer/src/fonts/PlayfairDisplay-OFL.txt
@@ -0,0 +1,93 @@
+Copyright 2017 The Playfair Display Project Authors (https://github.com/clauseggers/Playfair-Display), with Reserved Font Name "Playfair Display"
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+http://scripts.sil.org/OFL
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/remotion-composer/src/fonts/PlayfairDisplay-latin.woff2 b/remotion-composer/src/fonts/PlayfairDisplay-latin.woff2
new file mode 100644
index 00000000..5a3fbbda
Binary files /dev/null and b/remotion-composer/src/fonts/PlayfairDisplay-latin.woff2 differ
diff --git a/remotion-composer/src/fonts/SpaceGrotesk-OFL.txt b/remotion-composer/src/fonts/SpaceGrotesk-OFL.txt
new file mode 100644
index 00000000..f831dbc6
--- /dev/null
+++ b/remotion-composer/src/fonts/SpaceGrotesk-OFL.txt
@@ -0,0 +1,93 @@
+Copyright 2020 The Space Grotesk Project Authors (https://github.com/floriankarsten/space-grotesk)
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+http://scripts.sil.org/OFL
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/remotion-composer/src/fonts/SpaceGrotesk-latin.woff2 b/remotion-composer/src/fonts/SpaceGrotesk-latin.woff2
new file mode 100644
index 00000000..0f3474ee
Binary files /dev/null and b/remotion-composer/src/fonts/SpaceGrotesk-latin.woff2 differ
diff --git a/remotion-composer/src/fonts/fonts.d.ts b/remotion-composer/src/fonts/fonts.d.ts
new file mode 100644
index 00000000..0199a101
--- /dev/null
+++ b/remotion-composer/src/fonts/fonts.d.ts
@@ -0,0 +1,5 @@
+// Remotion's bundler turns an imported font file into a URL string.
+declare module "*.woff2" {
+ const url: string;
+ export default url;
+}
diff --git a/remotion-composer/src/lib/localFonts.ts b/remotion-composer/src/lib/localFonts.ts
new file mode 100644
index 00000000..526b31d8
--- /dev/null
+++ b/remotion-composer/src/lib/localFonts.ts
@@ -0,0 +1,55 @@
+import { cancelRender, continueRender, delayRender } from "remotion";
+
+import playfairItalicUrl from "../fonts/PlayfairDisplay-Italic-latin.woff2";
+import playfairUrl from "../fonts/PlayfairDisplay-latin.woff2";
+import spaceGroteskUrl from "../fonts/SpaceGrotesk-latin.woff2";
+
+/**
+ * Fonts bundled with the compositions instead of fetched from Google Fonts at
+ * render time, so a render needs no network and a flaky connection cannot fail
+ * it. The files are the exact latin woff2 files @remotion/google-fonts
+ * requested (Space Grotesk v22, Playfair Display v40; SIL OFL 1.1, licences in
+ * ../fonts), registered the same way: one FontFace per requested weight, same
+ * family name, same unicode range, so glyphs render identically.
+ *
+ * Registration is DEFERRED to a microtask. Remotion's delay-render module runs
+ * `window.remotion_delayRenderHandles = []` when it is evaluated, and this
+ * bundle holds two copies of it. A handle created during bundle evaluation,
+ * before the second copy ran, was wiped from the list while its timeout
+ * survived: continueRender could not find it and the render failed "not
+ * cleared after 28000ms" (2 of 3 collage renders, measured 2026-09-16). A
+ * microtask runs after the whole synchronous bundle evaluation — so after every
+ * Remotion init — and before any frame can be captured.
+ */
+
+const LATIN =
+ "U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD";
+
+const loaded = new Set<string>();
+
+const register = (family: string, url: string, style: "normal" | "italic", weights: string[]) => {
+ if (typeof FontFace === "undefined") return family;
+ for (const weight of weights) {
+ const key = `${family}-${style}-${weight}`;
+ if (loaded.has(key)) continue;
+ loaded.add(key);
+ queueMicrotask(() => {
+ const handle = delayRender(`Loading bundled font ${key}`);
+ const face = new FontFace(family, `url(${url}) format('woff2')`, { weight, style, unicodeRange: LATIN });
+ face
+ .load()
+ .then(() => {
+ document.fonts.add(face);
+ continueRender(handle);
+ })
+ // Never silently fall back to a system font: fail the render.
+ .catch((err) => cancelRender(new Error(`Bundled font ${key} failed to load: ${err}`)));
+ });
+ }
+ return family;
+};
+
+export const loadSpaceGrotesk = (weights: string[]) => ({ fontFamily: register("Space Grotesk", spaceGroteskUrl, "normal", weights) });
+export const loadPlayfair = (style: "normal" | "italic", weights: string[]) => ({
+ fontFamily: register("Playfair Display", style === "italic" ? playfairItalicUrl : playfairUrl, style, weights),
+});