|
1 | 1 | import { continueRender, delayRender, staticFile } from "remotion"; |
2 | 2 |
|
3 | | -const waitForGroteskFont = delayRender("groteskFont"); |
4 | | -const groteskFont = new FontFace( |
5 | | - `Founders Grotesk`, |
6 | | - `url(${staticFile("fonts/FoundersGrotesk-Bold.woff2")}) format('woff2')`, |
7 | | - { weight: "700" } |
8 | | -); |
| 3 | +export const loadFonts = async () => { |
| 4 | + const waitForGroteskFont = delayRender("groteskFont"); |
| 5 | + const groteskFont = new FontFace( |
| 6 | + `Founders Grotesk`, |
| 7 | + `url(${staticFile("fonts/FoundersGrotesk-Bold.woff2")}) format('woff2')`, |
| 8 | + { weight: "700" } |
| 9 | + ); |
9 | 10 |
|
10 | | -groteskFont |
11 | | - .load() |
12 | | - .then(() => { |
13 | | - document.fonts.add(groteskFont); |
14 | | - continueRender(waitForGroteskFont); |
| 11 | + groteskFont |
| 12 | + .load() |
| 13 | + .then(() => { |
| 14 | + document.fonts.add(groteskFont); |
| 15 | + continueRender(waitForGroteskFont); |
| 16 | + }) |
| 17 | + .catch((err) => console.log("Error loading font", err)); |
15 | 18 |
|
16 | | - console.log("Loaded Grotesk font"); |
17 | | - }) |
18 | | - .catch((err) => console.log("Error loading font", err)); |
| 19 | + const waitForGtPlanar = delayRender("gtPlanar"); |
| 20 | + const gtPlanarFont = new FontFace( |
| 21 | + `GTPlanar`, |
| 22 | + `url(${staticFile("fonts/gt-planar-black.woff2")}) format('woff2')`, |
| 23 | + { weight: "700" } |
| 24 | + ); |
19 | 25 |
|
20 | | -const waitForGtPlanar = delayRender("gtPlanar"); |
21 | | -const gtPlanarFont = new FontFace( |
22 | | - `GTPlanar`, |
23 | | - `url(${staticFile("fonts/gt-planar-black.woff2")}) format('woff2')`, |
24 | | - { weight: "700" } |
25 | | -); |
26 | | - |
27 | | -gtPlanarFont |
28 | | - .load() |
29 | | - .then(() => { |
30 | | - document.fonts.add(gtPlanarFont); |
31 | | - continueRender(waitForGtPlanar); |
32 | | - console.log("Loaded GTPlanar font"); |
33 | | - }) |
34 | | - .catch((err) => console.log("Error loading font", err)); |
| 26 | + gtPlanarFont |
| 27 | + .load() |
| 28 | + .then(() => { |
| 29 | + document.fonts.add(gtPlanarFont); |
| 30 | + continueRender(waitForGtPlanar); |
| 31 | + }) |
| 32 | + .catch((err) => console.log("Error loading font", err)); |
| 33 | +}; |
0 commit comments