Skip to content

Commit

Permalink
Girlscouting: since, webfont, spacing.
Browse files Browse the repository at this point in the history
  • Loading branch information
hellofromtonya committed May 25, 2023
1 parent 1214f8d commit c146215
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions lib/experimental/fonts-api/class-wp-fonts-resolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,13 @@ private static function get_value_from_style( $style, $preset_type = 'font-famil

/**
* Register fonts defined in theme.json.
*
* @since X.X.X
*/
public static function register_fonts_from_theme_json() {

$settings = static::get_settings();
// Bail out early if there are no settings for webfonts.
// Bail out early if there are no settings for fonts.
if ( empty( $settings['typography'] ) || empty( $settings['typography']['fontFamilies'] ) ) {
return;
}
Expand All @@ -127,6 +129,8 @@ public static function register_fonts_from_theme_json() {
/**
* Add missing fonts to the global styles.
*
* @since X.X.X
*
* @param WP_Theme_JSON_Gutenberg|WP_Theme_JSON $data The global styles.
* @return WP_Theme_JSON_Gutenberg|WP_Theme_JSON The global styles with missing fonts.
*/
Expand Down Expand Up @@ -167,7 +171,9 @@ public static function add_missing_fonts_to_theme_json( $data ) {
}

/**
* Returns theme's settings and adds webfonts defined in variations.
* Returns theme's settings and adds fonts defined in variations.
*
* @since X.X.X
*
* @return array An array containing theme's settings.
*/
Expand All @@ -179,7 +185,7 @@ private static function get_settings() {
return $settings;
}

// If in the editor, add webfonts defined in variations.
// If in the editor, add fonts defined in variations.
$variations = WP_Theme_JSON_Resolver_Gutenberg::get_style_variations();
$set_theme_structure = true;

Expand Down Expand Up @@ -212,6 +218,8 @@ private static function get_settings() {
/**
* Converts a list of font families into font handles and returns them as an array.
*
* @since X.X.X
*
* @param array $families_data An array of font families data.
* @return array An array containing font handles.
*/
Expand All @@ -231,12 +239,15 @@ private static function get_font_families( $families_data ) {
/**
* Parse font families from theme.json.
*
* @since X.X.X
*
* @param array $settings Font settings to parse.
* @return array Returns an array that contains font data and corresponding handles.
*/
private static function parse_font_families( array $settings ) {
$handles = array();
$fonts = array();

// Look for fontFamilies.
foreach ( $settings['typography']['fontFamilies'] as $font_families ) {
foreach ( $font_families as $font_family ) {
Expand Down

0 comments on commit c146215

Please sign in to comment.