Jump to content

Google Fonts integration outed


Recommended Posts

Hi IPS,

Please can you fix the the Google Fonts integration as the new improved API has been out for some time now?

Themes > Core > Global > Global > includeCSS template:

{{if ( theme.headline_font && theme.headline_font !== 'default' ) || ( theme.body_font && theme.body_font !== 'default' ) }}
	{{if theme.headline_font == theme.body_font}}
		<link href="https://fonts.googleapis.com/css?family={expression="\IPS\Http\Url::encodeComponent( \IPS\Http\Url::COMPONENT_FRAGMENT, \IPS\Theme::i()->settings['body_font'] )"}:300,300i,400,400i,500,700,700i" rel="stylesheet" referrerpolicy="origin">
	{{else}}
		{{if ( theme.headline_font && theme.headline_font !== 'default' )}}
			<link href="https://fonts.googleapis.com/css?family={expression="\IPS\Http\Url::encodeComponent( \IPS\Http\Url::COMPONENT_FRAGMENT, \IPS\Theme::i()->settings['headline_font'] )"}:300,300i,400,500,400i,700,700i" rel="stylesheet" referrerpolicy="origin">
		{{endif}}
		{{if ( theme.body_font && theme.body_font !== 'default' )}}
			<link href="https://fonts.googleapis.com/css?family={expression="\IPS\Http\Url::encodeComponent( \IPS\Http\Url::COMPONENT_FRAGMENT, \IPS\Theme::i()->settings['body_font'] )"}:300,300i,400,400i,500,700,700i" rel="stylesheet" referrerpolicy="origin">
		{{endif}}
	{{endif}}
{{endif}}

I know the old links are still compatible Google provid the new V2 links some time ago, they supposedly offer various improvements, new variable fonts, reduced latency, smaller code, display: swap etc.

The new link are similar to:

<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;700&display=swap" rel="stylesheet">

Or for the variable fonts versions:

<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300..700&display=swap" rel="stylesheet">

<link href="https://fonts.googleapis.com/css2?family=Inter:slnt,wght@-10..0,300..700&display=swap" rel="stylesheet">

https://developers.google.com/fonts/docs/css2
https://web.dev/variable-fonts/
 

 

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...