diff --git a/fonts/cormorant-garamond/font.json b/fonts/cormorant-garamond/font.json index 1cbb98a5..c542a4cb 100644 --- a/fonts/cormorant-garamond/font.json +++ b/fonts/cormorant-garamond/font.json @@ -4,7 +4,7 @@ "version": "16", "key": "cormorant-garamond", "name": "Cormorant Garamond", - "family": "'Cormorant Garamond'", + "family": "Cormorant Garamond", "alt": "Garamond", "type": "serif", "styles": ["normal", "italic"], diff --git a/fonts/crimson-text/font.json b/fonts/crimson-text/font.json index b2a09526..37f1cd8d 100644 --- a/fonts/crimson-text/font.json +++ b/fonts/crimson-text/font.json @@ -4,7 +4,7 @@ "version": "19", "key": "crimson-text", "name": "Crimson Text", - "family": "'Crimson Text'", + "family": "Crimson Text", "type": "serif", "styles": ["normal", "italic"], "weights": [400, 600, 700], diff --git a/fonts/helvetica-neue/font.json b/fonts/helvetica-neue/font.json index 594c0f8c..393069d0 100644 --- a/fonts/helvetica-neue/font.json +++ b/fonts/helvetica-neue/font.json @@ -4,7 +4,7 @@ "version": "", "key": "helvetica-neue", "name": "Helvetica Neue", - "family": "'Helvetica Neue'", + "family": "Helvetica Neue", "alt": "Helvetica, Arial", "type": "sans-serif", "styles": ["normal", "italic"], diff --git a/fonts/open-sans/font.json b/fonts/open-sans/font.json index b728b155..a2b176c4 100644 --- a/fonts/open-sans/font.json +++ b/fonts/open-sans/font.json @@ -4,7 +4,7 @@ "version": "40", "key": "open-sans", "name": "Open Sans", - "family": "'Open Sans'", + "family": "Open Sans", "type": "sans-serif", "styles": ["normal", "italic"], "weights": [300, 325, 400, 500, 600, 700], diff --git a/fonts/roboto-mono/font.json b/fonts/roboto-mono/font.json index df7f97e3..dc619dc7 100644 --- a/fonts/roboto-mono/font.json +++ b/fonts/roboto-mono/font.json @@ -4,7 +4,7 @@ "version": "23", "key": "roboto-mono", "name": "Roboto Mono", - "family": "'Roboto Mono'", + "family": "Roboto Mono", "type": "monospace", "styles": ["normal", "italic"], "weights": [300, 400, 500, 600, 700], diff --git a/fonts/roboto-serif/font.json b/fonts/roboto-serif/font.json index 74332082..160df336 100644 --- a/fonts/roboto-serif/font.json +++ b/fonts/roboto-serif/font.json @@ -4,7 +4,7 @@ "version": "13", "key": "roboto-serif", "name": "Roboto Serif", - "family": "'Roboto Serif'", + "family": "Roboto Serif", "type": "serif", "styles": ["normal", "italic"], "weights": [300, 400, 500, 600, 700], diff --git a/includes/functions/_utility.php b/includes/functions/_utility.php index 019efdb9..c2f7ef23 100644 --- a/includes/functions/_utility.php +++ b/includes/functions/_utility.php @@ -1977,7 +1977,7 @@ if ( ! function_exists( 'fictioneer_get_fonts' ) ) { // Setup $custom_fonts = get_option( 'fictioneer_chapter_fonts' ); $fonts = array( - array( 'css' => "'" . FICTIONEER_PRIMARY_FONT_CSS . "'", 'name' => FICTIONEER_PRIMARY_FONT_NAME ), + array( 'css' => fictioneer_font_family_value( FICTIONEER_PRIMARY_FONT_CSS ), 'name' => FICTIONEER_PRIMARY_FONT_NAME ), array( 'css' => '', 'name' => _x( 'System Font', 'Font name.', 'fictioneer' ) ) ); @@ -1997,6 +1997,29 @@ if ( ! function_exists( 'fictioneer_get_fonts' ) ) { } } +// ============================================================================= +// WRAP MULTI-WORD FONTS INTO QUOTES +// ============================================================================= + +/** + * Returns font family value with quotes if required + * + * @since 5.10.0 + * + * @param string $font_value The font family value. + * @param string $quote Optional. The wrapping character. Default '"'. + * + * @return string Ready to use font family value. + */ + +function fictioneer_font_family_value( $font_value, $quote = '"' ) { + if ( preg_match( '/\s/', $font_value ) ) { + return $quote . $font_value . $quote; + } else { + return $font_value; + } +} + // ============================================================================= // GET FONT COLORS // ============================================================================= @@ -2792,7 +2815,7 @@ function fictioneer_build_bundled_fonts() { foreach ( $fonts as $font ) { if ( $font['chapter'] ?? 0 ) { $font_stack[ $font['key'] ] = array( - 'css' => $font['family'] ?? '', + 'css' => fictioneer_font_family_value( $font['family'] ?? '' ), 'name' => $font['name'] ?? '', 'alt' => $font['alt'] ?? '' );