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. diff --git a/projects/plugins/jetpack/modules/google-fonts.php b/projects/plugins/jetpack/modules/google-fonts.php index 501cc9bdbfb5..267451d47085 100644 --- a/projects/plugins/jetpack/modules/google-fonts.php +++ b/projects/plugins/jetpack/modules/google-fonts.php @@ -56,6 +56,24 @@ 'Work Sans', ); +const JETPACK_GOOGLE_FONTS_I18N = array( + '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)', +); + /** * Register a curated selection of Google Fonts. * @@ -68,6 +86,9 @@ function jetpack_add_google_fonts_provider() { wp_register_webfont_provider( 'jetpack-google-fonts', '\Automattic\Jetpack\Fonts\Google_Fonts_Provider' ); + // Ensure i18n specific fonts are at the end of the list + $fonts_list = array_merge( JETPACK_GOOGLE_FONTS_LIST, array_keys( JETPACK_GOOGLE_FONTS_I18N ) ); + /** * Curated list of Google Fonts. * @@ -77,12 +98,20 @@ 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 ) { + + $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', @@ -90,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',