Skip to content

Commit c449b0d

Browse files
committed
Ensure fonts are installed in the library before including them in the custom fonts declaration.
1 parent 842f754 commit c449b0d

File tree

1 file changed

+7
-4
lines changed
  • packages/edit-site/src/components/global-styles/font-library-modal

1 file changed

+7
-4
lines changed

packages/edit-site/src/components/global-styles/font-library-modal/context.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,15 +101,18 @@ function FontLibraryProvider( { children } ) {
101101
.sort( ( a, b ) => a.name.localeCompare( b.name ) )
102102
: [];
103103

104-
const customFonts = fontFamilies?.custom
105-
? fontFamilies.custom
104+
const baseCustomFonts = libraryFonts
105+
? libraryFonts
106106
.map( ( f ) => setUIValuesNeeded( f, { source: 'custom' } ) )
107107
.sort( ( a, b ) => a.name.localeCompare( b.name ) )
108108
: [];
109109

110-
const baseCustomFonts = libraryFonts
111-
? libraryFonts
110+
const customFonts = fontFamilies?.custom
111+
? fontFamilies.custom
112112
.map( ( f ) => setUIValuesNeeded( f, { source: 'custom' } ) )
113+
.filter( ( f ) =>
114+
baseCustomFonts.some( ( bf ) => bf.slug === f.slug )
115+
) // Ensures that the font actually exists in the library.
113116
.sort( ( a, b ) => a.name.localeCompare( b.name ) )
114117
: [];
115118

0 commit comments

Comments
 (0)