Skip to content

🎥 Make videos programmatically with React

Fixes #6178

Jonny Burgere65f444ad01d
diff --git a/packages/template-recorder/remotion/captions/boxed/components/AnimatedCaptions.tsx b/packages/template-recorder/remotion/captions/boxed/components/AnimatedCaptions.tsx
index 60eaa09088..563834eb23 100644
--- a/packages/template-recorder/remotion/captions/boxed/components/AnimatedCaptions.tsx
+++ b/packages/template-recorder/remotion/captions/boxed/components/AnimatedCaptions.tsx
@@ -22,7 +22,6 @@ import {
TransitionToNextSubtitles,
} from "./TransitionBetweenSubtitles";
-const LINE_HEIGHT = 2;
const SUBTITLES_FONT_SIZE = 56;
export const AnimatedCaptions: React.FC<{
@@ -79,7 +78,6 @@ export const AnimatedCaptions: React.FC<{
return {
fontSize: SUBTITLES_FONT_SIZE,
display: "flex",
- lineHeight: LINE_HEIGHT,
borderWidth: getBorderWidthForSubtitles(),
borderStyle: "solid",
borderColor: COLORS[theme].BORDER_COLOR,
diff --git a/packages/template-recorder/remotion/captions/boxed/components/SingleCaption.tsx b/packages/template-recorder/remotion/captions/boxed/components/SingleCaption.tsx
index 94d5ff717b..5da3075b96 100644
--- a/packages/template-recorder/remotion/captions/boxed/components/SingleCaption.tsx
+++ b/packages/template-recorder/remotion/captions/boxed/components/SingleCaption.tsx
@@ -14,6 +14,7 @@ import {
isCaptionMonospace,
removeMonospaceTicks,
} from "../../processing/split-caption-into-monospace-segments";
+import { isFirefox } from "../../../helpers/browsers";
type CaptionColor = {
appeared: string;
@@ -152,6 +153,8 @@ export const BoxedSingleCaption: React.FC<{
borderRadius: WORD_HIGHLIGHT_BORDER_RADIUS,
scale: String(progress),
cursor: "pointer",
+ // Chrome and Firefox do not interpret line-height the same, this makes it approximately equal
+ verticalAlign: isFirefox() ? "middle" : undefined,
};
}, [
active,
diff --git a/packages/template-recorder/remotion/helpers/browsers.ts b/packages/template-recorder/remotion/helpers/browsers.ts
new file mode 100644
index 0000000000..17ce5907a9
--- /dev/null
+++ b/packages/template-recorder/remotion/helpers/browsers.ts
@@ -0,0 +1,15 @@
+export const isFirefox = (): boolean => {
+ if (
+ typeof navigator === "undefined" ||
+ typeof navigator.userAgent !== "string"
+ ) {
+ return false;
+ }
+
+ // The userAgent contains 'Firefox' for Firefox browsers,
+ // and should NOT contain 'Seamonkey' (a related Mozilla suite)
+ return (
+ /firefox/i.test(navigator.userAgent) &&
+ !/seamonkey/i.test(navigator.userAgent)
+ );
+};