Skip to content

Commit

Permalink
Fix the install of system fonts from a font collection
Browse files Browse the repository at this point in the history
  • Loading branch information
matiasbenedetto authored and jffng committed Sep 26, 2023
1 parent 9a34f30 commit 15e2929
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 15e2929

Please sign in to comment.