Normalize extracted theme fonts before loading them

Ensure fonts are properly trimmed and stripped of quotes to maintain consistency and avoid potential loading issues.

The default fonts defined by MUI e.g., are set as "\"Roboto\", \"Helvetica\", \"Arial\", sans-serif" which lead to an invalid font request.

Fixes #1012
This commit is contained in:
schroda
2025-09-23 22:14:14 +02:00
parent d625a7b3dc
commit 0706e4671f

View File

@@ -52,7 +52,9 @@ const getFontsFromTheme = (obj: Record<string, any>, fonts: string[] = []): stri
const isValidFontProperty = propertyName === 'fontFamily' && propertyType === 'string';
if (isValidFontProperty) {
tmpFonts.push(propertyValue as string);
const detectedFonts = propertyValue.split(',') as string[];
const normalizedFonts = detectedFonts.map((detectedFont) => detectedFont.replace(/"/g, '').trim());
tmpFonts.push(...normalizedFonts);
// eslint-disable-next-line no-continue
continue;
}