Skip to content

🎥 Make videos programmatically with React

better docs + troubleshooting guide

Jonny Burger5eaceba9a3b5
diff --git a/packages/docs/docs/layout-utils/best-practices.mdx b/packages/docs/docs/layout-utils/best-practices.mdx
index dba25ef0a5..7f0ff968a7 100644
--- a/packages/docs/docs/layout-utils/best-practices.mdx
+++ b/packages/docs/docs/layout-utils/best-practices.mdx
@@ -43,12 +43,16 @@ const MyComp: React.FC = () => {
};
```
-### Use the `validateFontIsLoaded` property<AvailableFrom v="4.0.136"/>
+### Use the `validateFontIsLoaded` option<AvailableFrom v="4.0.136"/>
Pass `validateFontIsLoaded: true` to any of [`measureText()`](/docs/layout-utils/measure-text), [`fitText()`](/docs/layout-utils/fit-text), and [`fillTextBox()`](/docs/layout-utils/fill-text-box) to validate that the font family you passed is actually loaded.
This will take a second measurement with the fallback font and if it produces the same measurements, it assumes the fallback font was used and will throw an error.
+:::note
+In Remotion v5, this will become the default.
+:::
+
## Match all font properties
When measuring text, ensure that all font properties match the ones you are going to use in your video.
diff --git a/packages/layout-utils/src/layouts/measure-text.ts b/packages/layout-utils/src/layouts/measure-text.ts
index 7dd96c72c2..55a0019ea3 100644
--- a/packages/layout-utils/src/layouts/measure-text.ts
+++ b/packages/layout-utils/src/layouts/measure-text.ts
@@ -111,10 +111,11 @@ export const measureText = ({
if (sameAsFallbackFont && computedFallback !== computedFontFamily) {
const err = [
- `Called measureText() with "fontFamily" ${JSON.stringify(
+ `Called measureText() with "fontFamily": ${JSON.stringify(
fontFamily,
)} but it looks like the font is not loaded at the time of calling.`,
`A measurement with the fallback font ${computedFallback} was taken and had the same dimensions, indicating that the browser used the fallback font.`,
+ 'See https://remotion.dev/docs/layout-utils/best-practices for best practices.',
];
throw new Error(err.join('\n'));
}