Breaking bug in Google fonts handling
-
ChatGPT helped me identify an issue which I thought was due to a page builder update (Breakdance), but was due to Autoptimise combining Google Fonts requests. The font ‘Merriweather’ was loading but “Merriweather Sans’ was not. I have fixed this on my site (by turning off Autoptimse’s google font handling) but I’m sharing it for others / the developers, in case it is helpful.
ChatGPT said (amongst lots of other stuff that wasn’t true!)
2. The Google Fonts URL is malformed
This part caught my eye:
Merriweather Sans:300..800,italic300..800For variable fonts Google normally expects something like
family=Merriweather+Sans:ital,wght@0,300..800;1,300..800whereas the Merriweather request underneath is in the newer format:
family=Merriweather:ital,opsz,wdth,wght@...So the URL is mixing two different syntaxes. Modern Google Fonts is fairly forgiving, but it’s possible Autoptimize has generated an invalid URL for Merriweather Sans.
This is the full code from the page source:
<link rel="stylesheet" media="print" onload="this.onload=null;this.media='all';" id="ao_optimized_gfonts" href="https://fonts.googleapis.com/css?family=Merriweather Sans:300..800,italic300..800%7CMerriweather:ital,opsz,wdth,18..144,87..112,300..900,italic18..144,87..112,300..900&display=swap">
You must be logged in to reply to this topic.