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:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user