Skip to content
12 changes: 11 additions & 1 deletion packages/edit-site/src/components/global-styles/font-families.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ const { useGlobalSetting } = unlock( blockEditorPrivateApis );
function FontFamilies() {
const { modalTabOpen, setModalTabOpen } = useContext( FontLibraryContext );
const [ fontFamilies ] = useGlobalSetting( 'typography.fontFamilies' );
const [ baseFontFamilies ] = useGlobalSetting(
'typography.fontFamilies',
undefined,
'base'
);
const themeFonts = fontFamilies?.theme
? fontFamilies.theme
.map( ( f ) => setUIValuesNeeded( f, { source: 'theme' } ) )
Expand All @@ -39,6 +44,7 @@ function FontFamilies() {
.sort( ( a, b ) => a.name.localeCompare( b.name ) )
: [];
const hasFonts = 0 < customFonts.length || 0 < themeFonts.length;
const hasBaseFonts = baseFontFamilies?.theme?.length > 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This conditional is not enough to know if there are fonts installed but not activated. Currenty, this only checks if the theme provides fonts that are not activated but it doesn't check if there are custom fonts installed but they are not activated.

Copy link
Member Author

@akasunil akasunil Jul 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right; it's likely possible that the only available fonts are custom ones that haven't been activated. I'll update the PR


return (
<>
Expand Down Expand Up @@ -81,7 +87,11 @@ function FontFamilies() {
{ ! hasFonts && (
<VStack>
<Subtitle level={ 3 }>{ __( 'Fonts' ) }</Subtitle>
<Text as="p">{ __( 'No fonts installed.' ) }</Text>
<Text as="p">
{ hasBaseFonts
? __( 'No fonts activated.' )
: __( 'No fonts installed.' ) }
</Text>
</VStack>
) }
<Button
Expand Down