Browse Source

Filter out any fonts provided by Pendant from being loaded by Jetpack (#6643)

Jason Crist 2 years ago
parent
commit
ddb0634021
1 changed files with 25 additions and 2 deletions
  1. 25 2
      pendant/functions.php

+ 25 - 2
pendant/functions.php

@@ -68,5 +68,28 @@ function pendant_register_block_pattern_categories() {
 	register_block_pattern_category( 'images', array( 'label' => __( 'Images', 'pendant' ) ) );
 	register_block_pattern_category( 'gallery', array( 'label' => __( 'Gallery', 'pendant' ) ) );
 }
-	
-add_action( 'init', 'pendant_register_block_pattern_categories', 9 );
+
+add_action( 'init', 'pendant_register_block_pattern_categories', 9 );
+
+/**
+ * Jetpack may attempt to register fonts for the Google Font Provider.
+ * If Jetpack registeres fonts in the same family as what this theme offers
+ * then those are included instead (and may be different typeface choices
+ * than what are expressed here.)
+ * This filter eliminates the fonts that Pendant natively supplies.
+ *
+ * This will no longer be needed once this Jetpack issue has been resolved:
+ * https://github.com/Automattic/jetpack/issues/25987
+ */
+function pendant_filter_jetpack_google_fonts_list( $list_to_filter ) {
+	$filtered = array_filter(
+		$list_to_filter,
+		function( $font_family ) {
+			return 'Jost' !== $font_family && 'Literata' !== $font_family;
+		}
+	);
+	return $filtered;
+}
+
+add_filter( 'jetpack_google_fonts_list', 'pendant_filter_jetpack_google_fonts_list' );
+