WP_Font_Face_Resolver::parse_settings( array $settings ): array

In this article

This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

Parse theme.json settings to extract font definitions with variations grouped by font-family.

Parameters

$settingsarrayrequired
Font settings to parse.

Return

array Returns an array of fonts, grouped by font-family.

Source

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 ) ) {
				continue;
			}

			$fonts[] = static::convert_font_face_properties( $definition['fontFace'], $font_family_name );
		}
	}

	return $fonts;
}

Changelog

VersionDescription
6.4.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.