Skip to content

Commit

Permalink
fix (blocksy): add support for CSS custom property font family (#3436)
Browse files Browse the repository at this point in the history
Co-authored-by: [email protected] <>
  • Loading branch information
bfintal authored Feb 14, 2025
1 parent f65d27e commit f4b9f6a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/global-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
Expand Down
5 changes: 5 additions & 0 deletions src/util/font.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down

0 comments on commit f4b9f6a

Please sign in to comment.