{"record":{"id":"6243ff6e3339ae41","repo":"remotion-dev/remotion","slug":"loadfont-requires-an-object-as-its-argument-but","errorCode":null,"errorMessage":"loadFont() requires an object as its argument, but received ${typeof options === 'string' ? `\"${options}\"` : typeof options}. If you want to load a Google Font, use the @remotion/google-fonts package instead. See: https://www.remotion.dev/docs/google-fonts/load-font","messagePattern":"loadFont\\(\\) requires an object as its argument, but received (.+?)\"` : typeof options\\}\\. If you want to load a Google Font, use the @remotion/google-fonts package instead\\. See: https://www\\.remotion\\.dev/docs/google-fonts/load-font","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/fonts/src/load-font.ts","lineNumber":23,"sourceCode":"export type LoadFontOptions = {\n\tfamily: string;\n\turl: string;\n\tascentOverride?: string;\n\tdescentOverride?: string;\n\tdisplay?: 'auto' | 'block' | 'fallback' | 'optional' | 'swap';\n\tfeatureSettings?: string;\n\tlineGapOverride?: string;\n\tstretch?: string;\n\tstyle?: string;\n\tunicodeRange?: string;\n\tvariant?: string;\n\tweight?: string;\n\tformat?: FontFormat;\n};\n\nexport const loadFont = async (options: LoadFontOptions): Promise<void> => {\n\tif (typeof options !== 'object' || options === null) {\n\t\tthrow new TypeError(\n\t\t\t`loadFont() requires an object as its argument, but received ${typeof options === 'string' ? `\"${options}\"` : typeof options}. If you want to load a Google Font, use the @remotion/google-fonts package instead. See: https://www.remotion.dev/docs/google-fonts/load-font`,\n\t\t);\n\t}\n\n\tconst {\n\t\tfamily,\n\t\turl,\n\t\tascentOverride,\n\t\tdescentOverride,\n\t\tdisplay,\n\t\tfeatureSettings,\n\t\tlineGapOverride,\n\t\tstretch,\n\t\tstyle,\n\t\tunicodeRange,\n\t\tweight,\n\t\tformat,\n\t\tvariant,","sourceCodeStart":5,"sourceCodeEnd":41,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/fonts/src/load-font.ts#L5-L41","documentation":"The `loadFont` function requires an options object as its sole argument. If called with a string (e.g., just a URL), null, or any non-object value, it throws a TypeError directing you to use the correct options shape or `@remotion/google-fonts` for Google Fonts. This is the first validation check in the function.","triggerScenarios":"Calling `loadFont('https://example.com/font.woff2')` (string instead of object), `loadFont(null)`, `loadFont(undefined)`, or `loadFont(123)`. A common mistake is treating `loadFont` like a simple URL loader.","commonSituations":"New users expecting `loadFont` to accept a plain URL, migrating from a different font-loading API, or destructuring incorrectly so the wrong variable is passed.","solutions":["Pass an options object with at least `family` and `url`: `loadFont({family: 'MyFont', url: '...'})`.","For Google Fonts, use `@remotion/google-fonts` instead of `loadFont`.","Check that the argument is the options object, not a URL string."],"exampleFix":"// before\nloadFont('https://example.com/fonts/myfont.woff2');\n\n// after\nloadFont({\n  family: 'MyFont',\n  url: 'https://example.com/fonts/myfont.woff2',\n});","handlingStrategy":"type-guard","validationCode":"if (typeof options !== 'object' || options === null) {\n  throw new TypeError('loadFont requires an options object');\n}\nloadFont(options);","typeGuard":"const isLoadFontOptions = (v: unknown): v is Record<string, unknown> =>\n  typeof v === 'object' && v !== null;","tryCatchPattern":null,"preventionTips":["Always call loadFont with an object literal: loadFont({ family, url }).","Use the LoadFontOptions TypeScript type for compile-time checking.","For Google Fonts, use @remotion/google-fonts/loadFont instead."],"tags":["fonts","validation","typescript","load-font","api-misuse"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}