Make WordPress Core

Opened 18 hours ago

Last modified 14 hours ago

#62258 new defect (bug)

Update Google Fonts collection

Reported by: mmaattiiaass's profile mmaattiiaass Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: trunk
Component: General Keywords: needs-testing needs-testing-info 2nd-opinion
Focuses: css Cc:

Description

The current Google fonts collection data is not up-to-date with the latest additions to the list of available fonts and the latest version of the existing ones.

It should be updated for 6.7

A related issue reported in Gutenberg: https://github.com/WordPress/gutenberg/issues/64685

Change History (3)

#1 @dilip2615
15 hours ago

  • Focuses css added
  • Keywords needs-testing needs-testing-info 2nd-opinion added

To update the Google Fonts collection for WordPress 6.7, fetch the latest fonts data from the Google Fonts API. Replace the existing JSON file or fonts data in your project with the new version. For example, if you're updating Gutenberg, modify the font-loading mechanism to use the new data, then test to ensure new fonts are available. Finally, clear cache and verify functionality.

Fetch Latest Google Fonts: Use the API to get the updated fonts list:

$api_key = 'YOUR_API_KEY';
$url = "https://www.googleapis.com/webfonts/v1/webfonts?key=$api_key";
$response = wp_remote_get($url);
$body = wp_remote_retrieve_body($response);
$fonts_data = json_decode($body, true);

Replace Existing Fonts: Update your local JSON file or replace the existing font array in your project:

file_put_contents('path/to/fonts.json', json_encode($fonts_data));

Update Frontend: Update the font loading in your theme or plugin, e.g., enqueue the latest fonts:

Update Frontend: Update the font loading in your theme or plugin, e.g., enqueue the latest fonts:

#2 follow-up: @mmaattiiaass
15 hours ago

@dilip2615 those instructions doesn't seem to be correct.

To try the updated version of the Google Fonts collection you can follow the steps outline in the "How to test?" section of this PR: https://github.com/WordPress/google-fonts-to-wordpress-collection/pull/38

#3 in reply to: ↑ 2 @dilip2615
14 hours ago

Replying to mmaattiiaass:

Extremely Sorry for that Yes I know it's a old version example just I am sharing with you a example here.

Last edited 14 hours ago by dilip2615 (previous) (diff)
Note: See TracTickets for help on using tickets.