🎥 Make videos programmatically with React
validation
Jonny Burger88116c5b5457
diff --git a/packages/example/src/Title/index.tsx b/packages/example/src/Title/index.tsxindex ba3246ce33..e9473abf7b 100644--- a/packages/example/src/Title/index.tsx+++ b/packages/example/src/Title/index.tsx@@ -43,7 +43,7 @@ export const Title: React.FC<{};const {width, height} = measureText({text: `${line1} ${line2}`,- fontFamily: fontStyle.fontFamily,+ fontFamily: 'does not compute',fontSize: fontStyle.fontSize,});const box = fillTextBox({maxBoxWidth: 270, maxLines: 1});diff --git a/packages/layout-utils/src/layouts/measure-text.ts b/packages/layout-utils/src/layouts/measure-text.tsindex 8ecdb12ccf..6136858fa4 100644--- a/packages/layout-utils/src/layouts/measure-text.ts+++ b/packages/layout-utils/src/layouts/measure-text.ts@@ -53,11 +53,13 @@ const takeMeasurement = ({node.innerText = text;document.body.appendChild(node);+ const computedFontFamily = window.getComputedStyle(node).fontFamily;const boundingBox = node.getBoundingClientRect();document.body.removeChild(node);+return {boundingBox,- computedFontFamily: window.getComputedStyle(node).fontFamily,+ computedFontFamily,};};@@ -88,7 +90,7 @@ export const measureText = ({boundingBox: boundingBoxOfFallbackFont,computedFontFamily: computedFallback,} = takeMeasurement({- fontFamily,+ fontFamily: null,fontSize,text,fontVariantNumeric,@@ -100,9 +102,13 @@ export const measureText = ({boundingBox.height === boundingBoxOfFallbackFont.height &&boundingBox.width === boundingBoxOfFallbackFont.width;+ console.log({sameAsFallbackFont, computedFallback, computedFontFamily});+if (sameAsFallbackFont && computedFallback !== computedFontFamily) {const err = [- `Called measureText() with "fontFamily" ${fontFamily} but it looks like the font is not loaded at the time of calling.`,+ `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.`,];throw new Error(err.join('\n'));