W3cubDocs

/WordPress

WP_Font_Face::get_css( array[] $font_faces ): string

Gets the @font-face CSS styles for locally-hosted font files.

Description

This method does the following processing tasks:

  1. Orchestrates an optimized src (with format) for browser support.
  2. Generates the @font-face for all its fonts.

Parameters

$font_facesarray[]required
The font-faces to generate @font-face CSS styles.

Return

string The @font-face CSS styles.

Source

private function get_css( $font_faces ) {
	$css = '';

	foreach ( $font_faces as $font_face ) {
			// Order the font's `src` items to optimize for browser support.
			$font_face = $this->order_src( $font_face );

			// Build the @font-face CSS for this font.
			$css .= '@font-face{' . $this->build_font_face_css( $font_face ) . '}' . "\n";
	}

	// Don't print the last newline character.
	return rtrim( $css, "\n" );
}

Changelog

Version Description
6.4.0 Introduced.

© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_font_face/get_css