Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues with URLs of some embedded fonts returning 404 #14

Open
marcochiesi opened this issue May 11, 2023 · 0 comments
Open

Issues with URLs of some embedded fonts returning 404 #14

marcochiesi opened this issue May 11, 2023 · 0 comments

Comments

@marcochiesi
Copy link

Hi there,
thanks for this useful plugin. I have found a bug when using the Kanit font with the following enqueue:

wp_enqueue_style( 'google-font', 'https://fonts.googleapis.com/css?family=Kanit:100,200,300,400,400,500,700,900&display=swap' );

Basically, there was a mismatch between the file name in the local cache and the URL used as a replacement in the link.

I.e. The file was named kanit-v13-latin_latin-ext_thai_vietnamese-100.woff but the URL was kanit-v12-vietnamese_latin-ext_latin-regular.woff2, resulting in several 404 errors.

There were two different issues:

  1. The "thai" subset was completely missing
  2. It seems the order of the subsets in the two cases was not corresponding.

I was able to fix the issue with the following snippet thanks to the available filter:

// Fix to embed Kanit font via Embed Google Fonts plugin.
function bs_fix_embed_google_fonts_get_subsets( $subsets ) {
	if ( ! in_array ( 'thai', $subsets ) ) {
		$subsets[] = 'thai';
	}
	sort( $subsets );
	return $subsets;
}
add_filter( 'embed_google_fonts_get_subsets', 'bs_fix_embed_google_fonts_get_subsets' );

However, it would be ideal to add 'thai' and reorder the subsets directly in the original plugin.
Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant