wp-includes/fonts/class-wp-font-face-resolver.php:19The Font Face Resolver abstracts the processing of different data sources (such as theme.json) for processing within the Font Face.
class WP_Font_Face_Resolver { /** * Gets fonts defined in theme.json. * * @since 6.4.0 * * @return array Returns the font-families, each with their font-face variations. */ public static function get_fonts_from_theme_json() { $settings = wp_get_global_settings(); // Bail out early if there are no font settings. if ( empty( $settings['typography']['fontFamilies'] ) ) { return array(); } return static::parse_settings( $settings ); } /** * Gets fonts defined in style variations. * * @since 6.7.0 * * @return array Returns an array of font-families. */ public static function get_fonts_from_style_variations() { $variations = WP_Theme_JSON_Resolver::get_style_variations(); $fonts = array(); if ( empty( $variations ) ) { return $fonts; } foreach ( $variations as $variation ) { if ( ! empty( $variation['settings']['typography']['fontFamilies']['theme'] ) ) { $fonts = array_merge( $fonts, $variation['settings']['typography']['fontFamilies']['theme'] ); } } $settings = array( 'typography' => array( 'fontFamilies' => array( 'theme' => $fonts, ), ), ); return static::parse_settings( $settings ); } /** * Parse theme.json settings to extract font definitions with variations grouped by font-family. * * @since 6.4.0 * * @param array $settings Font settings to parse. * @return array Returns an array of fonts, grouped by font-family. */ private static function parse_settings( array $settings ) { $fonts = array(); foreach ( $settings['typography']['fontFamilies'] as $font_families ) { foreach ( $font_families as $definition ) { // Skip if "fontFace" is not defined, meaning there are no variations. if ( empty( $definition['fontFace'] ) ) { continue; } // Skip if "fontFamily" is not defined. if ( empty( $definition['fontFamily'] ) ) { continue; } $font_family_name = static::maybe_parse_name_from_comma_separated_list( $definition['fontFamily'] ); // Skip if no font family is defined. if ( empty( $font_family_name ) ) {Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
src/wp-includes/fonts/class-wp-font-face-resolver.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.