🎥 Make videos programmatically with React
`@remotion/google-fonts`: Fix numbers in fontFamily name not working in Firefox
Jonny Burger6f851f6ab84a
diff --git a/packages/google-fonts/scripts/generate.ts b/packages/google-fonts/scripts/generate.tsindex 392ba19dab..e1725df39d 100644--- a/packages/google-fonts/scripts/generate.ts+++ b/packages/google-fonts/scripts/generate.ts@@ -12,7 +12,13 @@ type FontInfo = {fonts: Record<string, Record<string, Record<string, string>>>;};-import { getCssLink, unquote, quote, removeWhitespace } from "./utils";+import {+ getCssLink,+ unquote,+ quote,+ removeWhitespace,+ replaceDigitsWithWords,+} from "./utils";import { Font } from "./google-fonts";import { filteredFonts } from "./filtered-fonts";@@ -32,7 +38,7 @@ const generate = async (font: Font) => {// Read css from cache, otherwise from urllet css: null | string = null;- let fontFamily: null | string = unquote(font.family);+ let fontFamily: null | string = replaceDigitsWithWords(unquote(font.family));let cssFile = path.resolve(CSS_CACHE_DIR, cssname);if (!fs.existsSync(cssFile)) {// Get from url with user agent that support woff2diff --git a/packages/google-fonts/scripts/utils.ts b/packages/google-fonts/scripts/utils.tsindex b6746a345d..30d65a2757 100644--- a/packages/google-fonts/scripts/utils.ts+++ b/packages/google-fonts/scripts/utils.ts@@ -3,6 +3,23 @@ import { Font } from "./google-fonts";export const unquote = (str: string) =>str.replace(/^['"]/g, "").replace(/['"]$/g, "");+// Firefox does not support numbers in fontFamily+export const replaceDigitsWithWords = (str: string): string => {+ const numWords = [+ "Zero",+ "One",+ "Two",+ "Three",+ "Four",+ "Five",+ "Six",+ "Seven",+ "Eight",+ "Nine",+ ];+ return str.replace(/\d/g, (digit) => numWords[parseInt(digit)]);+};+export const quote = (str: string) => `'${str}'`;export const removeWhitespace = (str: string) => str.replace(/\s/g, "");