From c29b095e762836e47df9080d670c2f6570d6cd12 Mon Sep 17 00:00:00 2001 From: Tonya Mork Date: Thu, 31 Aug 2023 21:47:40 +0000 Subject: [PATCH] Introduce font-face styles generator and printer. Introducing Font Face, a server-side `@font-face` styles generator and printer. tl;dr: * Introduces Font Face. * Deprecates `_wp_theme_json_webfonts_handler()`. **Introduce Font Face** From an array of fonts (i.e. each font-family and its font variations to be processed), it: 1. Validates each `font-face` declaration, i.e. the CSS property and value pairing. If validation fails, processing stops with no font-face styles printed. 3. Generates the `@font-face` CSS for each font-family. 4. Prints the CSS within a ` and open a + +CSS; + $this->expectOutputString( $expected_output ); + + wp_print_font_faces( $fonts ); + } + + public function test_should_print_fonts_in_merged_data() { + switch_theme( static::FONTS_THEME ); + + $expected = $this->get_expected_fonts_for_fonts_block_theme( 'font_face_styles' ); + $expected_output = $this->get_expected_styles_output( $expected ); + + $this->expectOutputString( $expected_output ); + wp_print_font_faces(); + } + + private function get_expected_styles_output( $styles ) { + $style_element = "\n"; + return sprintf( $style_element, $styles ); + } +} diff --git a/tests/phpunit/tests/theme/themeDir.php b/tests/phpunit/tests/theme/themeDir.php index ea721e5a4494c..73cf63539e58f 100644 --- a/tests/phpunit/tests/theme/themeDir.php +++ b/tests/phpunit/tests/theme/themeDir.php @@ -185,7 +185,7 @@ public function test_theme_list() { 'Block Theme [0.4.0]', 'Block Theme [1.0.0] in subdirectory', 'Block Theme Deprecated Path', - 'Webfonts theme', + 'Block Theme with defined Typography Fonts', 'Empty `fontFace` in theme.json - no webfonts defined', 'A theme with the Update URI header', );