Parse theme.json settings to extract font definitions with variations grouped by font-family.
Parameters
$settings
arrayrequired- Font settings to parse.
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
Version | Description |
---|---|
6.4.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.