From 3822e504f1183097ea024cff33c701b1f82e6f1e Mon Sep 17 00:00:00 2001 From: Mikael Korpela Date: Mon, 5 Dec 2022 17:16:36 +0200 Subject: [PATCH 1/3] [not verified] Add fonts --- .../plugins/jetpack/modules/google-fonts.php | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/projects/plugins/jetpack/modules/google-fonts.php b/projects/plugins/jetpack/modules/google-fonts.php index 501cc9bdbfb5..644646b7f1f7 100644 --- a/projects/plugins/jetpack/modules/google-fonts.php +++ b/projects/plugins/jetpack/modules/google-fonts.php @@ -56,6 +56,25 @@ 'Work Sans', ); +const JETPACK_GOOGLE_FONTS_I18N = array( + 'Alexandria', // Arabic + 'IBM Plex Sans Arabic', + 'Noto Sans Hebrew', + 'Noto Sans HK', // Noto Sans Hong Kong @TODO: should be HKC? + 'Noto Sans JP', // Japanese + 'Noto Sans KR', // Korean + 'Noto Sans SC', // Simplified Chinese + 'Noto Sans TC', // Traditional Chinese + 'Noto Sans Telugu', + 'Noto Serif Hebrew', + 'Noto Serif HK', // Noto Sans Hong Kong @TODO: should be HKC? + 'Noto Serif JP', // Japanese + 'Noto Serif KR', // Korean + 'Noto Serif SC', // Simplified Chinese + 'Noto Serif TC', // Traditional Chinese + // 'Mukta (Devanagari)' @TODO: not on Google Fonts? +); + /** * Register a curated selection of Google Fonts. * @@ -68,6 +87,10 @@ function jetpack_add_google_fonts_provider() { wp_register_webfont_provider( 'jetpack-google-fonts', '\Automattic\Jetpack\Fonts\Google_Fonts_Provider' ); + // @TODO: we need to modify some of the font names and + // Ensure i18n specific fonts are at the end of the list + $fonts_list = array_merge( JETPACK_GOOGLE_FONTS_I18N, JETPACK_GOOGLE_FONTS_I18N ); + /** * Curated list of Google Fonts. * @@ -77,7 +100,7 @@ function jetpack_add_google_fonts_provider() { * * @param array $fonts_to_register Array of Google Font names to register. */ - $fonts_to_register = apply_filters( 'jetpack_google_fonts_list', JETPACK_GOOGLE_FONTS_LIST ); + $fonts_to_register = apply_filters( 'jetpack_google_fonts_list', $fonts_list ); foreach ( $fonts_to_register as $font_family ) { wp_register_webfonts( From cb9049016deb6dc89b1158165f019aa8e8a0727f Mon Sep 17 00:00:00 2001 From: Mikael Korpela Date: Mon, 5 Dec 2022 17:17:49 +0200 Subject: [PATCH 2/3] [not verified] changelog --- projects/plugins/jetpack/changelog/update-fonts-i18n | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 projects/plugins/jetpack/changelog/update-fonts-i18n diff --git a/projects/plugins/jetpack/changelog/update-fonts-i18n b/projects/plugins/jetpack/changelog/update-fonts-i18n new file mode 100644 index 000000000000..f75f86fd5b33 --- /dev/null +++ b/projects/plugins/jetpack/changelog/update-fonts-i18n @@ -0,0 +1,4 @@ +Significance: patch +Type: enhancement + +Add fonts for better i18n compatibility. From 7c11fa4ad696f4a6c5202cfd4e27713aee7724cc Mon Sep 17 00:00:00 2001 From: Mikael Korpela Date: Thu, 8 Dec 2022 16:37:33 +0200 Subject: [PATCH 3/3] [not verified] Register different names for i18n fonts --- .../plugins/jetpack/modules/google-fonts.php | 43 +++++++++++-------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/projects/plugins/jetpack/modules/google-fonts.php b/projects/plugins/jetpack/modules/google-fonts.php index 644646b7f1f7..267451d47085 100644 --- a/projects/plugins/jetpack/modules/google-fonts.php +++ b/projects/plugins/jetpack/modules/google-fonts.php @@ -57,22 +57,21 @@ ); const JETPACK_GOOGLE_FONTS_I18N = array( - 'Alexandria', // Arabic - 'IBM Plex Sans Arabic', - 'Noto Sans Hebrew', - 'Noto Sans HK', // Noto Sans Hong Kong @TODO: should be HKC? - 'Noto Sans JP', // Japanese - 'Noto Sans KR', // Korean - 'Noto Sans SC', // Simplified Chinese - 'Noto Sans TC', // Traditional Chinese - 'Noto Sans Telugu', - 'Noto Serif Hebrew', - 'Noto Serif HK', // Noto Sans Hong Kong @TODO: should be HKC? - 'Noto Serif JP', // Japanese - 'Noto Serif KR', // Korean - 'Noto Serif SC', // Simplified Chinese - 'Noto Serif TC', // Traditional Chinese - // 'Mukta (Devanagari)' @TODO: not on Google Fonts? + 'Alexandria' => 'Alexandria (Arabic)', + 'IBM Plex Sans Arabic' => 'IBM Plex Sans (Arabic)', + 'Noto Sans Hebrew' => 'Noto Sans (Hebrew)', + 'Noto Sans HK' => 'Noto Sans (Hong Kong)', + 'Noto Sans JP' => 'Noto Sans (Japanese)', + 'Noto Sans KR' => 'Noto Sans (Korean)', + 'Noto Sans SC' => 'Noto Sans (Simplified Chinese)', + 'Noto Sans TC' => 'Noto Sans (Traditional Chinese)', + 'Noto Sans Telugu' => 'Noto Sans (Telugu)', + 'Noto Serif Hebrew' => 'Noto Serif (Hebrew)', + 'Noto Serif HK' => 'Noto Serif (Hong Kong)', + 'Noto Serif JP' => 'Noto Serif (Japanese)', + 'Noto Serif KR' => 'Noto Serif (Korean)', + 'Noto Serif SC' => 'Noto Serif (Simplified Chinese)', + 'Noto Serif TC' => 'Noto Serif (Traditional Chinese)', ); /** @@ -87,9 +86,8 @@ function jetpack_add_google_fonts_provider() { wp_register_webfont_provider( 'jetpack-google-fonts', '\Automattic\Jetpack\Fonts\Google_Fonts_Provider' ); - // @TODO: we need to modify some of the font names and // Ensure i18n specific fonts are at the end of the list - $fonts_list = array_merge( JETPACK_GOOGLE_FONTS_I18N, JETPACK_GOOGLE_FONTS_I18N ); + $fonts_list = array_merge( JETPACK_GOOGLE_FONTS_LIST, array_keys( JETPACK_GOOGLE_FONTS_I18N ) ); /** * Curated list of Google Fonts. @@ -103,9 +101,17 @@ function jetpack_add_google_fonts_provider() { $fonts_to_register = apply_filters( 'jetpack_google_fonts_list', $fonts_list ); foreach ( $fonts_to_register as $font_family ) { + + $font_name = $font_family; + + if ( array_key_exists( $font_family, JETPACK_GOOGLE_FONTS_I18N ) ) { + $font_name = JETPACK_GOOGLE_FONTS_I18N[ $font_family ]; + } + wp_register_webfonts( array( array( + 'name' => $font_name, 'font-family' => $font_family, 'font-weight' => '100 900', 'font-style' => 'normal', @@ -113,6 +119,7 @@ function jetpack_add_google_fonts_provider() { 'provider' => 'jetpack-google-fonts', ), array( + 'name' => $font_name, 'font-family' => $font_family, 'font-weight' => '100 900', 'font-style' => 'italic',