Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Apply best practices for creating programmatic videos with Remotion and React
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
rules/local-fonts.md
1For local font files, use the `@remotion/fonts` package.23### Prerequisites45First, install @remotion/fonts:67```bash8npx remotion add @remotion/fonts # If project uses npm9bunx remotion add @remotion/fonts # If project uses bun10yarn remotion add @remotion/fonts # If project uses yarn11pnpm exec remotion add @remotion/fonts # If project uses pnpm12```1314### Loading a local font1516Place your font file in the `public/` folder and use `loadFont()`:1718```tsx19import { loadFont } from "@remotion/fonts";20import { staticFile } from "remotion";2122await loadFont({23family: "MyFont",24url: staticFile("MyFont-Regular.woff2"),25});2627export const MyComposition = () => {28return <div style={{ fontFamily: "MyFont" }}>Hello World</div>;29};30```3132### Loading multiple weights3334Load each weight separately with the same family name:3536```tsx37import { loadFont } from "@remotion/fonts";38import { staticFile } from "remotion";3940await Promise.all([41loadFont({42family: "Inter",43url: staticFile("Inter-Regular.woff2"),44weight: "400",45}),46loadFont({47family: "Inter",48url: staticFile("Inter-Bold.woff2"),49weight: "700",50}),51]);52```5354### Available options5556```tsx57loadFont({58family: "MyFont", // Required: name to use in CSS59url: staticFile("font.woff2"), // Required: font file URL60format: "woff2", // Optional: auto-detected from extension61weight: "400", // Optional: font weight62style: "normal", // Optional: normal or italic63display: "block", // Optional: font-display behavior64});65```66