$registered_webfonts = array
();
/**
* Gets the webfonts from theme.json.
*
* @since 6.0.0
*
* @return array Array of defined webfonts.
*/
$fn_get_webfonts_from_theme_json =
static function() { // Get settings from theme.json.
$settings = WP_Theme_JSON_Resolver::
get_merged_data()->
get_settings();
// If in the editor, add webfonts defined in variations.
if ( is_admin() || ( defined( 'REST_REQUEST'
) && REST_REQUEST
) ) { $variations = WP_Theme_JSON_Resolver::
get_style_variations();
foreach ( $variations as $variation ) { // Skip if fontFamilies are not defined in the variation.
if ( empty( $variation['settings'
]['typography'
]['fontFamilies'
] ) ) { continue;
} // Initialize the array structure.