Skip to content

🎥 Make videos programmatically with React

`example`: Add issue #7359 fitTextOnNLines repro still

Jonny Burgerfb4f74282067
diff --git a/packages/example/src/Root.tsx b/packages/example/src/Root.tsx
index 2a8069e035..6ff397c174 100644
--- a/packages/example/src/Root.tsx
+++ b/packages/example/src/Root.tsx
@@ -189,6 +189,7 @@ import {StarburstExample} from './Starburst';
import {Seek} from './StudioApis/Seek';
import {TikTokTextBoxPlayground} from './TikTokTextbox/TikTokTextBox';
import {FitTextOnNLines, fitTextOnNLinesSchema} from './Title/FitTextOnNLines';
+import {Issue7359FitTextOnNLines} from './Title/Issue7359FitTextOnNLines';
import {TransitionRounding} from './TransitionRounding';
import {WebGlTransition} from './Transitions/WebGlTransition';
import {
@@ -713,6 +714,12 @@ export const Index: React.FC = () => {
textAlign: 'right' as const,
}}
/>
+ <Still
+ id="issue-7359-fit-text-on-n-lines"
+ component={Issue7359FitTextOnNLines}
+ width={1280}
+ height={720}
+ />
<Composition
id="beta-text"
component={BetaText}
diff --git a/packages/example/src/Title/Issue7359FitTextOnNLines.tsx b/packages/example/src/Title/Issue7359FitTextOnNLines.tsx
new file mode 100644
index 0000000000..78e46d7d21
--- /dev/null
+++ b/packages/example/src/Title/Issue7359FitTextOnNLines.tsx
@@ -0,0 +1,69 @@
+import {fitTextOnNLines} from '@remotion/layout-utils';
+import React, {useMemo} from 'react';
+import {AbsoluteFill} from 'remotion';
+
+const BOX_WIDTH = 756;
+
+/**
+ * Minimal reproduction for https://github.com/remotion-dev/remotion/issues/7359
+ */
+export const Issue7359FitTextOnNLines: React.FC = () => {
+ const {fontSize, lines} = useMemo(
+ () =>
+ fitTextOnNLines({
+ text: 'microtext abcdefghijklmnopq',
+ maxLines: 2,
+ maxBoxWidth: BOX_WIDTH,
+ maxFontSize: 80,
+ fontFamily: 'Verdana',
+ fontWeight: '900',
+ textTransform: 'uppercase',
+ }),
+ [],
+ );
+
+ return (
+ <AbsoluteFill
+ style={{
+ backgroundColor: '#111',
+ justifyContent: 'center',
+ alignItems: 'center',
+ }}
+ >
+ <div
+ style={{
+ width: BOX_WIDTH,
+ outline: '2px solid #6f6',
+ color: '#fff',
+ fontFamily: 'Verdana, sans-serif',
+ fontWeight: 900,
+ textTransform: 'uppercase',
+ }}
+ >
+ {lines.map((line) => (
+ <div
+ key={line}
+ style={{
+ fontSize,
+ lineHeight: 1.25,
+ whiteSpace: 'pre',
+ }}
+ >
+ {line}
+ </div>
+ ))}
+ </div>
+ <div
+ style={{
+ position: 'absolute',
+ bottom: 40,
+ color: '#aaa',
+ fontFamily: 'monospace',
+ fontSize: 14,
+ }}
+ >
+ fontSize: {fontSize} · maxBoxWidth: {BOX_WIDTH}
+ </div>
+ </AbsoluteFill>
+ );
+};