Skip to content

Commit 2585e72

Browse files
authored
fix: quote font names
2 parents 88d50af + 5e44728 commit 2585e72

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

newspack-theme/functions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ function newspack_content_width() {
429429
* Return the list of custom fonts in use.
430430
*/
431431
function newspack_get_used_custom_fonts(): array {
432-
return array_filter( array( get_theme_mod( 'font_header', '' ), get_theme_mod( 'font_body', '' ) ) );
432+
return array_values( array_filter( [ get_theme_mod( 'font_header', '' ), get_theme_mod( 'font_body', '' ) ] ) );
433433
}
434434

435435
/**

newspack-theme/js/src/font-loading.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
const fontsToLoad = window.newspackFontLoading?.fonts || [];
2-
Promise.all( fontsToLoad.map( fontName => document.fonts.load( `1rem ${ fontName }` ) ) ).then( res => {
2+
Promise.all(
3+
fontsToLoad.map( fontName => {
4+
const escapedFontName = String( fontName ).replace( /"/g, '\\"' );
5+
return document.fonts.load( `1rem "${ escapedFontName }"` );
6+
} )
7+
).then( res => {
38
if ( res.length === fontsToLoad.length ) {
49
document.body.classList.remove( 'newspack--font-loading' );
510
}

0 commit comments

Comments
 (0)