From f4b9f6a3cbf07c696d14fe154f9ef4f8093353b7 Mon Sep 17 00:00:00 2001 From: Benjamin Intal Date: Fri, 14 Feb 2025 16:45:02 +0800 Subject: [PATCH] fix (blocksy): add support for CSS custom property font family (#3436) Co-authored-by: bfintal@gmail.com <> --- src/global-settings.php | 5 +++++ src/util/font.js | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/global-settings.php b/src/global-settings.php index 9949ab46b..b833996eb 100644 --- a/src/global-settings.php +++ b/src/global-settings.php @@ -688,6 +688,11 @@ public function get_font_family( $font_name ) { return '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"'; } + // If the font is a CSS custom property, return it directly. + if ( strpos( $font_name, 'var(' ) === 0 ) { + return $font_name; + } + // Google font. return '"' . $font_name . '", sans-serif'; } diff --git a/src/util/font.js b/src/util/font.js index e6d84d3db..1ddce2f56 100644 --- a/src/util/font.js +++ b/src/util/font.js @@ -89,6 +89,11 @@ export const isGoogleFontEnqueued = ( fontName, head = document.querySelector( ' } export const getFontFamily = fontName => { + // If the font is a CSS custom property, return it directly. + if ( fontName.match( /^\s*var\(--/ ) ) { + return fontName + } + // Google Font. if ( isWebFont( fontName ) ) { return `"${ fontName }", Sans-serif`