Closed ryelle closed 5 months ago
Thank you for addressing this issue!
I tested this PR by doing the following:
function enqueue_cjk_fonts() {
global_fonts_preload( 'Noto Serif JP', 'cjk' );
wp_enqueue_style( 'wporg-global-fonts' );
}
add_action( 'init', 'enqueue_cjk_fonts' );
The font is preloaded, but the font family is not applied.
I investigated the reason and found that it might be because the folder contains a space.
This is because the space is encoded in the font URL:
<link rel='preload' href='http://localhost:8888/wp-content/mu-plugins/global-fonts/Noto%20Serif/NotoSerifJP-cjk.woff2' as='font' crossorigin='crossorigin' type='font/woff2' />
But in the stylesheet, the space remains a space.
As a test, I changed the directory name from Noto Serif
to NotoSerif
and removed the spaces from the relevant code, and the font family was applied correctly.
Aha, I had Noto Serif JP installed locally, so I missed the issue. I've renamed the folder to NotoSerif
to match the other folders, which lack spaces, and it's working correctly now.
This PR adds the Noto Serif JP font from noto-cjk, using "Region Specific Subset OTFs Japanese (日本語)".
I've decided to use this version, instead of the subset version suggested in https://github.com/WordPress/wporg-main-2022/issues/427, because this is a variable font. This means we have access to all weights (just like EB Garamond) without having to load multiple font files. This version has also been updated since the subset versions were made.
The font file has been added to the global-fonts CSS, so that w.org sites can use this with
font-family: "Noto Serif JP";
. The font can also be marked for preloading withglobal_fonts_preload( 'Noto Serif JP', 'cjk' );
.Followup PRs to the parent theme and main theme are in progress to actually use the font.
Fixes https://github.com/WordPress/wporg-main-2022/issues/427