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/google-fonts.md
1---2name: fonts3description: Loading Google Fonts and local fonts in Remotion4metadata:5tags: fonts, google-fonts, typography, text6---78# Using fonts in Remotion910## Google Fonts with @remotion/google-fonts1112The recommended way to use Google Fonts. It's type-safe and automatically blocks rendering until the font is ready.1314### Prerequisites1516First, the @remotion/google-fonts package needs to be installed.17If it is not installed, use the following command:1819```bash20npx remotion add @remotion/google-fonts # If project uses npm21bunx remotion add @remotion/google-fonts # If project uses bun22yarn remotion add @remotion/google-fonts # If project uses yarn23pnpm exec remotion add @remotion/google-fonts # If project uses pnpm24```2526```tsx27import { loadFont } from "@remotion/google-fonts/Lobster";2829const { fontFamily } = loadFont();3031export const MyComposition = () => {32return <div style={{ fontFamily }}>Hello World</div>;33};34```3536Preferrably, specify only needed weights and subsets to reduce file size:3738```tsx39import { loadFont } from "@remotion/google-fonts/Roboto";4041const { fontFamily } = loadFont("normal", {42weights: ["400", "700"],43subsets: ["latin"],44});45```4647## Using in components4849Call `loadFont()` at the top level of your component or in a separate file that's imported early:5051```tsx52import { loadFont } from "@remotion/google-fonts/Montserrat";5354const { fontFamily } = loadFont("normal", {55weights: ["400", "700"],56subsets: ["latin"],57});5859export const Title: React.FC<{ text: string }> = ({ text }) => {60return (61<h162style={{63fontFamily,64fontSize: 80,65fontWeight: "bold",66}}67>68{text}69</h1>70);71};72```73