Skip to content

🎥 Make videos programmatically with React

fix demo

Jonny Burgerada89577bfc4
diff --git a/packages/bundler/src/start-server.ts b/packages/bundler/src/start-server.ts
index eabf90b767..ef62edfbb5 100644
--- a/packages/bundler/src/start-server.ts
+++ b/packages/bundler/src/start-server.ts
@@ -44,7 +44,7 @@ export const startServer = async (
});
const compiler = webpack(config);
- const hash = `static-${crypto.randomBytes(6).toString('hex')}`;
+ const hash = `/static-${crypto.randomBytes(6).toString('hex')}`;
app.use(hash, express.static(path.join(process.cwd(), 'public')));
app.use(webpackDevMiddleware(compiler));
diff --git a/packages/example/package.json b/packages/example/package.json
index fecf538bc1..7e09ccd25b 100644
--- a/packages/example/package.json
+++ b/packages/example/package.json
@@ -36,6 +36,7 @@
"@types/express": "^4.17.11",
"@types/node": "^16.7.5",
"@types/styled-components": "^5.1.1",
+ "@types/web": "^0.0.48",
"babel-loader": "^8.2.2",
"express": "^4.17.1",
"mdx-loader": "3.0.2",
diff --git a/packages/example/public/bangers.woff2 b/packages/example/public/bangers.woff2
new file mode 100644
index 0000000000..7e4a7fa22c
Binary files /dev/null and b/packages/example/public/bangers.woff2 differ
diff --git a/packages/example/src/Fonts/index.tsx b/packages/example/src/Fonts/index.tsx
new file mode 100644
index 0000000000..3fabb26aef
--- /dev/null
+++ b/packages/example/src/Fonts/index.tsx
@@ -0,0 +1,31 @@
+import React from 'react';
+import {AbsoluteFill, 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));
+
+export const FontDemo: React.FC = () => {
+ return (
+ <AbsoluteFill
+ style={{
+ justifyContent: 'center',
+ alignItems: 'center',
+ fontFamily: 'Bangers',
+ fontSize: 300,
+ }}
+ >
+ <h1>Font Demo</h1>
+ </AbsoluteFill>
+ );
+};
diff --git a/packages/example/src/Video.tsx b/packages/example/src/Video.tsx
index b59fa52dbe..84cbf400ee 100644
--- a/packages/example/src/Video.tsx
+++ b/packages/example/src/Video.tsx
@@ -2,6 +2,7 @@ import React from 'react';
import {Composition, getInputProps, Still} from 'remotion';
import BetaText from './BetaText';
import {ColorInterpolation} from './ColorInterpolation';
+import {FontDemo} from './Fonts';
import {Framer} from './Framer';
import {MissingImg} from './MissingImg';
import {OrbScene} from './Orb';
@@ -287,9 +288,10 @@ export const Index: React.FC = () => {
<Still
id="static-demo"
component={StaticDemo}
- width={2000}
- height={2000}
+ width={1000}
+ height={1000}
/>
+ <Still id="font-demo" component={FontDemo} width={1000} height={1000} />
</>
);
};