wp_print_font_faces()
Проверено на WordPress 6.9, обновлено Источник: WordPress Developer Resources.
Сигнатура
wp_print_font_faces( array[][] $fonts = array() )
Описание
Генерирует и выводит стили font-face для указанных шрифтов или шрифтов из theme.json.
Параметры
$fonts
array[][]
необязательный
= array()
...$0array An indexed or associative (keyed by font-family) array of font variations for this font-family.
Each font face has the following structure....$0array The font face properties.font-familystringThe font-family property.srcstring|string[]The URL(s) to each resource containing the font data.font-stylestringOptional. The font-style property. Default'normal'.font-weightstringOptional. The font-weight property. Default'400'.font-displaystringOptional. The font-display property. Default'fallback'.ascent-overridestringOptional. The ascent-override property.descent-overridestringOptional. The descent-override property.font-stretchstringOptional. The font-stretch property.font-variantstringOptional. The font-variant property.font-feature-settingsstringOptional. The font-feature-settings property.font-variation-settingsstringOptional. The font-variation-settings property.line-gap-overridestringOptional. The line-gap-override property.size-adjuststringOptional. The size-adjust property.unicode-rangestringOptional. The unicode-range property.
}
Default:
Sourcearray()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 ); }View all references View on Trac View on GitHub
RelatedUses Description WP_Font_Face_Resolver::get_fonts_from_theme_json() wp-includes/fonts/class-wp-font-face-resolver.phpGets fonts defined in theme.json.
WP_Font_Face::generate_and_print() wp-includes/fonts/class-wp-font-face.phpGenerates and prints the
@font-facestyles for the given fonts.
ChangelogUsed by Description wp_print_font_faces_from_style_variations() wp-includes/fonts.phpGenerates and prints font-face styles defined the the theme style variations.
_wp_get_iframed_editor_assets() wp-includes/block-editor.phpCollect the block editor assets that need to be loaded into the editor’s iframe.
User Contributed NotesVersion Description 6.4.0 Introduced. -
Skip to note 2 content
Rodrigo Vieira Eufrasio da Silva
3 years ago
You must log in to vote on the helpfulness of this noteVote results for this note: -1You must log in to vote on the helpfulness of this note
Log in to add feedback$fonts = array( 'font-family-1' => array( 'variations' => array( 'font-variation-1' => array( 'font-family' => 'Font Family 1', 'src' => array( 'url-to-font-variation-1.woff', 'url-to-font-variation-1.woff2', ), 'font-style' => 'italic', 'font-weight' => '700', // Other optional properties... ), // Add more variations if necessary... ), ), 'font-family-2' => array( 'variations' => array( 'font-variation-2' => array( 'font-family' => 'Font Family 2', 'src' => array( 'url-to-font-variation-2.woff', 'url-to-font-variation-2.woff2', ), // Outras propriedades opcionais... ), // Add more variations if necessary... ), ), // Add more font families if necessary... ); wp_print_font_faces( $fonts );
You must log in before being able to contribute a note or feedback.
Исходный код
wp-includes/fonts.php:43
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 );
}
История изменений
| Версия | Описание |
|---|---|
| 6.4.0 | Introduced. |

