Skip to content

🎥 Make videos programmatically with React

`@remotion/studio`: Add inspector font family control (#8744)

Igor Samokhovets02b652394a07
diff --git a/packages/core/src/interactivity-schema.ts b/packages/core/src/interactivity-schema.ts
index 93c9cdd46c..9bb2c860c4 100644
--- a/packages/core/src/interactivity-schema.ts
+++ b/packages/core/src/interactivity-schema.ts
@@ -101,6 +101,13 @@ export type TextContentFieldSchema = {
keyframable?: false;
};
+export type FontFamilyFieldSchema = {
+ type: 'font-family';
+ default: string | undefined;
+ description?: string;
+ keyframable?: false;
+};
+
export type EnumFieldSchema = {
type: 'enum';
default: string;
@@ -181,6 +188,7 @@ export type VisibleFieldSchema =
| UvCoordinateFieldSchema
| ColorFieldSchema
| TextContentFieldSchema
+ | FontFamilyFieldSchema
| ArrayFieldSchema
| EnumFieldSchema;
@@ -236,6 +244,12 @@ export const textSchema = {
default: undefined,
description: 'Color',
},
+ 'style.fontFamily': {
+ type: 'font-family',
+ default: undefined,
+ description: 'Font family',
+ keyframable: false,
+ },
'style.fontSize': {
type: 'number',
default: undefined,
diff --git a/packages/core/src/test/with-interactivity-schema-helpers.test.ts b/packages/core/src/test/with-interactivity-schema-helpers.test.ts
index cde0bb0bd2..5da0385c89 100644
--- a/packages/core/src/test/with-interactivity-schema-helpers.test.ts
+++ b/packages/core/src/test/with-interactivity-schema-helpers.test.ts
@@ -115,6 +115,7 @@ test('textSchema exposes common text style fields', () => {
expect(Object.keys(textSchema).sort()).toEqual(
[
'style.color',
+ 'style.fontFamily',
'style.fontSize',
'style.fontStyle',
'style.fontWeight',
@@ -125,6 +126,11 @@ test('textSchema exposes common text style fields', () => {
);
expect(textSchema['style.color'].type).toBe('color');
expect(textSchema['style.color'].default).toBeUndefined();
+ expect(textSchema['style.fontFamily']).toMatchObject({
+ type: 'font-family',
+ default: undefined,
+ keyframable: false,
+ });
expect(textSchema['style.fontSize']).toMatchObject({
type: 'number',
default: undefined,
diff --git a/packages/docs/docs/interactive.mdx b/packages/docs/docs/interactive.mdx
index fe86febc80..fff9d68bb3 100644
--- a/packages/docs/docs/interactive.mdx
+++ b/packages/docs/docs/interactive.mdx
@@ -92,7 +92,9 @@ Use it for components that accept a `style` prop and apply it to the rendered el
Controls for text-related style props:
-`style.color`, `style.fontSize`, `style.lineHeight`, `style.fontWeight`, `style.fontStyle`, `style.textAlign` and `style.letterSpacing`.
+`style.color`, `style.fontFamily`, `style.fontSize`, `style.lineHeight`, `style.fontWeight`, `style.fontStyle`, `style.textAlign` and `style.letterSpacing`.
+
+`style.fontFamily` is available from <AvailableFrom v="4.0.486" inline />.
Use it for components that accept a `style` prop and render text.
diff --git a/packages/docs/docs/interactivity-schema.mdx b/packages/docs/docs/interactivity-schema.mdx
index c1c38aca97..e4afd55691 100644
--- a/packages/docs/docs/interactivity-schema.mdx
+++ b/packages/docs/docs/interactivity-schema.mdx
@@ -45,7 +45,9 @@ Transform-related style props: `style.transformOrigin`, `style.translate`, `styl
### `Interactive.textSchema`<AvailableFrom v="4.0.481" />
-Text-related style props: `style.color`, `style.fontSize`, `style.lineHeight`, `style.fontWeight`, `style.fontStyle`, `style.textAlign` and `style.letterSpacing`.
+Text-related style props: `style.color`, `style.fontFamily`, `style.fontSize`, `style.lineHeight`, `style.fontWeight`, `style.fontStyle`, `style.textAlign` and `style.letterSpacing`.
+
+`style.fontFamily` is available from <AvailableFrom v="4.0.486" inline />.
### `Interactive.premountSchema`
@@ -67,6 +69,12 @@ Shows an on/off control.
Shows a color control. The value is a CSS color string.
+### `font-family`<AvailableFrom v="4.0.485" />
+
+Shows a font family control. The value is a CSS font family string.
+
+When choosing a Google Font in Studio, Remotion adds the matching `loadFont()` call from `@remotion/google-fonts` to the composition file.
+
### `enum`
Shows a select control. Each variant can define its own nested `InteractivitySchema`.
@@ -193,7 +201,7 @@ Controls whether the field can be animated with keyframes.
Default: `true` for `number`, `boolean`, `rotation-css`, `rotation-degrees`, `translate`, `transform-origin`, `scale`, `uv-coordinate` and `color` fields.
-`array` and `enum` fields are not keyframable. Fields inside an `enum` variant schema can still be keyframed according to their own `keyframable` setting.
+`array`, `enum` and `font-family` fields are not keyframable. Fields inside an `enum` variant schema can still be keyframed according to their own `keyframable` setting.
Set `keyframable: false` on a keyframable field to show a static control.
diff --git a/packages/studio-server/src/codemods/update-sequence-props/update-sequence-props.ts b/packages/studio-server/src/codemods/update-sequence-props/update-sequence-props.ts
index 45838835ae..9b18ab722b 100644
--- a/packages/studio-server/src/codemods/update-sequence-props/update-sequence-props.ts
+++ b/packages/studio-server/src/codemods/update-sequence-props/update-sequence-props.ts
@@ -5,7 +5,11 @@ import type {
JSXFragment,
JSXSpreadAttribute,
StringLiteral,
+ Expression,
+ File,
+ Statement,
} from '@babel/types';
+import type {GoogleFontSourceEdit} from '@remotion/studio-shared';
import * as recast from 'recast';
import type {InteractivitySchema, SequenceNodePath} from 'remotion';
import {NoReactInternals} from 'remotion/no-react';
@@ -25,6 +29,7 @@ export type SequencePropUpdate = {
key: string;
value: unknown;
defaultValue: unknown | null;
+ googleFont?: GoogleFontSourceEdit | null;
};
export type RemovedProp = {
@@ -197,6 +202,537 @@ const updateJsxTextContent = ({
return staticTextContent.value;
};
+const collectTopLevelIdentifierNames = (ast: File): Set<string> => {
+ const names = new Set<string>();
+ recast.types.visit(ast, {
+ visitIdentifier(path) {
+ names.add(path.node.name);
+ this.traverse(path);
+ },
+ });
+
+ return names;
+};
+
+const toSafeIdentifier = (value: string) => {
+ const sanitized = value.replace(/[^a-zA-Z0-9_$]/g, '');
+ if (!sanitized) {
+ return 'loadGoogleFont';
+ }
+
+ return /^[a-zA-Z_$]/.test(sanitized) ? sanitized : `_${sanitized}`;
+};
+
+const getSafeLoadFontIdentifier = ({
+ font,
+ usedNames,
+}: {
+ font: GoogleFontSourceEdit;
+ usedNames: Set<string>;
+}) => {
+ const baseName = toSafeIdentifier(`load${font.importName}`);
+ if (!usedNames.has(baseName)) {
+ usedNames.add(baseName);
+ return baseName;
+ }
+
+ let index = 2;
+ while (usedNames.has(`${baseName}${index}`)) {
+ index++;
+ }
+
+ const name = `${baseName}${index}`;
+ usedNames.add(name);
+ return name;
+};
+
+const getImportedLoadFontIdentifier = ({
+ ast,
+ font,
+}: {
+ ast: File;
+ font: GoogleFontSourceEdit;
+}): string | null => {
+ const moduleName = `@remotion/google-fonts/${font.importName}`;
+ for (const statement of ast.program.body) {
+ if (
+ statement.type !== 'ImportDeclaration' ||
+ statement.source.value !== moduleName
+ ) {
+ continue;
+ }
+
+ for (const specifier of statement.specifiers ?? []) {
+ if (
+ specifier.type === 'ImportSpecifier' &&
+ specifier.imported.type === 'Identifier' &&
+ specifier.imported.name === 'loadFont'
+ ) {
+ return specifier.local?.name ?? 'loadFont';
+ }
+ }
+ }
+
+ return null;
+};
+
+const getInsertIndexAfterImportsOrDirectives = (ast: File) => {
+ const lastImportIndex = ast.program.body.reduce(
+ (lastIndex, statement, index) => {
+ return statement.type === 'ImportDeclaration' ? index : lastIndex;
+ },
+ -1,
+ );
+ if (lastImportIndex !== -1) {
+ return lastImportIndex + 1;
+ }
+
+ return ast.program.body.findIndex((statement) => {
+ return !(
+ statement.type === 'ExpressionStatement' &&
+ 'directive' in statement &&
+ statement.directive
+ );
+ });
+};
+
+const insertAfterImportsOrDirectives = (ast: File, statement: Statement) => {
+ const insertIndex = getInsertIndexAfterImportsOrDirectives(ast);
+ ast.program.body.splice(
+ insertIndex === -1 ? ast.program.body.length : insertIndex,
+ 0,
+ statement,
+ );
+};
+
+const ensureLoadFontImport = ({
+ ast,
+ font,
+ usedNames,
+}: {
+ ast: File;
+ font: GoogleFontSourceEdit;
+ usedNames: Set<string>;
+}) => {
+ const existing = getImportedLoadFontIdentifier({ast, font});
+ if (existing) {
+ return existing;
+ }
+
+ const moduleName = `@remotion/google-fonts/${font.importName}`;
+ const localName = getSafeLoadFontIdentifier({font, usedNames});
+ const specifier = b.importSpecifier(
+ b.identifier('loadFont'),
+ b.identifier(localName),
+ );
+
+ for (const statement of ast.program.body) {
+ if (
+ statement.type === 'ImportDeclaration' &&
+ statement.source.value === moduleName &&
+ !statement.specifiers?.some(
+ (existingSpecifier) =>
+ existingSpecifier.type === 'ImportNamespaceSpecifier',
+ )
+ ) {
+ statement.specifiers = [
+ ...(statement.specifiers ?? []),
+ specifier as never,
+ ];
+ return localName;
+ }
+ }
+
+ const declaration = b.importDeclaration(
+ [specifier as never],
+ b.stringLiteral(moduleName),
+ );
+ insertAfterImportsOrDirectives(ast, declaration as Statement);
+ return localName;
+};
+
+const getStringArrayObjectProperty = ({
+ node,
+ key,
+}: {
+ node: Expression;
+ key: string;
+}): string[] | null => {
+ if (node.type !== 'ObjectExpression') {
+ return null;
+ }
+
+ const property = node.properties.find((prop) => {
+ return (
+ prop.type === 'ObjectProperty' &&
+ prop.key.type === 'Identifier' &&
+ prop.key.name === key
+ );
+ });
+ if (!property || property.type !== 'ObjectProperty') {
+ return null;
+ }
+
+ if (property.value.type !== 'ArrayExpression') {
+ return null;
+ }
+
+ const values: string[] = [];
+ for (const element of property.value.elements) {
+ if (!element || element.type !== 'StringLiteral') {
+ return null;
+ }
+
+ values.push(element.value);
+ }
+
+ return values;
+};
+
+const arraysEqual = (a: readonly string[], bValues: readonly string[]) => {
+ return (
+ a.length === bValues.length &&
+ a.every((value, index) => value === bValues[index])
+ );
+};
+
+const isMatchingLoadFontCall = ({
+ statement,
+ localName,
+ font,
+}: {
+ statement: Statement;
+ localName: string;
+ font: GoogleFontSourceEdit;
+}) => {
+ if (
+ statement.type !== 'ExpressionStatement' ||
+ statement.expression.type !== 'CallExpression' ||
+ statement.expression.callee.type !== 'Identifier' ||
+ statement.expression.callee.name !== localName
+ ) {
+ return false;
+ }
+
+ const [style, options] = statement.expression.arguments;
+ if (style?.type !== 'StringLiteral' || style.value !== font.style) {
+ return false;
+ }
+
+ if (!options || options.type !== 'ObjectExpression') {
+ return false;
+ }
+
+ const weights = getStringArrayObjectProperty({node: options, key: 'weights'});
+ const subsets = getStringArrayObjectProperty({node: options, key: 'subsets'});
+
+ return (
+ weights !== null &&
+ subsets !== null &&
+ arraysEqual(weights, font.weights) &&
+ arraysEqual(subsets, font.subsets)
+ );
+};
+
+const hasTopLevelLoadFontCall = ({
+ ast,
+ localName,
+ font,
+}: {
+ ast: File;
+ localName: string;
+ font: GoogleFontSourceEdit;
+}) => {
+ return ast.program.body.some((statement) => {
+ return isMatchingLoadFontCall({statement, localName, font});
+ });
+};
+
+const getGoogleFontImportName = (moduleName: string) => {
+ const prefix = '@remotion/google-fonts/';
+ return moduleName.startsWith(prefix) ? moduleName.slice(prefix.length) : null;
+};
+
+const normalizeFontFamilyName = (fontFamily: string) => {
+ return fontFamily.toLowerCase().replace(/[^a-z0-9]/g, '');
+};
+
+const getPrimaryFontFamilyName = (fontFamily: string) => {
+ const trimmed = fontFamily.trim();
+ if (!trimmed) {
+ return null;
+ }
+
+ const quote = trimmed[0];
+ if (quote === '"' || quote === "'") {
+ const closingQuote = trimmed.indexOf(quote, 1);
+ return closingQuote === -1
+ ? trimmed.slice(1)
+ : trimmed.slice(1, closingQuote);
+ }
+
+ return trimmed.split(',')[0].trim();
+};
+
+const collectUsedFontFamilyNames = (ast: File): Set<string> => {
+ const used = new Set<string>();
+ const add = (fontFamily: string) => {
+ const primary = getPrimaryFontFamilyName(fontFamily);
+ if (primary) {
+ used.add(normalizeFontFamilyName(primary));
+ }
+ };
+
+ recast.types.visit(ast, {
+ visitObjectProperty(path) {
+ const {node} = path;
+ if (node.key.type === 'Identifier' && node.key.name === 'fontFamily') {
+ if (node.value.type === 'StringLiteral') {
+ add(node.value.value);
+ }
+
+ if (
+ node.value.type === 'TemplateLiteral' &&
+ node.value.expressions.length === 0 &&
+ node.value.quasis.length === 1
+ ) {
+ add(
+ node.value.quasis[0].value.cooked ?? node.value.quasis[0].value.raw,
+ );
+ }
+ }
+
+ this.traverse(path);
+ },
+ visitJSXAttribute(path) {
+ const {node} = path;
+ if (
+ node.name.type === 'JSXIdentifier' &&
+ node.name.name === 'fontFamily' &&
+ node.value?.type === 'StringLiteral'
+ ) {
+ add(node.value.value);
+ }
+
+ this.traverse(path);
+ },
+ });
+
+ return used;
+};
+
+const isIdentifierImportedBySpecifier = ({
+ parent,
+ name,
+}: {
+ parent: unknown;
+ name: string;
+}) => {
+ return (
+ parent !== null &&
+ typeof parent === 'object' &&
+ 'type' in parent &&
+ parent.type === 'ImportSpecifier' &&
+ 'local' in parent &&
+ parent.local !== null &&
+ typeof parent.local === 'object' &&
+ 'type' in parent.local &&
+ parent.local.type === 'Identifier' &&
+ 'name' in parent.local &&
+ parent.local.name === name
+ );
+};
+
+const hasNonImportIdentifierReference = ({
+ ast,
+ name,
+}: {
+ ast: File;
+ name: string;
+}) => {
+ let hasReference = false;
+ recast.types.visit(ast, {
+ visitIdentifier(path) {
+ if (path.node.name !== name) {
+ this.traverse(path);
+ return;
+ }
+
+ if (isIdentifierImportedBySpecifier({parent: path.parent.node, name})) {
+ this.traverse(path);
+ return;
+ }
+
+ hasReference = true;
+ return false;
+ },
+ });
+
+ return hasReference;
+};
+
+const googleFontLoadingComment =
+ 'Remotion Studio generated Google Font loading';
+
+const hasStudioGeneratedGoogleFontLoadingComment = (statement: Statement) => {
+ return (statement.leadingComments ?? []).some((comment) =>
+ comment.value.includes(googleFontLoadingComment),
+ );
+};
+
+const isTopLevelCallToIdentifier = ({
+ statement,
+ localName,
+}: {
+ statement: Statement;
+ localName: string;
+}) => {
+ return (
+ statement.type === 'ExpressionStatement' &&
+ statement.expression.type === 'CallExpression' &&
+ statement.expression.callee.type === 'Identifier' &&
+ statement.expression.callee.name === localName
+ );
+};
+
+const removeUnusedGoogleFontSourceEdits = (ast: File) => {
+ const usedFonts = collectUsedFontFamilyNames(ast);
+ const loadFontLocalNamesToRemove = new Set<string>();
+
+ for (const statement of ast.program.body) {
+ if (
+ statement.type !== 'ImportDeclaration' ||
+ typeof statement.source.value !== 'string'
+ ) {
+ continue;
+ }
+
+ const importName = getGoogleFontImportName(statement.source.value);
+ if (!importName) {
+ continue;
+ }
+
+ if (usedFonts.has(normalizeFontFamilyName(importName))) {
+ continue;
+ }
+
+ for (const specifier of statement.specifiers ?? []) {
+ if (
+ specifier.type === 'ImportSpecifier' &&
+ specifier.imported.type === 'Identifier' &&
+ specifier.imported.name === 'loadFont'
+ ) {
+ loadFontLocalNamesToRemove.add(specifier.local?.name ?? 'loadFont');
+ }
+ }
+ }
+
+ if (loadFontLocalNamesToRemove.size === 0) {
+ return;
+ }
+
+ ast.program.body = ast.program.body.filter((statement) => {
+ for (const localName of loadFontLocalNamesToRemove) {
+ if (
+ isTopLevelCallToIdentifier({statement, localName}) &&
+ hasStudioGeneratedGoogleFontLoadingComment(statement)
+ ) {
+ return false;
+ }
+ }
+
+ return true;
+ });
+
+ ast.program.body = ast.program.body.filter((statement) => {
+ if (statement.type !== 'ImportDeclaration') {
+ return true;
+ }
+
+ statement.specifiers = (statement.specifiers ?? []).filter((specifier) => {
+ return !(
+ specifier.type === 'ImportSpecifier' &&
+ specifier.imported.type === 'Identifier' &&
+ specifier.imported.name === 'loadFont' &&
+ loadFontLocalNamesToRemove.has(specifier.local?.name ?? 'loadFont') &&
+ !hasNonImportIdentifierReference({
+ ast,
+ name: specifier.local?.name ?? 'loadFont',
+ })
+ );
+ });
+
+ return statement.specifiers.length > 0;
+ });
+};
+
+const insertLoadFontCall = ({
+ ast,
+ font,
+ localName,
+}: {
+ ast: File;
+ font: GoogleFontSourceEdit;
+ localName: string;
+}) => {
+ if (hasTopLevelLoadFontCall({ast, localName, font})) {
+ return;
+ }
+
+ const call = b.expressionStatement(
+ b.callExpression(b.identifier(localName), [
+ b.stringLiteral(font.style),
+ b.objectExpression([
+ b.objectProperty(
+ b.identifier('weights'),
+ b.arrayExpression(
+ font.weights.map((weight) => b.stringLiteral(weight)),
+ ),
+ ),
+ b.objectProperty(
+ b.identifier('subsets'),
+ b.arrayExpression(
+ font.subsets.map((subset) => b.stringLiteral(subset)),
+ ),
+ ),
+ ]),
+ ]),
+ );
+ call.comments = [b.commentLine(` ${googleFontLoadingComment}`)];
+
+ insertAfterImportsOrDirectives(ast, call as Statement);
+};
+
+const applyGoogleFontSourceEdits = ({
+ ast,
+ updates,
+}: {
+ ast: File;
+ updates: SequencePropUpdate[];
+}) => {
+ const fonts = new Map<string, GoogleFontSourceEdit>();
+ let hasFontFamilyUpdate = false;
+ for (const update of updates) {
+ if (update.key === 'style.fontFamily') {
+ hasFontFamilyUpdate = true;
+ }
+
+ if (update.googleFont) {
+ fonts.set(update.googleFont.importName, update.googleFont);
+ }
+ }
+
+ const usedNames = collectTopLevelIdentifierNames(ast);
+ for (const font of fonts.values()) {
+ const localName = ensureLoadFontImport({ast, font, usedNames});
+ insertLoadFontCall({ast, font, localName});
+ }
+
+ if (hasFontFamilyUpdate) {
+ removeUnusedGoogleFontSourceEdits(ast);
+ }
+};
+
const updateSequencePropsNode = ({
jsxElement,
updates,
@@ -232,8 +768,9 @@ const updateSequencePropsNode = ({
}
const isDefault =
- defaultValue !== null &&
- JSON.stringify(value) === JSON.stringify(defaultValue);
+ (defaultValue === null && value === undefined) ||
+ (defaultValue !== null &&
+ JSON.stringify(value) === JSON.stringify(defaultValue));
const dotIndex = key.indexOf('.');
const isNested = dotIndex !== -1;
@@ -381,6 +918,7 @@ export const updateSequencePropsAst = ({
updates,
schema,
});
+ applyGoogleFontSourceEdits({ast, updates});
return {
serialized: serializeAst(ast),
@@ -400,6 +938,7 @@ export const updateMultipleSequenceProps = async ({
prettierConfigOverride: PrettierConfigOverride;
}): Promise<UpdateMultipleSequencePropsResult> => {
const ast = parseAst(input);
+ const allUpdates: SequencePropUpdate[] = [];
const results = changes.map(({nodePath, updates, schema}) => {
const jsxElement = findJsxElementNodeAtNodePath(ast, nodePath);
if (!jsxElement) {
@@ -408,8 +947,10 @@ export const updateMultipleSequenceProps = async ({
);
}
+ allUpdates.push(...updates);
return updateSequencePropsNode({jsxElement, updates, schema});
});
+ applyGoogleFontSourceEdits({ast, updates: allUpdates});
const {output, formatted} = await formatFileContent({
input: serializeAst(ast),
diff --git a/packages/studio-server/src/helpers/import-agnostic-node-path.ts b/packages/studio-server/src/helpers/import-agnostic-node-path.ts
index 25cf0aa21a..5200e7dab4 100644
--- a/packages/studio-server/src/helpers/import-agnostic-node-path.ts
+++ b/packages/studio-server/src/helpers/import-agnostic-node-path.ts
@@ -90,6 +90,31 @@ const getUseCurrentFrameLocalNames = (ast: File): Set<string> => {
return names;
};
+const getGoogleFontLoadFontLocalNames = (ast: File): Set<string> => {
+ const names = new Set<string>();
+ for (const statement of ast.program.body) {
+ if (
+ statement.type !== 'ImportDeclaration' ||
+ typeof statement.source.value !== 'string' ||
+ !statement.source.value.startsWith('@remotion/google-fonts/')
+ ) {
+ continue;
+ }
+
+ for (const specifier of statement.specifiers) {
+ if (
+ specifier.type === 'ImportSpecifier' &&
+ specifier.imported.type === 'Identifier' &&
+ specifier.imported.name === 'loadFont'
+ ) {
+ names.add(specifier.local?.name ?? 'loadFont');
+ }
+ }
+ }
+
+ return names;
+};
+
const isUseCurrentFrameCall = (
node: Node | null | undefined,
useCurrentFrameLocalNames: ReadonlySet<string>,
@@ -119,15 +144,27 @@ const isUseCurrentFrameStatement = (
);
};
+const isGoogleFontLoadFontStatement = (
+ node: Node,
+ googleFontLoadFontLocalNames: ReadonlySet<string>,
+): boolean => {
+ return (
+ node.type === 'ExpressionStatement' &&
+ node.expression.type === 'CallExpression' &&
+ node.expression.callee.type === 'Identifier' &&
+ googleFontLoadFontLocalNames.has(node.expression.callee.name)
+ );
+};
+
const getIgnoredNodePredicate = (ast: File): IgnoredNodePredicate => {
const useCurrentFrameLocalNames = getUseCurrentFrameLocalNames(ast);
+ const googleFontLoadFontLocalNames = getGoogleFontLoadFontLocalNames(ast);
return (node, {parent, property}) => {
- if (
- parent.type === 'Program' &&
- property === 'body' &&
- node.type === 'ImportDeclaration'
- ) {
- return true;
+ if (parent.type === 'Program' && property === 'body') {
+ return (
+ node.type === 'ImportDeclaration' ||
+ isGoogleFontLoadFontStatement(node, googleFontLoadFontLocalNames)
+ );
}
if (parent.type === 'BlockStatement' && property === 'body') {
diff --git a/packages/studio-server/src/preview-server/routes/save-sequence-props.ts b/packages/studio-server/src/preview-server/routes/save-sequence-props.ts
index ac8e86e026..07858277b5 100644
--- a/packages/studio-server/src/preview-server/routes/save-sequence-props.ts
+++ b/packages/studio-server/src/preview-server/routes/save-sequence-props.ts
@@ -35,6 +35,7 @@ type ResolvedSequencePropEdit = {
defaultValue: unknown | null;
defaultValueString: string | null;
schema: SaveSequencePropEdit['schema'];
+ sourceEdit: SaveSequencePropEdit['sourceEdit'];
};
type SequencePropEditGroup = {
@@ -42,6 +43,24 @@ type SequencePropEditGroup = {
edits: ResolvedSequencePropEdit[];
};
+const parseSequencePropEditValue = (
+ value: SaveSequencePropEdit['value'],
+): unknown => {
+ if (value.type === 'undefined') {
+ return undefined;
+ }
+
+ return JSON.parse(value.serialized);
+};
+
+const stringifySequencePropEditValue = (value: unknown): string => {
+ if (value === undefined) {
+ return 'undefined';
+ }
+
+ return JSON.stringify(value);
+};
+
type SequencePropUndoSnapshot = {
filePath: string;
oldContents: string;
@@ -59,7 +78,7 @@ type SequencePropEditResult = {
export const convertSequencePropEditToCodemodChange = (
edit: Pick<
ResolvedSequencePropEdit,
- 'nodePath' | 'key' | 'value' | 'defaultValue' | 'schema'
+ 'nodePath' | 'key' | 'value' | 'defaultValue' | 'schema' | 'sourceEdit'
>,
): SequencePropsNodeUpdate => {
return {
@@ -69,6 +88,8 @@ export const convertSequencePropEditToCodemodChange = (
key: edit.key,
value: edit.value,
defaultValue: edit.defaultValue,
+ googleFont:
+ edit.sourceEdit?.type === 'google-font' ? edit.sourceEdit.font : null,
},
],
schema: edit.schema,
@@ -76,9 +97,16 @@ export const convertSequencePropEditToCodemodChange = (
};
export const shouldSuppressHmrForSequencePropEdits = (
- edits: readonly {key: string}[],
+ edits: readonly {
+ key: string;
+ sourceEdit?: SaveSequencePropEdit['sourceEdit'];
+ }[],
): boolean => {
- return edits.every((edit) => edit.key !== 'showInTimeline');
+ return edits.every(
+ (edit) =>
+ edit.key !== 'showInTimeline' &&
+ (edit.sourceEdit === null || edit.sourceEdit === undefined),
+ );
};
export const saveSequencePropsHandler: ApiHandler<
@@ -102,7 +130,7 @@ export const saveSequencePropsHandler: ApiHandler<
const editGroups = new Map<string, SequencePropEditGroup>();
for (const [index, edit] of edits.entries()) {
- const parsedValue = JSON.parse(edit.value);
+ const parsedValue = parseSequencePropEditValue(edit.value);
const parsedDefaultValue =
edit.defaultValue !== null ? JSON.parse(edit.defaultValue) : null;
const {absolutePath, fileRelativeToRoot} = resolveFileInsideProject({
@@ -121,13 +149,14 @@ export const saveSequencePropsHandler: ApiHandler<
nodePath: edit.nodePath,
key: edit.key,
value: parsedValue,
- valueString: JSON.stringify(parsedValue),
+ valueString: stringifySequencePropEditValue(parsedValue),
defaultValue: parsedDefaultValue,
defaultValueString:
parsedDefaultValue !== null
? JSON.stringify(parsedDefaultValue)
: null,
schema: edit.schema,
+ sourceEdit: edit.sourceEdit,
});
editGroups.set(absolutePath, group);
}
diff --git a/packages/studio-server/src/test/save-sequence-props.test.ts b/packages/studio-server/src/test/save-sequence-props.test.ts
index fc8a3870cd..479f419f19 100644
--- a/packages/studio-server/src/test/save-sequence-props.test.ts
+++ b/packages/studio-server/src/test/save-sequence-props.test.ts
@@ -32,6 +32,26 @@ test('saveSequenceProps does not suppress HMR for showInTimeline edits', () => {
).toBe(false);
});
+test('saveSequenceProps does not suppress HMR for Google Font source edits', () => {
+ expect(
+ shouldSuppressHmrForSequencePropEdits([
+ {
+ key: 'style.fontFamily',
+ sourceEdit: {
+ type: 'google-font',
+ font: {
+ fontFamily: 'Roboto',
+ importName: 'Roboto',
+ style: 'normal',
+ weights: ['400', '700', '800'],
+ subsets: ['latin'],
+ },
+ },
+ },
+ ]),
+ ).toBe(false);
+});
+
test('saveSequenceProps forwards element schemas to the codemod', () => {
const change = convertSequencePropEditToCodemodChange({
nodePath: {
@@ -44,6 +64,7 @@ test('saveSequenceProps forwards element schemas to the codemod', () => {
value: 7,
defaultValue: 5,
schema: starSchema,
+ sourceEdit: null,
});
expect(change).toEqual({
@@ -53,6 +74,7 @@ test('saveSequenceProps forwards element schemas to the codemod', () => {
key: 'points',
value: 7,
defaultValue: 5,
+ googleFont: null,
},
],
schema: starSchema,
diff --git a/packages/studio-server/src/test/update-nested-sequence-props.test.ts b/packages/studio-server/src/test/update-nested-sequence-props.test.ts
index 2075e71d96..024a7ea2a5 100644
--- a/packages/studio-server/src/test/update-nested-sequence-props.test.ts
+++ b/packages/studio-server/src/test/update-nested-sequence-props.test.ts
@@ -113,3 +113,396 @@ test('updateSequenceProps should report default as oldValueString for missing ne
expect(oldValueString).toBe('1');
});
+
+test('updateSequenceProps should insert Google Font source loading code', async () => {
+ const {output, oldValueStrings} = await updateSequenceProps({
+ input: nestedInput,
+ nodePath: lineColumnToNodePath(nestedInput, 7),
+ updates: [
+ {
+ key: 'style.fontFamily',
+ value: 'Roboto',
+ defaultValue: null,
+ googleFont: {
+ fontFamily: 'Roboto',
+ importName: 'Roboto',
+ style: 'normal',
+ weights: ['400', '700', '800'],
+ subsets: ['latin'],
+ },
+ },
+ ],
+ schema: NoReactInternals.sequenceSchema,
+ prettierConfigOverride: null,
+ });
+
+ expect(oldValueStrings[0]).toBe('');
+ expect(output).toContain(
+ "import {loadFont as loadRoboto} from '@remotion/google-fonts/Roboto';",
+ );
+ expect(output).toContain("loadRoboto('normal', {");
+ expect(output).toContain("weights: ['400', '700', '800']");
+ expect(output).toContain("subsets: ['latin']");
+ expect(output).toContain("fontFamily: 'Roboto'");
+});
+
+test('updateSequenceProps should add a separate import if Google Font namespace import exists', async () => {
+ const input = `import React from 'react';
+import {AbsoluteFill} from 'remotion';
+import * as Roboto from '@remotion/google-fonts/Roboto';
+
+export const Example: React.FC = () => {
+ return (
+ <AbsoluteFill>
+ <div />
+ </AbsoluteFill>
+ );
+};
+`;
+ const {output} = await updateSequenceProps({
+ input,
+ nodePath: lineColumnToNodePath(input, 8),
+ updates: [
+ {
+ key: 'style.fontFamily',
+ value: 'Roboto',
+ defaultValue: null,
+ googleFont: {
+ fontFamily: 'Roboto',
+ importName: 'Roboto',
+ style: 'normal',
+ weights: ['400', '700', '800'],
+ subsets: ['latin'],
+ },
+ },
+ ],
+ schema: NoReactInternals.sequenceSchema,
+ prettierConfigOverride: null,
+ });
+
+ expect(output).toContain(
+ "import * as Roboto from '@remotion/google-fonts/Roboto';",
+ );
+ expect(output).toContain(
+ "import {loadFont as loadRoboto} from '@remotion/google-fonts/Roboto';",
+ );
+ expect(output).toContain("loadRoboto('normal', {");
+});
+
+test('updateSequenceProps should reuse existing Google Font import and call', async () => {
+ const input = `import React from 'react';
+import {AbsoluteFill} from 'remotion';
+import {loadFont} from '@remotion/google-fonts/Roboto';
+
+loadFont('normal', {
+ weights: ['400', '700', '800'],
+ subsets: ['latin'],
+});
+
+export const Example: React.FC = () => {
+ return (
+ <AbsoluteFill>
+ <div />
+ </AbsoluteFill>
+ );
+};
+`;
+ const {output} = await updateSequenceProps({
+ input,
+ nodePath: lineColumnToNodePath(input, 12),
+ updates: [
+ {
+ key: 'style.fontFamily',
+ value: 'Roboto',
+ defaultValue: null,
+ googleFont: {
+ fontFamily: 'Roboto',
+ importName: 'Roboto',
+ style: 'normal',
+ weights: ['400', '700', '800'],
+ subsets: ['latin'],
+ },
+ },
+ ],
+ schema: NoReactInternals.sequenceSchema,
+ prettierConfigOverride: null,
+ });
+
+ expect(output.match(/from '@remotion\/google-fonts\/Roboto'/g)?.length).toBe(
+ 1,
+ );
+ expect(output.match(/loadFont\('normal'/g)?.length).toBe(1);
+ expect(output).toContain("fontFamily: 'Roboto'");
+});
+
+test('updateSequenceProps should insert matching load call if existing call has different arguments', async () => {
+ const input = `import React from 'react';
+import {AbsoluteFill} from 'remotion';
+import {loadFont} from '@remotion/google-fonts/Roboto';
+
+loadFont('italic', {
+ weights: ['400'],
+ subsets: ['latin'],
+});
+
+export const Example: React.FC = () => {
+ return (
+ <AbsoluteFill>
+ <div />
+ </AbsoluteFill>
+ );
+};
+`;
+ const {output} = await updateSequenceProps({
+ input,
+ nodePath: lineColumnToNodePath(input, 13),
+ updates: [
+ {
+ key: 'style.fontFamily',
+ value: 'Roboto',
+ defaultValue: null,
+ googleFont: {
+ fontFamily: 'Roboto',
+ importName: 'Roboto',
+ style: 'normal',
+ weights: ['400', '700', '800'],
+ subsets: ['latin'],
+ },
+ },
+ ],
+ schema: NoReactInternals.sequenceSchema,
+ prettierConfigOverride: null,
+ });
+
+ expect(output.match(/loadFont\('/g)?.length).toBe(2);
+ expect(output).toContain("loadFont('italic', {");
+ expect(output).toContain("loadFont('normal', {");
+ expect(output).toContain("weights: ['400', '700', '800']");
+});
+
+test('updateSequenceProps should keep node paths stable after inserting Google Font loading code', async () => {
+ const nodePath = lineColumnToNodePath(nestedInput, 7);
+ const first = await updateSequenceProps({
+ input: nestedInput,
+ nodePath,
+ updates: [
+ {
+ key: 'style.fontFamily',
+ value: 'Roboto',
+ defaultValue: null,
+ googleFont: {
+ fontFamily: 'Roboto',
+ importName: 'Roboto',
+ style: 'normal',
+ weights: ['400', '700', '800'],
+ subsets: ['latin'],
+ },
+ },
+ ],
+ schema: NoReactInternals.sequenceSchema,
+ prettierConfigOverride: null,
+ });
+
+ const second = await updateSequenceProps({
+ input: first.output,
+ nodePath,
+ updates: [
+ {
+ key: 'style.fontFamily',
+ value: 'Ubuntu',
+ defaultValue: null,
+ googleFont: {
+ fontFamily: 'Ubuntu',
+ importName: 'Ubuntu',
+ style: 'normal',
+ weights: ['400', '700'],
+ subsets: ['latin'],
+ },
+ },
+ ],
+ schema: NoReactInternals.sequenceSchema,
+ prettierConfigOverride: null,
+ });
+
+ expect(second.oldValueStrings[0]).toBe("'Roboto'");
+ expect(second.output).toContain("fontFamily: 'Ubuntu'");
+ expect(second.output).toContain(
+ "import {loadFont as loadUbuntu} from '@remotion/google-fonts/Ubuntu';",
+ );
+ expect(second.output).not.toContain('@remotion/google-fonts/Roboto');
+ expect(second.output).not.toContain('loadRoboto(');
+});
+
+test('updateSequenceProps should clear a nested prop with an undefined default', async () => {
+ const input = `import React from 'react';
+import {AbsoluteFill} from 'remotion';
+
+export const Example: React.FC = () => {
+ return (
+ <AbsoluteFill>
+ <div style={{fontFamily: 'Roboto', color: 'red'}} />
+ </AbsoluteFill>
+ );
+};
+`;
+
+ const {output, oldValueStrings} = await updateSequenceProps({
+ input,
+ nodePath: lineColumnToNodePath(input, 7),
+ updates: [
+ {
+ key: 'style.fontFamily',
+ value: undefined,
+ defaultValue: null,
+ },
+ ],
+ schema: NoReactInternals.sequenceSchema,
+ prettierConfigOverride: null,
+ });
+
+ expect(oldValueStrings[0]).toBe("'Roboto'");
+ expect(output).not.toContain('fontFamily');
+ expect(output).toContain("color: 'red'");
+});
+
+test('updateSequenceProps should preserve user-authored Google Font loading code when usage is dynamic', async () => {
+ const input = `import React from 'react';
+import {AbsoluteFill} from 'remotion';
+import {loadFont as loadRoboto} from '@remotion/google-fonts/Roboto';
+
+loadRoboto('normal', {
+ weights: ['400', '700', '800'],
+ subsets: ['latin'],
+});
+
+const titleFont = 'Roboto';
+const titleStyle: React.CSSProperties = {
+ fontFamily: titleFont,
+};
+
+export const Example: React.FC = () => {
+ return (
+ <AbsoluteFill>
+ <div style={titleStyle} />
+ <div style={{fontFamily: 'Roboto'}} />
+ </AbsoluteFill>
+ );
+};
+`;
+
+ const {output} = await updateSequenceProps({
+ input,
+ nodePath: lineColumnToNodePath(input, 18),
+ updates: [
+ {
+ key: 'style.fontFamily',
+ value: 'Ubuntu',
+ defaultValue: null,
+ googleFont: {
+ fontFamily: 'Ubuntu',
+ importName: 'Ubuntu',
+ style: 'normal',
+ weights: ['400', '700'],
+ subsets: ['latin'],
+ },
+ },
+ ],
+ schema: NoReactInternals.sequenceSchema,
+ prettierConfigOverride: null,
+ });
+
+ expect(output).toContain('@remotion/google-fonts/Roboto');
+ expect(output).toContain('loadRoboto(');
+ expect(output).toContain('style={titleStyle}');
+ expect(output).toContain('@remotion/google-fonts/Ubuntu');
+ expect(output).toContain('loadUbuntu(');
+});
+
+test('updateSequenceProps should keep Google Font loading code if the font is still used', async () => {
+ const input = `import React from 'react';
+import {AbsoluteFill} from 'remotion';
+import {loadFont as loadRoboto} from '@remotion/google-fonts/Roboto';
+
+loadRoboto('normal', {
+ weights: ['400', '700', '800'],
+ subsets: ['latin'],
+});
+
+export const Example: React.FC = () => {
+ return (
+ <AbsoluteFill>
+ <div style={{fontFamily: 'Roboto'}} />
+ <div style={{fontFamily: 'Roboto'}} />
+ </AbsoluteFill>
+ );
+};
+`;
+
+ const {output} = await updateSequenceProps({
+ input,
+ nodePath: lineColumnToNodePath(input, 14),
+ updates: [
+ {
+ key: 'style.fontFamily',
+ value: 'Ubuntu',
+ defaultValue: null,
+ googleFont: {
+ fontFamily: 'Ubuntu',
+ importName: 'Ubuntu',
+ style: 'normal',
+ weights: ['400', '700'],
+ subsets: ['latin'],
+ },
+ },
+ ],
+ schema: NoReactInternals.sequenceSchema,
+ prettierConfigOverride: null,
+ });
+
+ expect(output).toContain('@remotion/google-fonts/Roboto');
+ expect(output).toContain('loadRoboto(');
+ expect(output).toContain('@remotion/google-fonts/Ubuntu');
+ expect(output).toContain('loadUbuntu(');
+});
+
+test('updateSequenceProps should avoid Google Font import alias collisions', async () => {
+ const input = `import React from 'react';
+import {AbsoluteFill} from 'remotion';
+
+const loadRoboto = () => null;
+
+export const Example: React.FC = () => {
+ return (
+ <AbsoluteFill>
+ <div />
+ </AbsoluteFill>
+ );
+};
+`;
+ const {output} = await updateSequenceProps({
+ input,
+ nodePath: lineColumnToNodePath(input, 9),
+ updates: [
+ {
+ key: 'style.fontFamily',
+ value: 'Roboto',
+ defaultValue: null,
+ googleFont: {
+ fontFamily: 'Roboto',
+ importName: 'Roboto',
+ style: 'normal',
+ weights: ['400', '700', '800'],
+ subsets: ['latin'],
+ },
+ },
+ ],
+ schema: NoReactInternals.sequenceSchema,
+ prettierConfigOverride: null,
+ });
+
+ expect(output).toContain(
+ "import {loadFont as loadRoboto2} from '@remotion/google-fonts/Roboto';",
+ );
+ expect(output).toContain("loadRoboto2('normal', {");
+ expect(output).toContain('const loadRoboto = () => null;');
+});
diff --git a/packages/studio-shared/src/api-requests.ts b/packages/studio-shared/src/api-requests.ts
index 9b199c3bff..595aeb525c 100644
--- a/packages/studio-shared/src/api-requests.ts
+++ b/packages/studio-shared/src/api-requests.ts
@@ -298,13 +298,34 @@ export type UnsubscribeFromSequencePropsRequest = {
effectKeys: string[][];
};
+export type GoogleFontSourceEdit = {
+ fontFamily: string;
+ importName: string;
+ style: string;
+ weights: string[];
+ subsets: string[];
+};
+
+export type SaveSequencePropSourceEdit = {
+ type: 'google-font';
+ font: GoogleFontSourceEdit;
+};
+
export type SaveSequencePropEdit = {
fileName: string;
nodePath: SequencePropsSubscriptionKey;
key: string;
- value: string;
+ value:
+ | {
+ type: 'json';
+ serialized: string;
+ }
+ | {
+ type: 'undefined';
+ };
defaultValue: string | null;
schema: InteractivitySchema;
+ sourceEdit: SaveSequencePropSourceEdit | null;
};
export type SaveSequencePropsRequest = {
diff --git a/packages/studio-shared/src/index.ts b/packages/studio-shared/src/index.ts
index 37878fe4d2..86edf2d051 100644
--- a/packages/studio-shared/src/index.ts
+++ b/packages/studio-shared/src/index.ts
@@ -73,6 +73,8 @@ export {
ReorderSequenceResponse,
RestartStudioRequest,
RestartStudioResponse,
+ GoogleFontSourceEdit,
+ SaveSequencePropSourceEdit,
SaveEffectPropsRequest,
SaveEffectPropsResponse,
SaveSequencePropEdit,
diff --git a/packages/studio-shared/src/keyframe-interpolation-function.ts b/packages/studio-shared/src/keyframe-interpolation-function.ts
index 4492d647df..209f433712 100644
--- a/packages/studio-shared/src/keyframe-interpolation-function.ts
+++ b/packages/studio-shared/src/keyframe-interpolation-function.ts
@@ -26,7 +26,8 @@ export const isInteractivitySchemaFieldKeyframable = (
if (
field.type === 'array' ||
field.type === 'boolean' ||
- field.type === 'enum'
+ field.type === 'enum' ||
+ field.type === 'font-family'
) {
return false;
}
diff --git a/packages/studio-shared/src/schema-field-info.ts b/packages/studio-shared/src/schema-field-info.ts
index d151d8b4d9..2e0ef593d8 100644
--- a/packages/studio-shared/src/schema-field-info.ts
+++ b/packages/studio-shared/src/schema-field-info.ts
@@ -72,6 +72,7 @@ const TRANSFORM_FIELD_KEYS = new Set([
const TEXT_FIELD_KEYS = new Set([
'children',
'style.color',
+ 'style.fontFamily',
'style.fontSize',
'style.lineHeight',
'style.fontWeight',
@@ -115,6 +116,7 @@ const SUPPORTED_SCHEMA_TYPES = [
'uv-coordinate',
'color',
'text-content',
+ 'font-family',
'array',
'enum',
'hidden',
diff --git a/packages/studio-shared/src/test/keyframe-interpolation-function.test.ts b/packages/studio-shared/src/test/keyframe-interpolation-function.test.ts
index 88f5782f5b..c5b5b78812 100644
--- a/packages/studio-shared/src/test/keyframe-interpolation-function.test.ts
+++ b/packages/studio-shared/src/test/keyframe-interpolation-function.test.ts
@@ -45,6 +45,20 @@ test('isSchemaFieldKeyframable rejects boolean fields', () => {
expect(isSchemaFieldKeyframable({schema, key: 'loop'})).toBe(false);
});
+test('isSchemaFieldKeyframable rejects font-family fields', () => {
+ const schema = {
+ 'style.fontFamily': {
+ type: 'font-family',
+ default: undefined,
+ keyframable: false,
+ },
+ } satisfies InteractivitySchema;
+
+ expect(isSchemaFieldKeyframable({schema, key: 'style.fontFamily'})).toBe(
+ false,
+ );
+});
+
test('isSchemaFieldKeyframable rejects boolean fields in enum variants', () => {
const schema = {
layout: {
diff --git a/packages/studio-shared/src/test/schema-field-info.test.ts b/packages/studio-shared/src/test/schema-field-info.test.ts
index fe8e4e9fc2..2095ab7b90 100644
--- a/packages/studio-shared/src/test/schema-field-info.test.ts
+++ b/packages/studio-shared/src/test/schema-field-info.test.ts
@@ -179,6 +179,11 @@ test('getFieldsToShow sorts fields by inspector group order', () => {
type: 'color',
default: undefined,
},
+ 'style.fontFamily': {
+ type: 'font-family',
+ default: undefined,
+ keyframable: false,
+ },
'style.rotate': {
type: 'rotation-css',
default: '0deg',
@@ -221,6 +226,7 @@ test('getFieldsToShow sorts fields by inspector group order', () => {
'style.opacity',
'style.fontSize',
'style.color',
+ 'style.fontFamily',
'style.letterSpacing',
'style.textAlign',
]);
@@ -234,6 +240,7 @@ test('getFieldsToShow sorts fields by inspector group order', () => {
'text',
'text',
'text',
+ 'text',
]);
});
diff --git a/packages/studio/scripts/generate-google-font-info.ts b/packages/studio/scripts/generate-google-font-info.ts
new file mode 100644
index 0000000000..918963ec32
--- /dev/null
+++ b/packages/studio/scripts/generate-google-font-info.ts
@@ -0,0 +1,317 @@
+// Execute with `bun packages/studio/scripts/generate-google-font-info.ts`
+
+import {execSync} from 'child_process';
+import {writeFileSync} from 'fs';
+import path from 'path';
+import type {GoogleFont} from '@remotion/google-fonts';
+
+type BasicFontInfo = {
+ importName: string;
+ fontFamily: string;
+ previewUrl: string;
+ weights: string[];
+};
+
+// From https://www.remotion.dev/docs/font-picker#show-only-the-250-most-popular-google-fonts
+const TOP_250_GOOGLE_FONT_IMPORT_NAMES = [
+ 'ABeeZee',
+ 'Abel',
+ 'AbrilFatface',
+ 'Acme',
+ 'Alata',
+ 'AlbertSans',
+ 'Alegreya',
+ 'AlegreyaSans',
+ 'AlegreyaSansSC',
+ 'AlfaSlabOne',
+ 'Alice',
+ 'Almarai',
+ 'AmaticSC',
+ 'Amiri',
+ 'AnticSlab',
+ 'Anton',
+ 'ArchitectsDaughter',
+ 'Archivo',
+ 'ArchivoBlack',
+ 'ArchivoNarrow',
+ 'Arimo',
+ 'Arsenal',
+ 'Arvo',
+ 'Asap',
+ 'AsapCondensed',
+ 'Assistant',
+ 'Barlow',
+ 'BarlowCondensed',
+ 'BarlowSemiCondensed',
+ 'BeVietnamPro',
+ 'BebasNeue',
+ 'Bitter',
+ 'BlackOpsOne',
+ 'BodoniModa',
+ 'BreeSerif',
+ 'Bungee',
+ 'Cabin',
+ 'Cairo',
+ 'Cantarell',
+ 'Cardo',
+ 'Catamaran',
+ 'Caveat',
+ 'ChakraPetch',
+ 'Changa',
+ 'Chivo',
+ 'Cinzel',
+ 'Comfortaa',
+ 'Commissioner',
+ 'ConcertOne',
+ 'Cookie',
+ 'Cormorant',
+ 'CormorantGaramond',
+ 'Courgette',
+ 'CreteRound',
+ 'CrimsonPro',
+ 'CrimsonText',
+ 'Cuprum',
+ 'DMSans',
+ 'DMSerifDisplay',
+ 'DMSerifText',
+ 'DancingScript',
+ 'DidactGothic',
+ 'Domine',
+ 'Dosis',
+ 'EBGaramond',
+ 'Eczar',
+ 'ElMessiri',
+ 'Electrolize',
+ 'EncodeSans',
+ 'EncodeSansCondensed',
+ 'Exo',
+ 'Exo2',
+ 'Figtree',
+ 'FiraSans',
+ 'FiraSansCondensed',
+ 'FjallaOne',
+ 'FrancoisOne',
+ 'FrankRuhlLibre',
+ 'Fraunces',
+ 'Gelasio',
+ 'GloriaHallelujah',
+ 'GothicA1',
+ 'GreatVibes',
+ 'Gruppo',
+ 'Heebo',
+ 'Hind',
+ 'HindMadurai',
+ 'HindSiliguri',
+ 'IBMPlexMono',
+ 'IBMPlexSans',
+ 'IBMPlexSansArabic',
+ 'IBMPlexSansCondensed',
+ 'IBMPlexSerif',
+ 'Inconsolata',
+ 'IndieFlower',
+ 'Inter',
+ 'InterTight',
+ 'JosefinSans',
+ 'JosefinSlab',
+ 'Jost',
+ 'Kalam',
+ 'Kanit',
+ 'Karla',
+ 'KaushanScript',
+ 'Khand',
+ 'Lato',
+ 'LeagueSpartan',
+ 'Lexend',
+ 'LexendDeca',
+ 'LibreBarcode39',
+ 'LibreBaskerville',
+ 'LibreCaslonText',
+ 'LibreFranklin',
+ 'LilitaOne',
+ 'Lobster',
+ 'LobsterTwo',
+ 'Lora',
+ 'LuckiestGuy',
+ 'MPLUS1p',
+ 'MPLUSRounded1c',
+ 'Macondo',
+ 'Manrope',
+ 'Marcellus',
+ 'Martel',
+ 'Mate',
+ 'MateSC',
+ 'MavenPro',
+ 'Merienda',
+ 'Merriweather',
+ 'MerriweatherSans',
+ 'Montserrat',
+ 'MontserratAlternates',
+ 'Mukta',
+ 'Mulish',
+ 'NanumGothic',
+ 'NanumGothicCoding',
+ 'NanumMyeongjo',
+ 'Neuton',
+ 'NoticiaText',
+ 'NotoColorEmoji',
+ 'NotoKufiArabic',
+ 'NotoNaskhArabic',
+ 'NotoSans',
+ 'NotoSansArabic',
+ 'NotoSansBengali',
+ 'NotoSansDisplay',
+ 'NotoSansHK',
+ 'NotoSansJP',
+ 'NotoSansKR',
+ 'NotoSansMono',
+ 'NotoSansSC',
+ 'NotoSansTC',
+ 'NotoSansThai',
+ 'NotoSerif',
+ 'NotoSerifJP',
+ 'NotoSerifKR',
+ 'NotoSerifTC',
+ 'Nunito',
+ 'NunitoSans',
+ 'OldStandardTT',
+ 'OleoScript',
+ 'OpenSans',
+ 'Orbitron',
+ 'Oswald',
+ 'Outfit',
+ 'Overpass',
+ 'Oxygen',
+ 'PTSans',
+ 'PTSansCaption',
+ 'PTSansNarrow',
+ 'PTSerif',
+ 'Pacifico',
+ 'PassionOne',
+ 'PathwayGothicOne',
+ 'PatuaOne',
+ 'PaytoneOne',
+ 'PermanentMarker',
+ 'Philosopher',
+ 'Play',
+ 'PlayfairDisplay',
+ 'PlusJakartaSans',
+ 'Poppins',
+ 'Prata',
+ 'Prompt',
+ 'PublicSans',
+ 'Quattrocento',
+ 'QuattrocentoSans',
+ 'Questrial',
+ 'Quicksand',
+ 'Rajdhani',
+ 'Raleway',
+ 'ReadexPro',
+ 'RedHatDisplay',
+ 'Righteous',
+ 'Roboto',
+ 'RobotoCondensed',
+ 'RobotoFlex',
+ 'RobotoMono',
+ 'RobotoSerif',
+ 'RobotoSlab',
+ 'Rokkitt',
+ 'Rowdies',
+ 'Rubik',
+ 'RubikBubbles',
+ 'RubikMonoOne',
+ 'RussoOne',
+ 'Sacramento',
+ 'Saira',
+ 'SairaCondensed',
+ 'Sarabun',
+ 'Satisfy',
+ 'SawarabiGothic',
+ 'SawarabiMincho',
+ 'Sen',
+ 'ShadowsIntoLight',
+ 'Signika',
+ 'SignikaNegative',
+ 'Silkscreen',
+ 'SixCaps',
+ 'Slabo27px',
+ 'Sora',
+ 'SourceCodePro',
+ 'SourceSans3',
+ 'SourceSerif4',
+ 'SpaceGrotesk',
+ 'SpaceMono',
+ 'SpecialElite',
+ 'Spectral',
+ 'Tajawal',
+ 'Tangerine',
+ 'Teko',
+ 'Tinos',
+ 'TitanOne',
+ 'TitilliumWeb',
+ 'Ubuntu',
+ 'UbuntuCondensed',
+ 'UbuntuMono',
+ 'Unbounded',
+ 'Unna',
+ 'Urbanist',
+ 'VarelaRound',
+ 'Vollkorn',
+ 'WorkSans',
+ 'YanoneKaffeesatz',
+ 'Yantramanav',
+ 'Yellowtail',
+ 'YesevaOne',
+ 'ZenKakuGothicNew',
+ 'Zeyada',
+ 'ZillaSlab',
+ 'TikTokSans',
+] as const;
+
+const basicInfos: BasicFontInfo[] = [];
+
+for (const importName of TOP_250_GOOGLE_FONT_IMPORT_NAMES) {
+ const info = (await import(
+ `@remotion/google-fonts/${importName}`
+ )) as GoogleFont;
+ const fontInfo = info.getInfo();
+ const previewUrl = fontInfo.url.match(/family=(.*):/)?.[1];
+ if (!previewUrl) {
+ throw new Error(
+ `Could not extract Google Fonts CSS family for ${fontInfo.fontFamily}`,
+ );
+ }
+
+ const weights = Object.keys(fontInfo.fonts.normal ?? {}).sort(
+ (a, b) => Number(a) - Number(b),
+ );
+
+ basicInfos.push({
+ importName: fontInfo.importName,
+ fontFamily: fontInfo.fontFamily,
+ previewUrl,
+ weights: weights.length ? weights : ['400'],
+ });
+}
+
+const basicContent = [
+ `// Auto-generated by packages/studio/scripts/generate-google-font-info.ts`,
+ `export const GOOGLE_FONTS_LIST = ${JSON.stringify(basicInfos, null, 2)};`,
+].join('\n');
+
+writeFileSync(
+ path.join(
+ __dirname,
+ '..',
+ 'src',
+ 'components',
+ 'Timeline',
+ 'google-fonts-list.ts',
+ ),
+ basicContent,
+);
+execSync(
+ `bunx oxfmt packages/studio/src/components/Timeline/google-fonts-list.ts --write`,
+ {
+ stdio: 'inherit',
+ },
+);
diff --git a/packages/studio/src/components/Timeline/TimelineFontFamilyField.tsx b/packages/studio/src/components/Timeline/TimelineFontFamilyField.tsx
new file mode 100644
index 0000000000..ccbe7bd32f
--- /dev/null
+++ b/packages/studio/src/components/Timeline/TimelineFontFamilyField.tsx
@@ -0,0 +1,849 @@
+import {PlayerInternals} from '@remotion/player';
+import type {GoogleFontSourceEdit} from '@remotion/studio-shared';
+import React, {useCallback, useEffect, useMemo, useRef, useState} from 'react';
+import ReactDOM from 'react-dom';
+import type {CanUpdateSequencePropStatusStatic} from 'remotion';
+import {
+ BACKGROUND,
+ INPUT_BACKGROUND,
+ LIGHT_TEXT,
+ SELECTED_BACKGROUND,
+} from '../../helpers/colors';
+import {installRequiredPackages} from '../../helpers/install-required-package';
+import type {
+ SchemaFieldInfo,
+ TimelineFieldOnDragValueChange,
+ TimelineFieldOnSave,
+} from '../../helpers/timeline-layout';
+import {CaretDown} from '../../icons/caret';
+import {Checkmark} from '../../icons/Checkmark';
+import {HigherZIndex, useZIndex} from '../../state/z-index';
+import {Spacing} from '../layout';
+import {MENU_INITIATOR_CLASSNAME} from '../Menu/is-menu-item';
+import {getPortal} from '../Menu/portals';
+import {
+ SHADOW_TOWARDS_BOTTOM,
+ SHADOW_TOWARDS_TOP,
+ fullScreenOverlay,
+ outerPortal,
+} from '../Menu/styles';
+import {GOOGLE_FONTS_LIST} from './google-fonts-list';
+
+const ROW_HEIGHT = 30;
+const LIST_HEIGHT = 280;
+const OVERSCAN = 10;
+const POPOVER_WIDTH = 280;
+const CLEAR_HOVER = 'rgba(255, 255, 255, 0.06)';
+const INPUT_BORDER_COLOR_UNHOVERED = 'rgba(0, 0, 0, 0.6)';
+const INPUT_BORDER_COLOR_HOVERED = 'rgba(255, 255, 255, 0.05)';
+
+const googleFonts = GOOGLE_FONTS_LIST.map((font) => ({
+ id: `google-${font.importName}`,
+ fontFamily: font.fontFamily,
+ label: font.fontFamily,
+ source: 'Google Fonts' as const,
+ value: font.fontFamily,
+ googleFontImportName: font.importName,
+ googleFontCssFamily: font.previewUrl,
+ googleFontWeights: font.weights,
+}));
+
+const loadedGoogleFontsForPreview = new Set<string>();
+const loadingGoogleFontsForPreview = new Set<string>();
+const loadedGoogleFontsForPickerPreview = new Set<string>();
+const loadingGoogleFontsForPickerPreview = new Set<string>();
+
+const systemFonts = [
+ 'Arial',
+ 'Helvetica',
+ 'Inter',
+ 'Georgia',
+ 'Times New Roman',
+ 'Courier New',
+ 'Verdana',
+ 'Tahoma',
+ 'Trebuchet MS',
+ 'sans-serif',
+ 'serif',
+ 'monospace',
+].map((fontFamily) => ({
+ id: `system-${fontFamily}`,
+ fontFamily,
+ label: fontFamily,
+ source: 'System' as const,
+ value: fontFamily,
+}));
+
+type FontFamilyOption = {
+ readonly id: string;
+ readonly fontFamily: string | null;
+ readonly label: string;
+ readonly source: 'Default' | 'System' | 'Google Fonts' | 'Current';
+ readonly value: string | undefined;
+ readonly googleFontImportName?: string;
+ readonly googleFontCssFamily?: string;
+ readonly googleFontWeights?: string[];
+};
+
+const triggerStyle: React.CSSProperties = {
+ marginLeft: 8,
+ padding: '3px 4px',
+ display: 'inline-flex',
+ alignItems: 'center',
+ backgroundColor: INPUT_BACKGROUND,
+ borderWidth: 1,
+ borderStyle: 'solid',
+ maxWidth: 140,
+ color: 'white',
+ userSelect: 'none',
+ WebkitUserSelect: 'none',
+};
+
+const triggerLabel: React.CSSProperties = {
+ fontSize: 11,
+ lineHeight: 1,
+ textAlign: 'left',
+ overflow: 'hidden',
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+};
+
+const popover: React.CSSProperties = {
+ position: 'fixed',
+ width: POPOVER_WIDTH,
+ backgroundColor: BACKGROUND,
+ color: 'white',
+ userSelect: 'none',
+ WebkitUserSelect: 'none',
+ border: '1px solid rgba(255, 255, 255, 0.08)',
+};
+
+const searchInput: React.CSSProperties = {
+ boxSizing: 'border-box',
+ width: '100%',
+ backgroundColor: INPUT_BACKGROUND,
+ border: '1px solid rgba(255, 255, 255, 0.12)',
+ color: 'white',
+ fontSize: 12,
+ outline: 'none',
+ padding: '6px 8px',
+};
+
+const listStyle: React.CSSProperties = {
+ height: LIST_HEIGHT,
+ overflowY: 'auto',
+ overflowX: 'hidden',
+ position: 'relative',
+};
+
+const noResults: React.CSSProperties = {
+ fontSize: 12,
+ color: LIGHT_TEXT,
+ padding: 12,
+};
+
+const optionButton: React.CSSProperties = {
+ height: ROW_HEIGHT,
+ width: '100%',
+ border: 'none',
+ background: 'transparent',
+ color: 'white',
+ display: 'flex',
+ alignItems: 'center',
+ padding: '0 8px',
+ fontSize: 12,
+ textAlign: 'left',
+ cursor: 'default',
+};
+
+const optionLabel: React.CSSProperties = {
+ flex: 1,
+ overflow: 'hidden',
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ fontSize: 12,
+};
+
+const optionSource: React.CSSProperties = {
+ color: LIGHT_TEXT,
+ fontSize: 10,
+ marginLeft: 8,
+};
+
+const errorText: React.CSSProperties = {
+ padding: '6px 8px',
+ color: '#ff8a8a',
+ fontSize: 10,
+};
+
+const portalStyle = ({
+ size,
+}: {
+ size: NonNullable<ReturnType<typeof PlayerInternals.useElementSize>>;
+}): React.CSSProperties => {
+ const margin = 10;
+ const spaceToBottom =
+ size.windowSize.height - (size.top + size.height) - margin;
+ const spaceToTop = size.top - margin;
+ const openDown = spaceToBottom >= LIST_HEIGHT || spaceToBottom >= spaceToTop;
+ const left = Math.min(
+ Math.max(0, size.left),
+ Math.max(0, size.windowSize.width - POPOVER_WIDTH),
+ );
+
+ return {
+ ...popover,
+ boxShadow: openDown ? SHADOW_TOWARDS_BOTTOM : SHADOW_TOWARDS_TOP,
+ left,
+ ...(openDown
+ ? {top: size.top + size.height}
+ : {bottom: size.windowSize.height - size.top}),
+ };
+};
+
+const getCurrentValue = ({
+ effectiveValue,
+ fallback,
+}: {
+ readonly effectiveValue: unknown;
+ readonly fallback: string | undefined;
+}) => {
+ return typeof effectiveValue === 'string' ? effectiveValue : fallback;
+};
+
+const scrollIndexIntoView = ({
+ index,
+ list,
+}: {
+ readonly index: number;
+ readonly list: HTMLDivElement;
+}) => {
+ const top = index * ROW_HEIGHT;
+ const bottom = top + ROW_HEIGHT;
+ if (top < list.scrollTop) {
+ list.scrollTop = top;
+ return;
+ }
+
+ if (bottom > list.scrollTop + LIST_HEIGHT) {
+ list.scrollTop = bottom - LIST_HEIGHT;
+ }
+};
+
+const getGoogleFontSourceEdit = ({
+ fontFamily,
+ importName,
+ weights,
+}: {
+ readonly fontFamily: string;
+ readonly importName: string;
+ readonly weights: string[];
+}): GoogleFontSourceEdit => {
+ return {
+ fontFamily,
+ importName,
+ style: 'normal',
+ weights,
+ subsets: ['latin'],
+ };
+};
+
+const makeFontPreviewName = (fontFamily: string) => {
+ return `${fontFamily}Preview`;
+};
+
+const loadGoogleFontForPickerPreview = async ({
+ fontFamily,
+ cssFamily,
+ document,
+}: {
+ readonly fontFamily: string;
+ readonly cssFamily: string;
+ readonly document: Document;
+}) => {
+ if (
+ loadedGoogleFontsForPickerPreview.has(fontFamily) ||
+ loadingGoogleFontsForPickerPreview.has(fontFamily)
+ ) {
+ return;
+ }
+
+ loadingGoogleFontsForPickerPreview.add(fontFamily);
+ try {
+ const response = await fetch(
+ `https://fonts.googleapis.com/css?family=${cssFamily}:400&text=${encodeURIComponent(
+ fontFamily,
+ )}`,
+ );
+ if (!response.ok) {
+ return;
+ }
+
+ const cssText = await response.text();
+ const match = cssText.match(/url\(([^)]+)\)/);
+ const url = match?.[1];
+ if (!url) {
+ return;
+ }
+
+ const fontFace = new FontFace(
+ makeFontPreviewName(fontFamily),
+ `url(${url})`,
+ {weight: '400'},
+ );
+ await fontFace.load();
+ document.fonts.add(fontFace);
+ loadedGoogleFontsForPickerPreview.add(fontFamily);
+ } finally {
+ loadingGoogleFontsForPickerPreview.delete(fontFamily);
+ }
+};
+
+const getGoogleFontUrlsFromCss = (cssText: string) => {
+ return [...cssText.matchAll(/url\(([^)]+)\)/g)].map((match) => match[1]);
+};
+
+const loadGoogleFontWeight = async ({
+ cssFamily,
+ fontFaceFamily,
+ weight,
+ document,
+ text,
+}: {
+ readonly cssFamily: string;
+ readonly fontFaceFamily: string;
+ readonly weight: string;
+ readonly document: Document;
+ readonly text: string | null;
+}) => {
+ const response = await fetch(
+ `https://fonts.googleapis.com/css?family=${cssFamily}:${weight}${
+ text === null ? '' : `&text=${encodeURIComponent(text)}`
+ }`,
+ );
+ if (!response.ok) {
+ return false;
+ }
+
+ const cssText = await response.text();
+ const urls = getGoogleFontUrlsFromCss(cssText);
+ if (urls.length === 0) {
+ return false;
+ }
+
+ await Promise.all(
+ urls.map(async (url) => {
+ const fontFace = new FontFace(fontFaceFamily, `url(${url})`, {weight});
+ await fontFace.load();
+ document.fonts.add(fontFace);
+ }),
+ );
+ return true;
+};
+
+const commonPreviewFontWeights = ['400', '700', '800'];
+
+const getGoogleFontPreviewWeights = (weights: string[]) => {
+ const commonWeights = weights.filter((weight) =>
+ commonPreviewFontWeights.includes(weight),
+ );
+ return commonWeights.length ? commonWeights : weights.slice(0, 1);
+};
+
+const loadGoogleFontForPreview = async ({
+ fontFamily,
+ cssFamily,
+ weights,
+ document,
+}: {
+ readonly fontFamily: string;
+ readonly cssFamily: string;
+ readonly weights: string[];
+ readonly document: Document;
+}) => {
+ if (
+ loadedGoogleFontsForPreview.has(fontFamily) ||
+ loadingGoogleFontsForPreview.has(fontFamily)
+ ) {
+ return;
+ }
+
+ if (!GOOGLE_FONTS_LIST.some((font) => font.fontFamily === fontFamily)) {
+ return;
+ }
+
+ loadingGoogleFontsForPreview.add(fontFamily);
+ try {
+ const loadedWeights = await Promise.all(
+ getGoogleFontPreviewWeights(weights).map((weight) =>
+ loadGoogleFontWeight({
+ cssFamily,
+ fontFaceFamily: fontFamily,
+ weight,
+ document,
+ text: null,
+ }),
+ ),
+ );
+ if (loadedWeights.some(Boolean)) {
+ loadedGoogleFontsForPreview.add(fontFamily);
+ }
+ } finally {
+ loadingGoogleFontsForPreview.delete(fontFamily);
+ }
+};
+
+export const TimelineFontFamilyField: React.FC<{
+ readonly field: SchemaFieldInfo;
+ readonly propStatus: CanUpdateSequencePropStatusStatic;
+ readonly effectiveValue: unknown;
+ readonly onSave: TimelineFieldOnSave;
+ readonly onDragValueChange: TimelineFieldOnDragValueChange;
+ readonly onDragEnd: () => void;
+}> = ({
+ field,
+ propStatus,
+ effectiveValue,
+ onSave,
+ onDragValueChange,
+ onDragEnd,
+}) => {
+ const {fieldSchema} = field;
+ if (fieldSchema.type !== 'font-family') {
+ throw new Error(
+ 'TimelineFontFamilyField rendered for non-font-family field',
+ );
+ }
+
+ const fallback = fieldSchema.default;
+ const current = getCurrentValue({effectiveValue, fallback});
+ const defaultOption = useMemo((): FontFamilyOption => {
+ return {
+ id: 'default',
+ fontFamily: fallback ?? null,
+ label: fallback ? `Default (${fallback})` : 'Default',
+ source: 'Default',
+ value: fallback,
+ };
+ }, [fallback]);
+ const [opened, setOpened] = useState(false);
+ const [hovered, setHovered] = useState(false);
+ const [query, setQuery] = useState('');
+ const [highlightedIndex, setHighlightedIndex] = useState(0);
+ const [scrollTop, setScrollTop] = useState(0);
+ const [loadedPickerPreviewFonts, setLoadedPickerPreviewFonts] = useState(
+ () => new Set(loadedGoogleFontsForPickerPreview),
+ );
+ const [saveError, setSaveError] = useState<string | null>(null);
+ const buttonRef = useRef<HTMLButtonElement>(null);
+ const inputRef = useRef<HTMLInputElement>(null);
+ const listRef = useRef<HTMLDivElement>(null);
+ const {tabIndex, currentZIndex} = useZIndex();
+ const size = PlayerInternals.useElementSize(buttonRef, {
+ triggerOnWindowResize: true,
+ shouldApplyCssTransforms: true,
+ });
+
+ const options = useMemo((): FontFamilyOption[] => {
+ const base = [defaultOption, ...systemFonts, ...googleFonts];
+ if (!current || base.some((option) => option.value === current)) {
+ return base;
+ }
+
+ return [
+ defaultOption,
+ {
+ id: `current-${current}`,
+ fontFamily: current,
+ label: current,
+ source: 'Current',
+ value: current,
+ },
+ ...systemFonts,
+ ...googleFonts,
+ ];
+ }, [current, defaultOption]);
+
+ const filteredOptions = useMemo(() => {
+ const needle = query.trim().toLowerCase();
+ if (!needle) {
+ return options;
+ }
+
+ return options.filter((option) => {
+ return option.label.toLowerCase().includes(needle);
+ });
+ }, [options, query]);
+
+ const selected = useMemo(() => {
+ return options.find((option) => option.value === current) ?? defaultOption;
+ }, [current, defaultOption, options]);
+
+ const visibleRange = useMemo(() => {
+ const visibleCount = Math.ceil(LIST_HEIGHT / ROW_HEIGHT);
+ const start = Math.max(0, Math.floor(scrollTop / ROW_HEIGHT) - OVERSCAN);
+ const end = Math.min(
+ filteredOptions.length,
+ start + visibleCount + OVERSCAN * 2,
+ );
+ return {start, end};
+ }, [filteredOptions.length, scrollTop]);
+
+ const hide = useCallback(() => {
+ setOpened(false);
+ setQuery('');
+ }, []);
+
+ const selectOption = useCallback(
+ (option: FontFamilyOption) => {
+ setSaveError(null);
+ if (option.value === propStatus.codeValue) {
+ hide();
+ return;
+ }
+
+ onDragValueChange(option.value);
+ hide();
+
+ const save = async () => {
+ if (option.source !== 'Google Fonts' || !option.googleFontImportName) {
+ await onSave(option.value);
+ return;
+ }
+
+ await installRequiredPackages(['@remotion/google-fonts']);
+ const googleFont = getGoogleFontSourceEdit({
+ fontFamily: option.value ?? option.label,
+ importName: option.googleFontImportName,
+ weights: option.googleFontWeights ?? ['400'],
+ });
+ await onSave(option.value, {
+ sourceEdit: {type: 'google-font', font: googleFont},
+ });
+ };
+
+ save()
+ .catch((err) => {
+ onDragValueChange(propStatus.codeValue);
+ setSaveError(err instanceof Error ? err.message : String(err));
+ })
+ .finally(() => {
+ onDragEnd();
+ });
+ },
+ [propStatus.codeValue, onDragValueChange, hide, onSave, onDragEnd],
+ );
+
+ const toggleOpened = useCallback(() => {
+ if (opened) {
+ setOpened(false);
+ return;
+ }
+
+ size?.refresh?.();
+ setOpened(true);
+ }, [opened, size]);
+
+ useEffect(() => {
+ if (!opened) {
+ return;
+ }
+
+ const selectedIndex = filteredOptions.findIndex(
+ (option) => option.value === current,
+ );
+ const nextIndex = Math.max(0, selectedIndex);
+ setHighlightedIndex(nextIndex);
+
+ requestAnimationFrame(() => {
+ inputRef.current?.focus();
+ const list = listRef.current;
+ if (!list) {
+ return;
+ }
+
+ list.scrollTop = Math.max(
+ 0,
+ nextIndex * ROW_HEIGHT - LIST_HEIGHT / 2 + ROW_HEIGHT / 2,
+ );
+ });
+ }, [current, filteredOptions, opened]);
+
+ useEffect(() => {
+ setHighlightedIndex(0);
+ if (listRef.current) {
+ listRef.current.scrollTop = 0;
+ }
+ }, [query]);
+
+ useEffect(() => {
+ if (!current) {
+ return;
+ }
+
+ const googleFont = GOOGLE_FONTS_LIST.find(
+ (font) => font.fontFamily === current,
+ );
+ if (!googleFont) {
+ return;
+ }
+
+ loadGoogleFontForPreview({
+ fontFamily: current,
+ cssFamily: googleFont.previewUrl,
+ weights: googleFont.weights,
+ document,
+ }).catch(() => undefined);
+ loadGoogleFontForPickerPreview({
+ fontFamily: current,
+ cssFamily: googleFont.previewUrl,
+ document,
+ })
+ .then(() => {
+ setLoadedPickerPreviewFonts(new Set(loadedGoogleFontsForPickerPreview));
+ })
+ .catch(() => undefined);
+ }, [current]);
+
+ useEffect(() => {
+ if (!opened) {
+ return;
+ }
+
+ const visibleGoogleFonts = filteredOptions
+ .slice(visibleRange.start, visibleRange.end)
+ .filter(
+ (option) =>
+ option.source === 'Google Fonts' &&
+ option.fontFamily &&
+ option.googleFontCssFamily,
+ );
+
+ if (visibleGoogleFonts.length === 0) {
+ return;
+ }
+
+ Promise.all(
+ visibleGoogleFonts.map((font) =>
+ loadGoogleFontForPickerPreview({
+ fontFamily: font.fontFamily as string,
+ cssFamily: font.googleFontCssFamily as string,
+ document,
+ }),
+ ),
+ )
+ .then(() => {
+ setLoadedPickerPreviewFonts(new Set(loadedGoogleFontsForPickerPreview));
+ })
+ .catch(() => undefined);
+ }, [filteredOptions, opened, visibleRange.end, visibleRange.start]);
+
+ const onKeyDown = useCallback(
+ (event: React.KeyboardEvent<HTMLInputElement>) => {
+ if (event.key === 'ArrowDown') {
+ event.preventDefault();
+ setHighlightedIndex((prev) => {
+ const next = Math.max(
+ 0,
+ Math.min(filteredOptions.length - 1, prev + 1),
+ );
+ if (listRef.current) {
+ scrollIndexIntoView({index: next, list: listRef.current});
+ }
+
+ return next;
+ });
+ }
+
+ if (event.key === 'ArrowUp') {
+ event.preventDefault();
+ setHighlightedIndex((prev) => {
+ const next = Math.max(0, prev - 1);
+ if (listRef.current) {
+ scrollIndexIntoView({index: next, list: listRef.current});
+ }
+
+ return next;
+ });
+ }
+
+ if (event.key === 'Enter') {
+ event.preventDefault();
+ const option = filteredOptions[highlightedIndex];
+ if (option) {
+ selectOption(option);
+ }
+ }
+
+ if (event.key === 'Escape') {
+ event.preventDefault();
+ hide();
+ }
+ },
+ [filteredOptions, hide, highlightedIndex, selectOption],
+ );
+
+ const renderedOptions = filteredOptions.slice(
+ visibleRange.start,
+ visibleRange.end,
+ );
+ const getOptionPreviewStyle = useCallback(
+ (option: FontFamilyOption): React.CSSProperties => {
+ if (
+ option.source !== 'Google Fonts' ||
+ !option.fontFamily ||
+ !loadedPickerPreviewFonts.has(option.fontFamily)
+ ) {
+ return {};
+ }
+
+ return {fontFamily: makeFontPreviewName(option.fontFamily)};
+ },
+ [loadedPickerPreviewFonts],
+ );
+ const style = useMemo((): React.CSSProperties => {
+ return {
+ ...triggerStyle,
+ borderColor: opened
+ ? SELECTED_BACKGROUND
+ : hovered
+ ? INPUT_BORDER_COLOR_HOVERED
+ : INPUT_BORDER_COLOR_UNHOVERED,
+ };
+ }, [hovered, opened]);
+ const selectedPreviewStyle = getOptionPreviewStyle(selected);
+
+ return (
+ <>
+ <button
+ ref={buttonRef}
+ title={field.key}
+ tabIndex={tabIndex}
+ type="button"
+ style={style}
+ className={MENU_INITIATOR_CLASSNAME}
+ onPointerDown={(event) => {
+ event.stopPropagation();
+ toggleOpened();
+ }}
+ onClick={(event) => {
+ event.stopPropagation();
+ if (event.detail === 0) {
+ toggleOpened();
+ }
+ }}
+ onMouseEnter={() => setHovered(true)}
+ onMouseLeave={() => setHovered(false)}
+ >
+ <div
+ title={selected.label}
+ style={{...triggerLabel, ...selectedPreviewStyle}}
+ >
+ {selected.label}
+ </div>
+ <Spacing x={0.5} />
+ <CaretDown small />
+ </button>
+ {saveError === null ? null : <div style={errorText}>{saveError}</div>}
+ {opened && size
+ ? ReactDOM.createPortal(
+ <div
+ style={fullScreenOverlay}
+ onPointerDown={(event) => event.stopPropagation()}
+ >
+ <div style={outerPortal} className="css-reset">
+ <HigherZIndex onOutsideClick={hide} onEscape={hide}>
+ <div style={portalStyle({size})}>
+ <div style={{padding: 6}}>
+ <input
+ ref={inputRef}
+ value={query}
+ onChange={(event) => setQuery(event.target.value)}
+ onKeyDown={onKeyDown}
+ placeholder="Search fonts"
+ style={searchInput}
+ />
+ </div>
+ {filteredOptions.length === 0 ? (
+ <div style={noResults}>No fonts found</div>
+ ) : (
+ <div
+ ref={listRef}
+ style={listStyle}
+ onScroll={(event) => {
+ setScrollTop(event.currentTarget.scrollTop);
+ }}
+ >
+ <div
+ style={{height: visibleRange.start * ROW_HEIGHT}}
+ />
+ {renderedOptions.map((option, index) => {
+ const actualIndex = visibleRange.start + index;
+ const isSelected = option.value === current;
+ const isHighlighted =
+ actualIndex === highlightedIndex;
+ return (
+ <button
+ key={option.id}
+ type="button"
+ style={{
+ ...optionButton,
+ backgroundColor: isHighlighted
+ ? CLEAR_HOVER
+ : isSelected
+ ? SELECTED_BACKGROUND
+ : 'transparent',
+ }}
+ onPointerEnter={() =>
+ setHighlightedIndex(actualIndex)
+ }
+ onPointerDown={(event) => {
+ event.preventDefault();
+ event.stopPropagation();
+ selectOption(option);
+ }}
+ >
+ <span style={{width: 18}}>
+ {isSelected ? <Checkmark size={11} /> : null}
+ </span>
+ <span
+ style={{
+ ...optionLabel,
+ ...getOptionPreviewStyle(option),
+ }}
+ >
+ {option.label}
+ </span>
+ <span style={optionSource}>{option.source}</span>
+ </button>
+ );
+ })}
+ <div
+ style={{
+ height:
+ (filteredOptions.length - visibleRange.end) *
+ ROW_HEIGHT,
+ }}
+ />
+ </div>
+ )}
+ <div
+ style={{
+ padding: '6px 8px',
+ color: LIGHT_TEXT,
+ fontSize: 10,
+ }}
+ >
+ Google Fonts are loaded for Studio preview and saved to
+ your composition when selected.
+ </div>
+ </div>
+ </HigherZIndex>
+ </div>
+ </div>,
+ getPortal(currentZIndex),
+ )
+ : null}
+ </>
+ );
+};
diff --git a/packages/studio/src/components/Timeline/TimelinePrimitiveFieldValue.tsx b/packages/studio/src/components/Timeline/TimelinePrimitiveFieldValue.tsx
index 08c4d43ca3..ba06d5657b 100644
--- a/packages/studio/src/components/Timeline/TimelinePrimitiveFieldValue.tsx
+++ b/packages/studio/src/components/Timeline/TimelinePrimitiveFieldValue.tsx
@@ -13,6 +13,7 @@ import type {
import {TimelineBooleanField} from './TimelineBooleanField';
import {TimelineColorField} from './TimelineColorField';
import {TimelineEnumField} from './TimelineEnumField';
+import {TimelineFontFamilyField} from './TimelineFontFamilyField';
import {TimelineNumberField} from './TimelineNumberField';
import {TimelineRotationField} from './TimelineRotationField';
import {TimelineScaleField} from './TimelineScaleField';
@@ -217,5 +218,20 @@ export const TimelinePrimitiveFieldValue: React.FC<{
);
}
+ if (field.typeName === 'font-family') {
+ return (
+ <span style={inlineWrapper}>
+ <TimelineFontFamilyField
+ effectiveValue={effectiveValue}
+ field={field}
+ onDragEnd={onDragEnd}
+ onDragValueChange={onDragValueChange}
+ onSave={onSave}
+ propStatus={propStatus}
+ />
+ </span>
+ );
+ }
+
throw new Error(`Unsupported field type: ${field.typeName satisfies never}`);
};
diff --git a/packages/studio/src/components/Timeline/TimelineSequencePropItem.tsx b/packages/studio/src/components/Timeline/TimelineSequencePropItem.tsx
index 444dbd9262..e4dab6d18b 100644
--- a/packages/studio/src/components/Timeline/TimelineSequencePropItem.tsx
+++ b/packages/studio/src/components/Timeline/TimelineSequencePropItem.tsx
@@ -108,7 +108,7 @@ const Value: React.FC<{
: null;
const onSave = useCallback<TimelineFieldOnSave>(
- (value) => {
+ (value, options) => {
if (!clientId) {
return Promise.reject(new Error('Not connected to studio server'));
}
@@ -143,6 +143,7 @@ const Value: React.FC<{
value,
defaultValue,
schema,
+ sourceEdit: options?.sourceEdit,
},
],
setPropStatuses,
diff --git a/packages/studio/src/components/Timeline/google-fonts-list.ts b/packages/studio/src/components/Timeline/google-fonts-list.ts
new file mode 100644
index 0000000000..1fbc77fc85
--- /dev/null
+++ b/packages/studio/src/components/Timeline/google-fonts-list.ts
@@ -0,0 +1,1509 @@
+// Auto-generated by packages/studio/scripts/generate-google-font-info.ts
+export const GOOGLE_FONTS_LIST = [
+ {
+ importName: 'ABeeZee',
+ fontFamily: 'ABeeZee',
+ previewUrl: 'ABeeZee',
+ weights: ['400'],
+ },
+ {
+ importName: 'Abel',
+ fontFamily: 'Abel',
+ previewUrl: 'Abel',
+ weights: ['400'],
+ },
+ {
+ importName: 'AbrilFatface',
+ fontFamily: 'Abril Fatface',
+ previewUrl: 'Abril+Fatface',
+ weights: ['400'],
+ },
+ {
+ importName: 'Acme',
+ fontFamily: 'Acme',
+ previewUrl: 'Acme',
+ weights: ['400'],
+ },
+ {
+ importName: 'Alata',
+ fontFamily: 'Alata',
+ previewUrl: 'Alata',
+ weights: ['400'],
+ },
+ {
+ importName: 'AlbertSans',
+ fontFamily: 'Albert Sans',
+ previewUrl: 'Albert+Sans',
+ weights: ['100', '200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'Alegreya',
+ fontFamily: 'Alegreya',
+ previewUrl: 'Alegreya',
+ weights: ['400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'AlegreyaSans',
+ fontFamily: 'Alegreya Sans',
+ previewUrl: 'Alegreya+Sans',
+ weights: ['100', '300', '400', '500', '700', '800', '900'],
+ },
+ {
+ importName: 'AlegreyaSansSC',
+ fontFamily: 'Alegreya Sans SC',
+ previewUrl: 'Alegreya+Sans+SC',
+ weights: ['100', '300', '400', '500', '700', '800', '900'],
+ },
+ {
+ importName: 'AlfaSlabOne',
+ fontFamily: 'Alfa Slab One',
+ previewUrl: 'Alfa+Slab+One',
+ weights: ['400'],
+ },
+ {
+ importName: 'Alice',
+ fontFamily: 'Alice',
+ previewUrl: 'Alice',
+ weights: ['400'],
+ },
+ {
+ importName: 'Almarai',
+ fontFamily: 'Almarai',
+ previewUrl: 'Almarai',
+ weights: ['300', '400', '700', '800'],
+ },
+ {
+ importName: 'AmaticSC',
+ fontFamily: 'Amatic SC',
+ previewUrl: 'Amatic+SC',
+ weights: ['400', '700'],
+ },
+ {
+ importName: 'Amiri',
+ fontFamily: 'Amiri',
+ previewUrl: 'Amiri',
+ weights: ['400', '700'],
+ },
+ {
+ importName: 'AnticSlab',
+ fontFamily: 'Antic Slab',
+ previewUrl: 'Antic+Slab',
+ weights: ['400'],
+ },
+ {
+ importName: 'Anton',
+ fontFamily: 'Anton',
+ previewUrl: 'Anton',
+ weights: ['400'],
+ },
+ {
+ importName: 'ArchitectsDaughter',
+ fontFamily: 'Architects Daughter',
+ previewUrl: 'Architects+Daughter',
+ weights: ['400'],
+ },
+ {
+ importName: 'Archivo',
+ fontFamily: 'Archivo',
+ previewUrl: 'Archivo',
+ weights: ['100', '200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'ArchivoBlack',
+ fontFamily: 'Archivo Black',
+ previewUrl: 'Archivo+Black',
+ weights: ['400'],
+ },
+ {
+ importName: 'ArchivoNarrow',
+ fontFamily: 'Archivo Narrow',
+ previewUrl: 'Archivo+Narrow',
+ weights: ['400', '500', '600', '700'],
+ },
+ {
+ importName: 'Arimo',
+ fontFamily: 'Arimo',
+ previewUrl: 'Arimo',
+ weights: ['400', '500', '600', '700'],
+ },
+ {
+ importName: 'Arsenal',
+ fontFamily: 'Arsenal',
+ previewUrl: 'Arsenal',
+ weights: ['400', '700'],
+ },
+ {
+ importName: 'Arvo',
+ fontFamily: 'Arvo',
+ previewUrl: 'Arvo',
+ weights: ['400', '700'],
+ },
+ {
+ importName: 'Asap',
+ fontFamily: 'Asap',
+ previewUrl: 'Asap',
+ weights: ['100', '200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'AsapCondensed',
+ fontFamily: 'Asap Condensed',
+ previewUrl: 'Asap+Condensed',
+ weights: ['200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'Assistant',
+ fontFamily: 'Assistant',
+ previewUrl: 'Assistant',
+ weights: ['200', '300', '400', '500', '600', '700', '800'],
+ },
+ {
+ importName: 'Barlow',
+ fontFamily: 'Barlow',
+ previewUrl: 'Barlow',
+ weights: ['100', '200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'BarlowCondensed',
+ fontFamily: 'Barlow Condensed',
+ previewUrl: 'Barlow+Condensed',
+ weights: ['100', '200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'BarlowSemiCondensed',
+ fontFamily: 'Barlow Semi Condensed',
+ previewUrl: 'Barlow+Semi+Condensed',
+ weights: ['100', '200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'BeVietnamPro',
+ fontFamily: 'Be Vietnam Pro',
+ previewUrl: 'Be+Vietnam+Pro',
+ weights: ['100', '200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'BebasNeue',
+ fontFamily: 'Bebas Neue',
+ previewUrl: 'Bebas+Neue',
+ weights: ['400'],
+ },
+ {
+ importName: 'Bitter',
+ fontFamily: 'Bitter',
+ previewUrl: 'Bitter',
+ weights: ['100', '200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'BlackOpsOne',
+ fontFamily: 'Black Ops One',
+ previewUrl: 'Black+Ops+One',
+ weights: ['400'],
+ },
+ {
+ importName: 'BodoniModa',
+ fontFamily: 'Bodoni Moda',
+ previewUrl: 'Bodoni+Moda',
+ weights: ['400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'BreeSerif',
+ fontFamily: 'Bree Serif',
+ previewUrl: 'Bree+Serif',
+ weights: ['400'],
+ },
+ {
+ importName: 'Bungee',
+ fontFamily: 'Bungee',
+ previewUrl: 'Bungee',
+ weights: ['400'],
+ },
+ {
+ importName: 'Cabin',
+ fontFamily: 'Cabin',
+ previewUrl: 'Cabin',
+ weights: ['400', '500', '600', '700'],
+ },
+ {
+ importName: 'Cairo',
+ fontFamily: 'Cairo',
+ previewUrl: 'Cairo',
+ weights: ['200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'Cantarell',
+ fontFamily: 'Cantarell',
+ previewUrl: 'Cantarell',
+ weights: ['400', '700'],
+ },
+ {
+ importName: 'Cardo',
+ fontFamily: 'Cardo',
+ previewUrl: 'Cardo',
+ weights: ['400', '700'],
+ },
+ {
+ importName: 'Catamaran',
+ fontFamily: 'Catamaran',
+ previewUrl: 'Catamaran',
+ weights: ['100', '200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'Caveat',
+ fontFamily: 'Caveat',
+ previewUrl: 'Caveat',
+ weights: ['400', '500', '600', '700'],
+ },
+ {
+ importName: 'ChakraPetch',
+ fontFamily: 'Chakra Petch',
+ previewUrl: 'Chakra+Petch',
+ weights: ['300', '400', '500', '600', '700'],
+ },
+ {
+ importName: 'Changa',
+ fontFamily: 'Changa',
+ previewUrl: 'Changa',
+ weights: ['200', '300', '400', '500', '600', '700', '800'],
+ },
+ {
+ importName: 'Chivo',
+ fontFamily: 'Chivo',
+ previewUrl: 'Chivo',
+ weights: ['100', '200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'Cinzel',
+ fontFamily: 'Cinzel',
+ previewUrl: 'Cinzel',
+ weights: ['400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'Comfortaa',
+ fontFamily: 'Comfortaa',
+ previewUrl: 'Comfortaa',
+ weights: ['300', '400', '500', '600', '700'],
+ },
+ {
+ importName: 'Commissioner',
+ fontFamily: 'Commissioner',
+ previewUrl: 'Commissioner',
+ weights: ['100', '200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'ConcertOne',
+ fontFamily: 'Concert One',
+ previewUrl: 'Concert+One',
+ weights: ['400'],
+ },
+ {
+ importName: 'Cookie',
+ fontFamily: 'Cookie',
+ previewUrl: 'Cookie',
+ weights: ['400'],
+ },
+ {
+ importName: 'Cormorant',
+ fontFamily: 'Cormorant',
+ previewUrl: 'Cormorant',
+ weights: ['300', '400', '500', '600', '700'],
+ },
+ {
+ importName: 'CormorantGaramond',
+ fontFamily: 'Cormorant Garamond',
+ previewUrl: 'Cormorant+Garamond',
+ weights: ['300', '400', '500', '600', '700'],
+ },
+ {
+ importName: 'Courgette',
+ fontFamily: 'Courgette',
+ previewUrl: 'Courgette',
+ weights: ['400'],
+ },
+ {
+ importName: 'CreteRound',
+ fontFamily: 'Crete Round',
+ previewUrl: 'Crete+Round',
+ weights: ['400'],
+ },
+ {
+ importName: 'CrimsonPro',
+ fontFamily: 'Crimson Pro',
+ previewUrl: 'Crimson+Pro',
+ weights: ['200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'CrimsonText',
+ fontFamily: 'Crimson Text',
+ previewUrl: 'Crimson+Text',
+ weights: ['400', '600', '700'],
+ },
+ {
+ importName: 'Cuprum',
+ fontFamily: 'Cuprum',
+ previewUrl: 'Cuprum',
+ weights: ['400', '500', '600', '700'],
+ },
+ {
+ importName: 'DMSans',
+ fontFamily: 'DM Sans',
+ previewUrl: 'DM+Sans',
+ weights: ['100', '200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'DMSerifDisplay',
+ fontFamily: 'DM Serif Display',
+ previewUrl: 'DM+Serif+Display',
+ weights: ['400'],
+ },
+ {
+ importName: 'DMSerifText',
+ fontFamily: 'DM Serif Text',
+ previewUrl: 'DM+Serif+Text',
+ weights: ['400'],
+ },
+ {
+ importName: 'DancingScript',
+ fontFamily: 'Dancing Script',
+ previewUrl: 'Dancing+Script',
+ weights: ['400', '500', '600', '700'],
+ },
+ {
+ importName: 'DidactGothic',
+ fontFamily: 'Didact Gothic',
+ previewUrl: 'Didact+Gothic',
+ weights: ['400'],
+ },
+ {
+ importName: 'Domine',
+ fontFamily: 'Domine',
+ previewUrl: 'Domine',
+ weights: ['400', '500', '600', '700'],
+ },
+ {
+ importName: 'Dosis',
+ fontFamily: 'Dosis',
+ previewUrl: 'Dosis',
+ weights: ['200', '300', '400', '500', '600', '700', '800'],
+ },
+ {
+ importName: 'EBGaramond',
+ fontFamily: 'EB Garamond',
+ previewUrl: 'EB+Garamond',
+ weights: ['400', '500', '600', '700', '800'],
+ },
+ {
+ importName: 'Eczar',
+ fontFamily: 'Eczar',
+ previewUrl: 'Eczar',
+ weights: ['400', '500', '600', '700', '800'],
+ },
+ {
+ importName: 'ElMessiri',
+ fontFamily: 'El Messiri',
+ previewUrl: 'El+Messiri',
+ weights: ['400', '500', '600', '700'],
+ },
+ {
+ importName: 'Electrolize',
+ fontFamily: 'Electrolize',
+ previewUrl: 'Electrolize',
+ weights: ['400'],
+ },
+ {
+ importName: 'EncodeSans',
+ fontFamily: 'Encode Sans',
+ previewUrl: 'Encode+Sans',
+ weights: ['100', '200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'EncodeSansCondensed',
+ fontFamily: 'Encode Sans Condensed',
+ previewUrl: 'Encode+Sans+Condensed',
+ weights: ['100', '200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'Exo',
+ fontFamily: 'Exo',
+ previewUrl: 'Exo',
+ weights: ['100', '200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'Exo2',
+ fontFamily: 'Exo Two',
+ previewUrl: 'Exo+2',
+ weights: ['100', '200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'Figtree',
+ fontFamily: 'Figtree',
+ previewUrl: 'Figtree',
+ weights: ['300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'FiraSans',
+ fontFamily: 'Fira Sans',
+ previewUrl: 'Fira+Sans',
+ weights: ['100', '200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'FiraSansCondensed',
+ fontFamily: 'Fira Sans Condensed',
+ previewUrl: 'Fira+Sans+Condensed',
+ weights: ['100', '200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'FjallaOne',
+ fontFamily: 'Fjalla One',
+ previewUrl: 'Fjalla+One',
+ weights: ['400'],
+ },
+ {
+ importName: 'FrancoisOne',
+ fontFamily: 'Francois One',
+ previewUrl: 'Francois+One',
+ weights: ['400'],
+ },
+ {
+ importName: 'FrankRuhlLibre',
+ fontFamily: 'Frank Ruhl Libre',
+ previewUrl: 'Frank+Ruhl+Libre',
+ weights: ['300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'Fraunces',
+ fontFamily: 'Fraunces',
+ previewUrl: 'Fraunces',
+ weights: ['100', '200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'Gelasio',
+ fontFamily: 'Gelasio',
+ previewUrl: 'Gelasio',
+ weights: ['400', '500', '600', '700'],
+ },
+ {
+ importName: 'GloriaHallelujah',
+ fontFamily: 'Gloria Hallelujah',
+ previewUrl: 'Gloria+Hallelujah',
+ weights: ['400'],
+ },
+ {
+ importName: 'GothicA1',
+ fontFamily: 'Gothic AOne',
+ previewUrl: 'Gothic+A1',
+ weights: ['100', '200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'GreatVibes',
+ fontFamily: 'Great Vibes',
+ previewUrl: 'Great+Vibes',
+ weights: ['400'],
+ },
+ {
+ importName: 'Gruppo',
+ fontFamily: 'Gruppo',
+ previewUrl: 'Gruppo',
+ weights: ['400'],
+ },
+ {
+ importName: 'Heebo',
+ fontFamily: 'Heebo',
+ previewUrl: 'Heebo',
+ weights: ['100', '200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'Hind',
+ fontFamily: 'Hind',
+ previewUrl: 'Hind',
+ weights: ['300', '400', '500', '600', '700'],
+ },
+ {
+ importName: 'HindMadurai',
+ fontFamily: 'Hind Madurai',
+ previewUrl: 'Hind+Madurai',
+ weights: ['300', '400', '500', '600', '700'],
+ },
+ {
+ importName: 'HindSiliguri',
+ fontFamily: 'Hind Siliguri',
+ previewUrl: 'Hind+Siliguri',
+ weights: ['300', '400', '500', '600', '700'],
+ },
+ {
+ importName: 'IBMPlexMono',
+ fontFamily: 'IBM Plex Mono',
+ previewUrl: 'IBM+Plex+Mono',
+ weights: ['100', '200', '300', '400', '500', '600', '700'],
+ },
+ {
+ importName: 'IBMPlexSans',
+ fontFamily: 'IBM Plex Sans',
+ previewUrl: 'IBM+Plex+Sans',
+ weights: ['100', '200', '300', '400', '500', '600', '700'],
+ },
+ {
+ importName: 'IBMPlexSansArabic',
+ fontFamily: 'IBM Plex Sans Arabic',
+ previewUrl: 'IBM+Plex+Sans+Arabic',
+ weights: ['100', '200', '300', '400', '500', '600', '700'],
+ },
+ {
+ importName: 'IBMPlexSansCondensed',
+ fontFamily: 'IBM Plex Sans Condensed',
+ previewUrl: 'IBM+Plex+Sans+Condensed',
+ weights: ['100', '200', '300', '400', '500', '600', '700'],
+ },
+ {
+ importName: 'IBMPlexSerif',
+ fontFamily: 'IBM Plex Serif',
+ previewUrl: 'IBM+Plex+Serif',
+ weights: ['100', '200', '300', '400', '500', '600', '700'],
+ },
+ {
+ importName: 'Inconsolata',
+ fontFamily: 'Inconsolata',
+ previewUrl: 'Inconsolata',
+ weights: ['200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'IndieFlower',
+ fontFamily: 'Indie Flower',
+ previewUrl: 'Indie+Flower',
+ weights: ['400'],
+ },
+ {
+ importName: 'Inter',
+ fontFamily: 'Inter',
+ previewUrl: 'Inter',
+ weights: ['100', '200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'InterTight',
+ fontFamily: 'Inter Tight',
+ previewUrl: 'Inter+Tight',
+ weights: ['100', '200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'JosefinSans',
+ fontFamily: 'Josefin Sans',
+ previewUrl: 'Josefin+Sans',
+ weights: ['100', '200', '300', '400', '500', '600', '700'],
+ },
+ {
+ importName: 'JosefinSlab',
+ fontFamily: 'Josefin Slab',
+ previewUrl: 'Josefin+Slab',
+ weights: ['100', '200', '300', '400', '500', '600', '700'],
+ },
+ {
+ importName: 'Jost',
+ fontFamily: 'Jost',
+ previewUrl: 'Jost',
+ weights: ['100', '200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'Kalam',
+ fontFamily: 'Kalam',
+ previewUrl: 'Kalam',
+ weights: ['300', '400', '700'],
+ },
+ {
+ importName: 'Kanit',
+ fontFamily: 'Kanit',
+ previewUrl: 'Kanit',
+ weights: ['100', '200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'Karla',
+ fontFamily: 'Karla',
+ previewUrl: 'Karla',
+ weights: ['200', '300', '400', '500', '600', '700', '800'],
+ },
+ {
+ importName: 'KaushanScript',
+ fontFamily: 'Kaushan Script',
+ previewUrl: 'Kaushan+Script',
+ weights: ['400'],
+ },
+ {
+ importName: 'Khand',
+ fontFamily: 'Khand',
+ previewUrl: 'Khand',
+ weights: ['300', '400', '500', '600', '700'],
+ },
+ {
+ importName: 'Lato',
+ fontFamily: 'Lato',
+ previewUrl: 'Lato',
+ weights: ['100', '300', '400', '700', '900'],
+ },
+ {
+ importName: 'LeagueSpartan',
+ fontFamily: 'League Spartan',
+ previewUrl: 'League+Spartan',
+ weights: ['100', '200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'Lexend',
+ fontFamily: 'Lexend',
+ previewUrl: 'Lexend',
+ weights: ['100', '200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'LexendDeca',
+ fontFamily: 'Lexend Deca',
+ previewUrl: 'Lexend+Deca',
+ weights: ['100', '200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'LibreBarcode39',
+ fontFamily: 'Libre Barcode ThreeNine',
+ previewUrl: 'Libre+Barcode+39',
+ weights: ['400'],
+ },
+ {
+ importName: 'LibreBaskerville',
+ fontFamily: 'Libre Baskerville',
+ previewUrl: 'Libre+Baskerville',
+ weights: ['400', '500', '600', '700'],
+ },
+ {
+ importName: 'LibreCaslonText',
+ fontFamily: 'Libre Caslon Text',
+ previewUrl: 'Libre+Caslon+Text',
+ weights: ['400', '700'],
+ },
+ {
+ importName: 'LibreFranklin',
+ fontFamily: 'Libre Franklin',
+ previewUrl: 'Libre+Franklin',
+ weights: ['100', '200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'LilitaOne',
+ fontFamily: 'Lilita One',
+ previewUrl: 'Lilita+One',
+ weights: ['400'],
+ },
+ {
+ importName: 'Lobster',
+ fontFamily: 'Lobster',
+ previewUrl: 'Lobster',
+ weights: ['400'],
+ },
+ {
+ importName: 'LobsterTwo',
+ fontFamily: 'Lobster Two',
+ previewUrl: 'Lobster+Two',
+ weights: ['400', '700'],
+ },
+ {
+ importName: 'Lora',
+ fontFamily: 'Lora',
+ previewUrl: 'Lora',
+ weights: ['400', '500', '600', '700'],
+ },
+ {
+ importName: 'LuckiestGuy',
+ fontFamily: 'Luckiest Guy',
+ previewUrl: 'Luckiest+Guy',
+ weights: ['400'],
+ },
+ {
+ importName: 'MPLUS1p',
+ fontFamily: 'M PLUS Onep',
+ previewUrl: 'M+PLUS+1p',
+ weights: ['100', '300', '400', '500', '700', '800', '900'],
+ },
+ {
+ importName: 'MPLUSRounded1c',
+ fontFamily: 'M PLUS Rounded Onec',
+ previewUrl: 'M+PLUS+Rounded+1c',
+ weights: ['100', '300', '400', '500', '700', '800', '900'],
+ },
+ {
+ importName: 'Macondo',
+ fontFamily: 'Macondo',
+ previewUrl: 'Macondo',
+ weights: ['400'],
+ },
+ {
+ importName: 'Manrope',
+ fontFamily: 'Manrope',
+ previewUrl: 'Manrope',
+ weights: ['200', '300', '400', '500', '600', '700', '800'],
+ },
+ {
+ importName: 'Marcellus',
+ fontFamily: 'Marcellus',
+ previewUrl: 'Marcellus',
+ weights: ['400'],
+ },
+ {
+ importName: 'Martel',
+ fontFamily: 'Martel',
+ previewUrl: 'Martel',
+ weights: ['200', '300', '400', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'Mate',
+ fontFamily: 'Mate',
+ previewUrl: 'Mate',
+ weights: ['400'],
+ },
+ {
+ importName: 'MateSC',
+ fontFamily: 'Mate SC',
+ previewUrl: 'Mate+SC',
+ weights: ['400'],
+ },
+ {
+ importName: 'MavenPro',
+ fontFamily: 'Maven Pro',
+ previewUrl: 'Maven+Pro',
+ weights: ['400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'Merienda',
+ fontFamily: 'Merienda',
+ previewUrl: 'Merienda',
+ weights: ['300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'Merriweather',
+ fontFamily: 'Merriweather',
+ previewUrl: 'Merriweather',
+ weights: ['300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'MerriweatherSans',
+ fontFamily: 'Merriweather Sans',
+ previewUrl: 'Merriweather+Sans',
+ weights: ['300', '400', '500', '600', '700', '800'],
+ },
+ {
+ importName: 'Montserrat',
+ fontFamily: 'Montserrat',
+ previewUrl: 'Montserrat',
+ weights: ['100', '200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'MontserratAlternates',
+ fontFamily: 'Montserrat Alternates',
+ previewUrl: 'Montserrat+Alternates',
+ weights: ['100', '200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'Mukta',
+ fontFamily: 'Mukta',
+ previewUrl: 'Mukta',
+ weights: ['200', '300', '400', '500', '600', '700', '800'],
+ },
+ {
+ importName: 'Mulish',
+ fontFamily: 'Mulish',
+ previewUrl: 'Mulish',
+ weights: ['200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'NanumGothic',
+ fontFamily: 'Nanum Gothic',
+ previewUrl: 'Nanum+Gothic',
+ weights: ['400', '700', '800'],
+ },
+ {
+ importName: 'NanumGothicCoding',
+ fontFamily: 'Nanum Gothic Coding',
+ previewUrl: 'Nanum+Gothic+Coding',
+ weights: ['400', '700'],
+ },
+ {
+ importName: 'NanumMyeongjo',
+ fontFamily: 'Nanum Myeongjo',
+ previewUrl: 'Nanum+Myeongjo',
+ weights: ['400', '700', '800'],
+ },
+ {
+ importName: 'Neuton',
+ fontFamily: 'Neuton',
+ previewUrl: 'Neuton',
+ weights: ['200', '300', '400', '700', '800'],
+ },
+ {
+ importName: 'NoticiaText',
+ fontFamily: 'Noticia Text',
+ previewUrl: 'Noticia+Text',
+ weights: ['400', '700'],
+ },
+ {
+ importName: 'NotoColorEmoji',
+ fontFamily: 'Noto Color Emoji',
+ previewUrl: 'Noto+Color+Emoji',
+ weights: ['400'],
+ },
+ {
+ importName: 'NotoKufiArabic',
+ fontFamily: 'Noto Kufi Arabic',
+ previewUrl: 'Noto+Kufi+Arabic',
+ weights: ['100', '200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'NotoNaskhArabic',
+ fontFamily: 'Noto Naskh Arabic',
+ previewUrl: 'Noto+Naskh+Arabic',
+ weights: ['400', '500', '600', '700'],
+ },
+ {
+ importName: 'NotoSans',
+ fontFamily: 'Noto Sans',
+ previewUrl: 'Noto+Sans',
+ weights: ['100', '200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'NotoSansArabic',
+ fontFamily: 'Noto Sans Arabic',
+ previewUrl: 'Noto+Sans+Arabic',
+ weights: ['100', '200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'NotoSansBengali',
+ fontFamily: 'Noto Sans Bengali',
+ previewUrl: 'Noto+Sans+Bengali',
+ weights: ['100', '200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'NotoSansDisplay',
+ fontFamily: 'Noto Sans Display',
+ previewUrl: 'Noto+Sans+Display',
+ weights: ['100', '200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'NotoSansHK',
+ fontFamily: 'Noto Sans HK',
+ previewUrl: 'Noto+Sans+HK',
+ weights: ['100', '200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'NotoSansJP',
+ fontFamily: 'Noto Sans JP',
+ previewUrl: 'Noto+Sans+JP',
+ weights: ['100', '200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'NotoSansKR',
+ fontFamily: 'Noto Sans KR',
+ previewUrl: 'Noto+Sans+KR',
+ weights: ['100', '200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'NotoSansMono',
+ fontFamily: 'Noto Sans Mono',
+ previewUrl: 'Noto+Sans+Mono',
+ weights: ['100', '200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'NotoSansSC',
+ fontFamily: 'Noto Sans SC',
+ previewUrl: 'Noto+Sans+SC',
+ weights: ['100', '200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'NotoSansTC',
+ fontFamily: 'Noto Sans TC',
+ previewUrl: 'Noto+Sans+TC',
+ weights: ['100', '200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'NotoSansThai',
+ fontFamily: 'Noto Sans Thai',
+ previewUrl: 'Noto+Sans+Thai',
+ weights: ['100', '200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'NotoSerif',
+ fontFamily: 'Noto Serif',
+ previewUrl: 'Noto+Serif',
+ weights: ['100', '200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'NotoSerifJP',
+ fontFamily: 'Noto Serif JP',
+ previewUrl: 'Noto+Serif+JP',
+ weights: ['200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'NotoSerifKR',
+ fontFamily: 'Noto Serif KR',
+ previewUrl: 'Noto+Serif+KR',
+ weights: ['200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'NotoSerifTC',
+ fontFamily: 'Noto Serif TC',
+ previewUrl: 'Noto+Serif+TC',
+ weights: ['200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'Nunito',
+ fontFamily: 'Nunito',
+ previewUrl: 'Nunito',
+ weights: ['200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'NunitoSans',
+ fontFamily: 'Nunito Sans',
+ previewUrl: 'Nunito+Sans',
+ weights: ['200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'OldStandardTT',
+ fontFamily: 'Old Standard TT',
+ previewUrl: 'Old+Standard+TT',
+ weights: ['400', '700'],
+ },
+ {
+ importName: 'OleoScript',
+ fontFamily: 'Oleo Script',
+ previewUrl: 'Oleo+Script',
+ weights: ['400', '700'],
+ },
+ {
+ importName: 'OpenSans',
+ fontFamily: 'Open Sans',
+ previewUrl: 'Open+Sans',
+ weights: ['300', '400', '500', '600', '700', '800'],
+ },
+ {
+ importName: 'Orbitron',
+ fontFamily: 'Orbitron',
+ previewUrl: 'Orbitron',
+ weights: ['400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'Oswald',
+ fontFamily: 'Oswald',
+ previewUrl: 'Oswald',
+ weights: ['200', '300', '400', '500', '600', '700'],
+ },
+ {
+ importName: 'Outfit',
+ fontFamily: 'Outfit',
+ previewUrl: 'Outfit',
+ weights: ['100', '200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'Overpass',
+ fontFamily: 'Overpass',
+ previewUrl: 'Overpass',
+ weights: ['100', '200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'Oxygen',
+ fontFamily: 'Oxygen',
+ previewUrl: 'Oxygen',
+ weights: ['300', '400', '700'],
+ },
+ {
+ importName: 'PTSans',
+ fontFamily: 'PT Sans',
+ previewUrl: 'PT+Sans',
+ weights: ['400', '700'],
+ },
+ {
+ importName: 'PTSansCaption',
+ fontFamily: 'PT Sans Caption',
+ previewUrl: 'PT+Sans+Caption',
+ weights: ['400', '700'],
+ },
+ {
+ importName: 'PTSansNarrow',
+ fontFamily: 'PT Sans Narrow',
+ previewUrl: 'PT+Sans+Narrow',
+ weights: ['400', '700'],
+ },
+ {
+ importName: 'PTSerif',
+ fontFamily: 'PT Serif',
+ previewUrl: 'PT+Serif',
+ weights: ['400', '700'],
+ },
+ {
+ importName: 'Pacifico',
+ fontFamily: 'Pacifico',
+ previewUrl: 'Pacifico',
+ weights: ['400'],
+ },
+ {
+ importName: 'PassionOne',
+ fontFamily: 'Passion One',
+ previewUrl: 'Passion+One',
+ weights: ['400', '700', '900'],
+ },
+ {
+ importName: 'PathwayGothicOne',
+ fontFamily: 'Pathway Gothic One',
+ previewUrl: 'Pathway+Gothic+One',
+ weights: ['400'],
+ },
+ {
+ importName: 'PatuaOne',
+ fontFamily: 'Patua One',
+ previewUrl: 'Patua+One',
+ weights: ['400'],
+ },
+ {
+ importName: 'PaytoneOne',
+ fontFamily: 'Paytone One',
+ previewUrl: 'Paytone+One',
+ weights: ['400'],
+ },
+ {
+ importName: 'PermanentMarker',
+ fontFamily: 'Permanent Marker',
+ previewUrl: 'Permanent+Marker',
+ weights: ['400'],
+ },
+ {
+ importName: 'Philosopher',
+ fontFamily: 'Philosopher',
+ previewUrl: 'Philosopher',
+ weights: ['400', '700'],
+ },
+ {
+ importName: 'Play',
+ fontFamily: 'Play',
+ previewUrl: 'Play',
+ weights: ['400', '700'],
+ },
+ {
+ importName: 'PlayfairDisplay',
+ fontFamily: 'Playfair Display',
+ previewUrl: 'Playfair+Display',
+ weights: ['400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'PlusJakartaSans',
+ fontFamily: 'Plus Jakarta Sans',
+ previewUrl: 'Plus+Jakarta+Sans',
+ weights: ['200', '300', '400', '500', '600', '700', '800'],
+ },
+ {
+ importName: 'Poppins',
+ fontFamily: 'Poppins',
+ previewUrl: 'Poppins',
+ weights: ['100', '200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'Prata',
+ fontFamily: 'Prata',
+ previewUrl: 'Prata',
+ weights: ['400'],
+ },
+ {
+ importName: 'Prompt',
+ fontFamily: 'Prompt',
+ previewUrl: 'Prompt',
+ weights: ['100', '200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'PublicSans',
+ fontFamily: 'Public Sans',
+ previewUrl: 'Public+Sans',
+ weights: ['100', '200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'Quattrocento',
+ fontFamily: 'Quattrocento',
+ previewUrl: 'Quattrocento',
+ weights: ['400', '700'],
+ },
+ {
+ importName: 'QuattrocentoSans',
+ fontFamily: 'Quattrocento Sans',
+ previewUrl: 'Quattrocento+Sans',
+ weights: ['400', '700'],
+ },
+ {
+ importName: 'Questrial',
+ fontFamily: 'Questrial',
+ previewUrl: 'Questrial',
+ weights: ['400'],
+ },
+ {
+ importName: 'Quicksand',
+ fontFamily: 'Quicksand',
+ previewUrl: 'Quicksand',
+ weights: ['300', '400', '500', '600', '700'],
+ },
+ {
+ importName: 'Rajdhani',
+ fontFamily: 'Rajdhani',
+ previewUrl: 'Rajdhani',
+ weights: ['300', '400', '500', '600', '700'],
+ },
+ {
+ importName: 'Raleway',
+ fontFamily: 'Raleway',
+ previewUrl: 'Raleway',
+ weights: ['100', '200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'ReadexPro',
+ fontFamily: 'Readex Pro',
+ previewUrl: 'Readex+Pro',
+ weights: ['200', '300', '400', '500', '600', '700'],
+ },
+ {
+ importName: 'RedHatDisplay',
+ fontFamily: 'Red Hat Display',
+ previewUrl: 'Red+Hat+Display',
+ weights: ['300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'Righteous',
+ fontFamily: 'Righteous',
+ previewUrl: 'Righteous',
+ weights: ['400'],
+ },
+ {
+ importName: 'Roboto',
+ fontFamily: 'Roboto',
+ previewUrl: 'Roboto',
+ weights: ['100', '200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'RobotoCondensed',
+ fontFamily: 'Roboto Condensed',
+ previewUrl: 'Roboto+Condensed',
+ weights: ['100', '200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'RobotoFlex',
+ fontFamily: 'Roboto Flex',
+ previewUrl: 'Roboto+Flex',
+ weights: ['400'],
+ },
+ {
+ importName: 'RobotoMono',
+ fontFamily: 'Roboto Mono',
+ previewUrl: 'Roboto+Mono',
+ weights: ['100', '200', '300', '400', '500', '600', '700'],
+ },
+ {
+ importName: 'RobotoSerif',
+ fontFamily: 'Roboto Serif',
+ previewUrl: 'Roboto+Serif',
+ weights: ['100', '200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'RobotoSlab',
+ fontFamily: 'Roboto Slab',
+ previewUrl: 'Roboto+Slab',
+ weights: ['100', '200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'Rokkitt',
+ fontFamily: 'Rokkitt',
+ previewUrl: 'Rokkitt',
+ weights: ['100', '200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'Rowdies',
+ fontFamily: 'Rowdies',
+ previewUrl: 'Rowdies',
+ weights: ['300', '400', '700'],
+ },
+ {
+ importName: 'Rubik',
+ fontFamily: 'Rubik',
+ previewUrl: 'Rubik',
+ weights: ['300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'RubikBubbles',
+ fontFamily: 'Rubik Bubbles',
+ previewUrl: 'Rubik+Bubbles',
+ weights: ['400'],
+ },
+ {
+ importName: 'RubikMonoOne',
+ fontFamily: 'Rubik Mono One',
+ previewUrl: 'Rubik+Mono+One',
+ weights: ['400'],
+ },
+ {
+ importName: 'RussoOne',
+ fontFamily: 'Russo One',
+ previewUrl: 'Russo+One',
+ weights: ['400'],
+ },
+ {
+ importName: 'Sacramento',
+ fontFamily: 'Sacramento',
+ previewUrl: 'Sacramento',
+ weights: ['400'],
+ },
+ {
+ importName: 'Saira',
+ fontFamily: 'Saira',
+ previewUrl: 'Saira',
+ weights: ['100', '200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'SairaCondensed',
+ fontFamily: 'Saira Condensed',
+ previewUrl: 'Saira+Condensed',
+ weights: ['100', '200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'Sarabun',
+ fontFamily: 'Sarabun',
+ previewUrl: 'Sarabun',
+ weights: ['100', '200', '300', '400', '500', '600', '700', '800'],
+ },
+ {
+ importName: 'Satisfy',
+ fontFamily: 'Satisfy',
+ previewUrl: 'Satisfy',
+ weights: ['400'],
+ },
+ {
+ importName: 'SawarabiGothic',
+ fontFamily: 'Sawarabi Gothic',
+ previewUrl: 'Sawarabi+Gothic',
+ weights: ['400'],
+ },
+ {
+ importName: 'SawarabiMincho',
+ fontFamily: 'Sawarabi Mincho',
+ previewUrl: 'Sawarabi+Mincho',
+ weights: ['400'],
+ },
+ {
+ importName: 'Sen',
+ fontFamily: 'Sen',
+ previewUrl: 'Sen',
+ weights: ['400', '500', '600', '700', '800'],
+ },
+ {
+ importName: 'ShadowsIntoLight',
+ fontFamily: 'Shadows Into Light',
+ previewUrl: 'Shadows+Into+Light',
+ weights: ['400'],
+ },
+ {
+ importName: 'Signika',
+ fontFamily: 'Signika',
+ previewUrl: 'Signika',
+ weights: ['300', '400', '500', '600', '700'],
+ },
+ {
+ importName: 'SignikaNegative',
+ fontFamily: 'Signika Negative',
+ previewUrl: 'Signika+Negative',
+ weights: ['300', '400', '500', '600', '700'],
+ },
+ {
+ importName: 'Silkscreen',
+ fontFamily: 'Silkscreen',
+ previewUrl: 'Silkscreen',
+ weights: ['400', '700'],
+ },
+ {
+ importName: 'SixCaps',
+ fontFamily: 'Six Caps',
+ previewUrl: 'Six+Caps',
+ weights: ['400'],
+ },
+ {
+ importName: 'Slabo27px',
+ fontFamily: 'Slabo TwoSevenpx',
+ previewUrl: 'Slabo+27px',
+ weights: ['400'],
+ },
+ {
+ importName: 'Sora',
+ fontFamily: 'Sora',
+ previewUrl: 'Sora',
+ weights: ['100', '200', '300', '400', '500', '600', '700', '800'],
+ },
+ {
+ importName: 'SourceCodePro',
+ fontFamily: 'Source Code Pro',
+ previewUrl: 'Source+Code+Pro',
+ weights: ['200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'SourceSans3',
+ fontFamily: 'Source Sans Three',
+ previewUrl: 'Source+Sans+3',
+ weights: ['200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'SourceSerif4',
+ fontFamily: 'Source Serif Four',
+ previewUrl: 'Source+Serif+4',
+ weights: ['200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'SpaceGrotesk',
+ fontFamily: 'Space Grotesk',
+ previewUrl: 'Space+Grotesk',
+ weights: ['300', '400', '500', '600', '700'],
+ },
+ {
+ importName: 'SpaceMono',
+ fontFamily: 'Space Mono',
+ previewUrl: 'Space+Mono',
+ weights: ['400', '700'],
+ },
+ {
+ importName: 'SpecialElite',
+ fontFamily: 'Special Elite',
+ previewUrl: 'Special+Elite',
+ weights: ['400'],
+ },
+ {
+ importName: 'Spectral',
+ fontFamily: 'Spectral',
+ previewUrl: 'Spectral',
+ weights: ['200', '300', '400', '500', '600', '700', '800'],
+ },
+ {
+ importName: 'Tajawal',
+ fontFamily: 'Tajawal',
+ previewUrl: 'Tajawal',
+ weights: ['200', '300', '400', '500', '700', '800', '900'],
+ },
+ {
+ importName: 'Tangerine',
+ fontFamily: 'Tangerine',
+ previewUrl: 'Tangerine',
+ weights: ['400', '700'],
+ },
+ {
+ importName: 'Teko',
+ fontFamily: 'Teko',
+ previewUrl: 'Teko',
+ weights: ['300', '400', '500', '600', '700'],
+ },
+ {
+ importName: 'Tinos',
+ fontFamily: 'Tinos',
+ previewUrl: 'Tinos',
+ weights: ['400', '700'],
+ },
+ {
+ importName: 'TitanOne',
+ fontFamily: 'Titan One',
+ previewUrl: 'Titan+One',
+ weights: ['400'],
+ },
+ {
+ importName: 'TitilliumWeb',
+ fontFamily: 'Titillium Web',
+ previewUrl: 'Titillium+Web',
+ weights: ['200', '300', '400', '600', '700', '900'],
+ },
+ {
+ importName: 'Ubuntu',
+ fontFamily: 'Ubuntu',
+ previewUrl: 'Ubuntu',
+ weights: ['300', '400', '500', '700'],
+ },
+ {
+ importName: 'UbuntuCondensed',
+ fontFamily: 'Ubuntu Condensed',
+ previewUrl: 'Ubuntu+Condensed',
+ weights: ['400'],
+ },
+ {
+ importName: 'UbuntuMono',
+ fontFamily: 'Ubuntu Mono',
+ previewUrl: 'Ubuntu+Mono',
+ weights: ['400', '700'],
+ },
+ {
+ importName: 'Unbounded',
+ fontFamily: 'Unbounded',
+ previewUrl: 'Unbounded',
+ weights: ['200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'Unna',
+ fontFamily: 'Unna',
+ previewUrl: 'Unna',
+ weights: ['400', '700'],
+ },
+ {
+ importName: 'Urbanist',
+ fontFamily: 'Urbanist',
+ previewUrl: 'Urbanist',
+ weights: ['100', '200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'VarelaRound',
+ fontFamily: 'Varela Round',
+ previewUrl: 'Varela+Round',
+ weights: ['400'],
+ },
+ {
+ importName: 'Vollkorn',
+ fontFamily: 'Vollkorn',
+ previewUrl: 'Vollkorn',
+ weights: ['400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'WorkSans',
+ fontFamily: 'Work Sans',
+ previewUrl: 'Work+Sans',
+ weights: ['100', '200', '300', '400', '500', '600', '700', '800', '900'],
+ },
+ {
+ importName: 'YanoneKaffeesatz',
+ fontFamily: 'Yanone Kaffeesatz',
+ previewUrl: 'Yanone+Kaffeesatz',
+ weights: ['200', '300', '400', '500', '600', '700'],
+ },
+ {
+ importName: 'Yantramanav',
+ fontFamily: 'Yantramanav',
+ previewUrl: 'Yantramanav',
+ weights: ['100', '300', '400', '500', '700', '900'],
+ },
+ {
+ importName: 'Yellowtail',
+ fontFamily: 'Yellowtail',
+ previewUrl: 'Yellowtail',
+ weights: ['400'],
+ },
+ {
+ importName: 'YesevaOne',
+ fontFamily: 'Yeseva One',
+ previewUrl: 'Yeseva+One',
+ weights: ['400'],
+ },
+ {
+ importName: 'ZenKakuGothicNew',
+ fontFamily: 'Zen Kaku Gothic New',
+ previewUrl: 'Zen+Kaku+Gothic+New',
+ weights: ['300', '400', '500', '700', '900'],
+ },
+ {
+ importName: 'Zeyada',
+ fontFamily: 'Zeyada',
+ previewUrl: 'Zeyada',
+ weights: ['400'],
+ },
+ {
+ importName: 'ZillaSlab',
+ fontFamily: 'Zilla Slab',
+ previewUrl: 'Zilla+Slab',
+ weights: ['300', '400', '500', '600', '700'],
+ },
+ {
+ importName: 'TikTokSans',
+ fontFamily: 'TikTok Sans',
+ previewUrl: 'TikTok+Sans',
+ weights: ['300', '400', '500', '600', '700', '800', '900'],
+ },
+];
diff --git a/packages/studio/src/components/Timeline/save-sequence-prop.ts b/packages/studio/src/components/Timeline/save-sequence-prop.ts
index 09eec8113a..bd8f58c3df 100644
--- a/packages/studio/src/components/Timeline/save-sequence-prop.ts
+++ b/packages/studio/src/components/Timeline/save-sequence-prop.ts
@@ -1,4 +1,7 @@
-import {optimisticUpdateForPropStatuses} from '@remotion/studio-shared';
+import {
+ optimisticUpdateForPropStatuses,
+ type SaveSequencePropSourceEdit,
+} from '@remotion/studio-shared';
import type {
CanUpdateSequencePropsResponse,
SequencePropsSubscriptionKey,
@@ -21,6 +24,7 @@ export type SaveSequencePropChange = {
value: unknown;
defaultValue: string | null;
schema: InteractivitySchema;
+ sourceEdit?: SaveSequencePropSourceEdit;
};
type SaveSequencePropsOptions = {
@@ -31,6 +35,14 @@ type SaveSequencePropsOptions = {
redoLabel: string;
};
+const serializeSequencePropValue = (value: unknown) => {
+ if (value === undefined) {
+ return {type: 'undefined' as const};
+ }
+
+ return {type: 'json' as const, serialized: JSON.stringify(value)};
+};
+
export const saveSequenceProps = ({
changes,
setPropStatuses,
@@ -66,9 +78,10 @@ export const saveSequenceProps = ({
fileName: change.fileName,
nodePath: change.nodePath,
key: change.fieldKey,
- value: JSON.stringify(change.value),
+ value: serializeSequencePropValue(change.value),
defaultValue: change.defaultValue,
schema: change.schema,
+ sourceEdit: change.sourceEdit ?? null,
},
],
clientId,
@@ -97,9 +110,10 @@ export const saveSequenceProps = ({
fileName: change.fileName,
nodePath: change.nodePath,
key: change.fieldKey,
- value: JSON.stringify(change.value),
+ value: serializeSequencePropValue(change.value),
defaultValue: change.defaultValue,
schema: change.schema,
+ sourceEdit: change.sourceEdit ?? null,
};
}),
clientId,
diff --git a/packages/studio/src/helpers/timeline-layout.ts b/packages/studio/src/helpers/timeline-layout.ts
index e1961e694d..b958b8da15 100644
--- a/packages/studio/src/helpers/timeline-layout.ts
+++ b/packages/studio/src/helpers/timeline-layout.ts
@@ -10,6 +10,7 @@ import {
type PropStatuses,
type SchemaFieldInfo,
type SequenceControls,
+ type SaveSequencePropSourceEdit,
} from '@remotion/studio-shared';
import type {
GetDragOverrides,
@@ -48,7 +49,14 @@ export const TIMELINE_TRACK_EXPANDED_HEIGHT = 100;
export const TREE_GROUP_ROW_HEIGHT = 22;
export const EXPANDED_SECTION_PADDING_RIGHT = 10;
-export type TimelineFieldOnSave = (value: unknown) => Promise<void>;
+export type TimelineFieldOnSave = (
+ value: unknown,
+ options?: {
+ // Extra source-code transformation applied atomically with this value save.
+ // Used by Google Font selection to insert @remotion/google-fonts imports/loadFont().
+ sourceEdit?: SaveSequencePropSourceEdit;
+ },
+) => Promise<void>;
export type TimelineFieldOnDragValueChange = (value: unknown) => void;
export type TimelineEffectGroupInfo = {