Skip to content

🎥 Make videos programmatically with React

update: docs

benya7035cd01ae477
diff --git a/packages/docs/docs/fonts/index.md b/packages/docs/docs/fonts/index.md
new file mode 100644
index 0000000000..41323e90b5
--- /dev/null
+++ b/packages/docs/docs/fonts/index.md
@@ -0,0 +1,66 @@
+---
+image: /generated/articles-docs-fonts-index.png
+id: fonts
+sidebar_label: Overview
+title: "@remotion/fonts"
+---
+import Tabs from '@theme/Tabs';
+import TabItem from '@theme/TabItem';
+
+
+The `@remotion/fonts` package provides APIs for easily load local fonts into Remotion.
+
+## Installation
+
+<Tabs
+defaultValue="npm"
+values={[
+{ label: 'npm', value: 'npm', },
+{ label: 'yarn', value: 'yarn', },
+{ label: 'pnpm', value: 'pnpm', },
+]
+}>
+<TabItem value="npm">
+
+```bash
+npm i @remotion/fonts
+```
+
+ </TabItem>
+
+ <TabItem value="yarn">
+
+```bash
+yarn add @remotion/fonts
+```
+
+ </TabItem>
+
+ <TabItem value="pnpm">
+
+```bash
+pnpm i @remotion/fonts
+```
+
+ </TabItem>
+</Tabs>
+
+## Usage
+
+Put the font into your `public/` folder.
+To load a font, import the package `@remotion/fonts` and call [`loadFont()`](/docs/fonts/load-font).
+
+```tsx twoslash
+import { loadFont } from "@remotion/fonts/";
+loadFont({
+ family: 'some name',
+ url: 'someName',
+ weight: '500',
+ // ... other options
+}).then(() => console.log('Font loaded!'))
+```
+
+:::note
+Check the available options [around the URL](/docs/fonts/load-font).
+The font format should be one of `woff2` for WOFF2 files, `woff` for WOFF, `opentype` for OTF, `truetype` for TTF.
+:::
diff --git a/packages/docs/docs/fonts/load-font.md b/packages/docs/docs/fonts/load-font.md
new file mode 100644
index 0000000000..e0737d485d
--- /dev/null
+++ b/packages/docs/docs/fonts/load-font.md
@@ -0,0 +1,77 @@
+---
+image: /generated/articles-docs-fonts-load-font.png
+title: loadFont()
+crumb: "@remotion/fonts"
+---
+
+_Part of the [`@remotion/fonts`](/docs/fonts) package_
+
+Load a local font for use in Remotion.
+
+- Automatically blocks the render until the font is ready.
+- Each `loadFont()` call is typesafe and available options are exposed through autocompletion.
+
+## Usage
+
+```tsx twoslash
+import { loadFont } from "@remotion/fonts";
+import { AbsoluteFill } from "remotion";
+
+loadFont({
+ family: 'Bangers',
+ url: 'bangers.ttf',
+ weight: '500'
+ // ... other options
+}).then(() => console.log('Font loaded!'));
+
+export const GoogleFontsExample: React.FC = () => {
+ return (
+ <AbsoluteFill
+ style={{
+ fontFamily: 'Bangers',
+ }}
+ >
+ <h1>Local Font</h1>
+ </AbsoluteFill>
+ );
+};
+```
+## Arguments
+
+All arguments and options are optional. Use TypeScript autocompletion.
+
+### ascentOverride
+
+Defines the ascent metric for the font.
+
+### descentOverride
+
+Defines the descent metric for the font.
+
+### display
+
+Determines how a font face is displayed based on whether and when it is downloaded and ready to use.
+
+### featureSettings
+
+Allows control over advanced typographic features in OpenType fonts.
+
+### lineGapOverride
+
+Defines the line gap metric for the font.
+
+### stretch
+
+Allows to specify a normal, condensed, or expanded face.
+
+### style
+
+The font style we want to load. While each font has a different set of styles, common options are: `normal`, `italic` etc.
+
+### unicodeRange
+
+The range of Unicode code points to be used from the font.
+
+### weight
+
+Sets the weight (or boldness) of the font. The weights available depend on the font-family that is currently set.
\ No newline at end of file
diff --git a/packages/docs/docs/studio/restart-studio.mdx b/packages/docs/docs/studio/restart-studio.mdx
index d3790e8e37..e82fe7b075 100644
--- a/packages/docs/docs/studio/restart-studio.mdx
+++ b/packages/docs/docs/studio/restart-studio.mdx
@@ -1,4 +1,5 @@
---
+image: /generated/articles-docs-studio-restart-studio.png
title: restartStudio()
crumb: "@remotion/studio"
---
diff --git a/packages/docs/docs/using-fonts.md b/packages/docs/docs/using-fonts.md
index 7682b200e4..b9cd375894 100644
--- a/packages/docs/docs/using-fonts.md
+++ b/packages/docs/docs/using-fonts.md
@@ -2,7 +2,7 @@
image: /generated/articles-docs-using-fonts.png
title: Using fonts
sidebar_label: Fonts
-id: fonts
+id: using-fonts
crumb: "Techniques"
---
@@ -44,33 +44,27 @@ const MyComp: React.FC = () => {
};
```
-## Example using local fonts
+## Local fonts using `@remotion/fonts`
-Put the font into your `public/` folder and use the [`staticFile()`](/docs/staticfile) API to load the font. Use the `FontFace` browser API to load the font. [Click here](https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face) to read the syntax that can be used for the Font Face API.
+_available from v4.0.164_
+Put the font into your `public/` folder.
Put this somewhere in your app where it gets executed:
```tsx twoslash title="load-fonts.ts"
-import { continueRender, delayRender, staticFile } from "remotion";
-
-const waitForFont = delayRender();
-const font = new FontFace(
- `Bangers`,
- `url('${staticFile("bangers.woff2")}') format('woff2')`,
-);
-
-font
- .load()
- .then(() => {
- document.fonts.add(font);
- continueRender(waitForFont);
- })
- .catch((err) => console.log("Error loading font", err));
+import {loadFont} from "@remotion/fonts";
+
+loadFont({
+ family: 'Font family name',
+ url: 'Local font url',
+ weight: '500',
+ // ... other options
+}).then(() => console.log('Font loaded!'))
```
:::note
-Make sure to include quotes [around the URL](/docs/troubleshooting/could-not-be-parsed-as-a-value-list).
-The `format` should be one of `woff2` for WOFF2 files, `woff` for WOFF, `opentype` for OTF, `truetype` for TTF.
+Check the available options [around the URL](/docs/fonts/load-font).
+The font format should be one of `woff2` for WOFF2 files, `woff` for WOFF, `opentype` for OTF, `truetype` for TTF.
:::
The font is now available for use:
diff --git a/packages/docs/package.json b/packages/docs/package.json
index b93bae5f88..7dfdda624d 100644
--- a/packages/docs/package.json
+++ b/packages/docs/package.json
@@ -34,6 +34,7 @@
"@remotion/bundler": "workspace:*",
"@remotion/cli": "workspace:*",
"@remotion/cloudrun": "workspace:*",
+ "@remotion/fonts": "workspace:*",
"@remotion/gif": "workspace:*",
"@remotion/google-fonts": "workspace:*",
"@remotion/install-whisper-cpp": "workspace:*",
diff --git a/packages/docs/sidebars.js b/packages/docs/sidebars.js
index 58aef46632..450498f4ee 100644
--- a/packages/docs/sidebars.js
+++ b/packages/docs/sidebars.js
@@ -543,6 +543,17 @@ module.exports = {
"install-whisper-cpp/convert-to-captions",
],
},
+ {
+ type: "category",
+ label: "@remotion/fonts",
+ link: {
+ type: "doc",
+ id: "fonts/fonts",
+ },
+ items: [
+ "fonts/load-font"
+ ],
+ },
],
mainSidebar: [
{
@@ -566,7 +577,7 @@ module.exports = {
"layers",
"transitioning",
"using-audio",
- "fonts",
+ "using-fonts",
"measuring",
"using-randomness",
"audio-visualization",
diff --git a/packages/docs/src/data/articles.ts b/packages/docs/src/data/articles.ts
index 9a08110008..ca1888c135 100644
--- a/packages/docs/src/data/articles.ts
+++ b/packages/docs/src/data/articles.ts
@@ -86,7 +86,7 @@ export const articles = [
{
id: "api",
title: "API overview",
- relativePath: "docs/api.md",
+ relativePath: "docs/api.mdx",
compId: "articles-docs-api",
crumb: null,
},
@@ -679,7 +679,7 @@ export const articles = [
crumb: "@remotion/enable-scss",
},
{
- id: "enable-scss",
+ id: "enable-scss/overview",
title: "@remotion/enable-scss",
relativePath: "docs/enable-scss/overview.mdx",
compId: "articles-docs-enable-scss-overview",
@@ -741,6 +741,20 @@ export const articles = [
compId: "articles-docs-font-picker",
crumb: "Building video apps",
},
+ {
+ id: "fonts",
+ title: "@remotion/fonts",
+ relativePath: "docs/fonts/index.md",
+ compId: "articles-docs-fonts-index",
+ crumb: null,
+ },
+ {
+ id: "fonts/load-font",
+ title: "loadFont()",
+ relativePath: "docs/fonts/load-font.md",
+ compId: "articles-docs-fonts-load-font",
+ crumb: "@remotion/fonts",
+ },
{
id: "freeze",
title: "<Freeze>",
@@ -2790,7 +2804,7 @@ export const articles = [
{
id: "standalone",
title: "Useful functions outside of Remotion",
- relativePath: "docs/standalone.md",
+ relativePath: "docs/standalone.mdx",
compId: "articles-docs-standalone",
crumb: null,
},
@@ -2871,6 +2885,13 @@ export const articles = [
compId: "articles-docs-studio-quick-switcher",
crumb: "Remotion Studio",
},
+ {
+ id: "studio/restart-studio",
+ title: "restartStudio()",
+ relativePath: "docs/studio/restart-studio.mdx",
+ compId: "articles-docs-studio-restart-studio",
+ crumb: "@remotion/studio",
+ },
{
id: "studio/save-default-props",
title: "saveDefaultProps()",
@@ -3383,7 +3404,7 @@ export const articles = [
crumb: "Techniques",
},
{
- id: "fonts",
+ id: "using-fonts",
title: "Using fonts",
relativePath: "docs/using-fonts.md",
compId: "articles-docs-using-fonts",
diff --git a/packages/docs/static/generated/articles-docs-fonts-index.png b/packages/docs/static/generated/articles-docs-fonts-index.png
new file mode 100644
index 0000000000..79eeb550de
Binary files /dev/null and b/packages/docs/static/generated/articles-docs-fonts-index.png differ
diff --git a/packages/docs/static/generated/articles-docs-fonts-load-font.png b/packages/docs/static/generated/articles-docs-fonts-load-font.png
new file mode 100644
index 0000000000..2b4c19b287
Binary files /dev/null and b/packages/docs/static/generated/articles-docs-fonts-load-font.png differ
diff --git a/packages/docs/static/generated/articles-docs-studio-restart-studio.png b/packages/docs/static/generated/articles-docs-studio-restart-studio.png
new file mode 100644
index 0000000000..e3b8bdb950
Binary files /dev/null and b/packages/docs/static/generated/articles-docs-studio-restart-studio.png differ
diff --git a/packages/docs/tsconfig.json b/packages/docs/tsconfig.json
index 02e0a37330..6bfc8db7b1 100644
--- a/packages/docs/tsconfig.json
+++ b/packages/docs/tsconfig.json
@@ -29,6 +29,7 @@
{ "path": "../babel-loader" },
{ "path": "../cloudrun" },
{ "path": "../create-video" },
+ { "path": "../fonts" },
{ "path": "../lottie" },
{ "path": "../noise" },
{ "path": "../paths" },