Skip to content

Commit

Permalink
Fix the install of system fonts from a font collection (#54713)
Browse files Browse the repository at this point in the history
  • Loading branch information
matiasbenedetto committed Sep 27, 2023
1 parent be69ef4 commit cf0f7a0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function CollectionFontDetails( {
handleToggleVariant={ handleToggleVariant }
selected={ isFontFontFaceInOutline(
font.slug,
face,
font.fontFace ? face : null, // If the font has no fontFace, we want to check if the font is in the outline
fontToInstallOutline
) }
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,14 +281,16 @@ function FontLibraryProvider( { children } ) {
} );
// Add custom fonts to the browser.
fontsToAdd.forEach( ( font ) => {
font.fontFace.forEach( ( face ) => {
// Load font faces just in the iframe because they already are in the document.
loadFontFaceInBrowser(
face,
getDisplaySrcFromFontFace( face.src ),
'iframe'
);
} );
if ( font.fontFace ) {
font.fontFace.forEach( ( face ) => {
// Load font faces just in the iframe because they already are in the document.
loadFontFaceInBrowser(
face,
getDisplaySrcFromFontFace( face.src ),
'iframe'
);
} );
}
} );
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ export function getFontsOutline( fonts ) {
}

export function isFontFontFaceInOutline( slug, face, outline ) {
return (
outline[ slug ]?.[ `${ face.fontStyle }-${ face.fontWeight }` ] || false
);
if ( ! face ) {
return !! outline[ slug ];
}
return !! outline[ slug ]?.[ `${ face.fontStyle }-${ face.fontWeight }` ];
}

0 comments on commit cf0f7a0

Please sign in to comment.