wp_print_font_faces()WP 6.4.0

Generates and prints font-face styles for given fonts or theme.json fonts.

Хуков нет.

Возвращает

null. Ничего (null).

Использование

wp_print_font_faces( $fonts );
$fonts(array[][])

The font-families and their font faces.

По умолчанию: empty array

  • ...$0(массив)
    An indexed or associative (keyed by font-family) array of font variations for this font-family. Each font face has the following structure.

    • ...$0(массив)
      The font face properties.

      • font-family(строка)
        The font-family property.

      • src(строка|string[])
        The URL(s) to each resource containing the font data.

      • font-style(строка)
        Optional. The font-style property.
        По умолчанию: 'normal'

      • font-weight(строка)
        Optional. The font-weight property.
        По умолчанию: '400'

      • font-display(строка)
        Optional. The font-display property.
        По умолчанию: 'fallback'

      • ascent-override(строка)
        Optional. The ascent-override property.

      • descent-override(строка)
        Optional. The descent-override property.

      • font-stretch(строка)
        Optional. The font-stretch property.

      • font-variant(строка)
        Optional. The font-variant property.

      • font-feature-settings(строка)
        Optional. The font-feature-settings property.

      • font-variation-settings(строка)
        Optional. The font-variation-settings property.

      • line-gap-override(строка)
        Optional. The line-gap-override property.

      • size-adjust(строка)
        Optional. The size-adjust property.

      • unicode-range(строка)
        Optional. The unicode-range property.

Список изменений

С версии 6.4.0 Введена.

Код wp_print_font_faces() WP 6.7.1

function wp_print_font_faces( $fonts = array() ) {

	if ( empty( $fonts ) ) {
		$fonts = WP_Font_Face_Resolver::get_fonts_from_theme_json();
	}

	if ( empty( $fonts ) ) {
		return;
	}

	$wp_font_face = new WP_Font_Face();
	$wp_font_face->generate_and_print( $fonts );
}