Title: wp_print_font_faces
Published: November 8, 2023
Last modified: August 20, 2026

---

# wp_print_font_faces( array[][] $fonts = array() )

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/wp_print_font_faces/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/functions/wp_print_font_faces/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/wp_print_font_faces/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/wp_print_font_faces/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/functions/wp_print_font_faces/?output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/functions/wp_print_font_faces/?output_format=md#wp--skip-link--target)

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

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/wp_print_font_faces/?output_format=md#parameters)󠁿

 `$fonts`array[][]optional

The font-families and their font faces.

 * `...$0` array
 *  An indexed or associative (keyed by font-family) array of font variations for
   this font-family.
    Each font face has the following structure.
    - `...$0` array
    -  The font face properties.
       * `font-family` string
       * The font-family property.
       * `src` string|string[]
       * The URL(s) to each resource containing the font data.
       * `font-style` string
       * Optional. The font-style property. Default `'normal'`.
       * `font-weight` string
       * Optional. The font-weight property. Default `'400'`.
       * `font-display` string
       * Optional. The font-display property. Default `'fallback'`.
       * `ascent-override` string
       * Optional. The ascent-override property.
       * `descent-override` string
       * Optional. The descent-override property.
       * `font-stretch` string
       * Optional. The font-stretch property.
       * `font-variant` string
       * Optional. The font-variant property.
       * `font-feature-settings` string
       * Optional. The font-feature-settings property.
       * `font-variation-settings` string
       * Optional. The font-variation-settings property.
       * `line-gap-override` string
       * Optional. The line-gap-override property.
       * `size-adjust` string
       * Optional. The size-adjust property.
       * `unicode-range` string
       * Optional. The unicode-range property.
          }
 * Default:`array()`

## 󠀁[Source](https://developer.wordpress.org/reference/functions/wp_print_font_faces/?output_format=md#source)󠁿

    ```php
    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](https://developer.wordpress.org/reference/files/wp-includes/fonts.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-includes/fonts.php#L43)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/fonts.php#L43-L55)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/wp_print_font_faces/?output_format=md#related)󠁿

| Uses | Description | 
| [WP_Font_Face_Resolver::get_fonts_from_theme_json()](https://developer.wordpress.org/reference/classes/wp_font_face_resolver/get_fonts_from_theme_json/)`wp-includes/fonts/class-wp-font-face-resolver.php` |

Gets fonts defined in theme.json.

  | 
| [WP_Font_Face::generate_and_print()](https://developer.wordpress.org/reference/classes/wp_font_face/generate_and_print/)`wp-includes/fonts/class-wp-font-face.php` |

Generates and prints the `@font-face` styles for the given fonts.

  |

| Used by | Description | 
| [wp_print_font_faces_from_style_variations()](https://developer.wordpress.org/reference/functions/wp_print_font_faces_from_style_variations/)`wp-includes/fonts.php` |

Generates and prints font-face styles defined in the theme style variations.

  | 
| [_wp_get_iframed_editor_assets()](https://developer.wordpress.org/reference/functions/_wp_get_iframed_editor_assets/)`wp-includes/block-editor.php` |

Collect the block editor assets that need to be loaded into the editor’s iframe.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/wp_print_font_faces/?output_format=md#changelog)󠁿

| Version | Description | 
| [6.4.0](https://developer.wordpress.org/reference/since/6.4.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/functions/wp_print_font_faces/?output_format=md#user-contributed-notes)󠁿

 1.  [Skip to note 2 content](https://developer.wordpress.org/reference/functions/wp_print_font_faces/?output_format=md#comment-content-6768)
 2.   [Rodrigo Vieira Eufrasio da Silva](https://profiles.wordpress.org/rodrigomct/)
    [  3 years ago  ](https://developer.wordpress.org/reference/functions/wp_print_font_faces/#comment-6768)
 3. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_print_font_faces%2F%23comment-6768)
    Vote results for this note: -1[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_print_font_faces%2F%23comment-6768)
 4.     ```php
        $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 );
        ```
    
 5.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_print_font_faces%2F%3Freplytocom%3D6768%23feedback-editor-6768)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_print_font_faces%2F)
before being able to contribute a note or feedback.