Google Fonts not connecting

Started by Term, Aug 06, 2022, 10:48 AM

Previous topic - Next topic

TermTopic starter

Friends, hello everyone.

Below is an excerpt from functions php. I do not understand why the fonts are not connected? What's my mistake?
1 <?php
2     add_filter
4     add_action
5     function site_scripts() {
6         wp_enqueue_style('googleapsis''');
7         wp_enqueue_style('gstatic''');
8         wp_enqueue_style('google-fonts'';600;700&family=Mulish:wght@400;700&display=swap');
9         wp_enqueue_style('main-style'get_stylesheet_uri(), array(), '');
10     }
12 ?>
When connecting via header php via link everything works...
Maybe the fonts are not all right?


News this summer. recommends that theme authors work exclusively with local web fonts.
In light of a recent lawsuit in Germany where a website owner was fined for violating the GDPR by implementing Google fonts, the WordPress team has begun recommending the correct placement of web fonts. Most theme developers include Google fonts via a CDN to improve performance, but it turned out that this method exposes the IP addresses of visitors.

"The WP team strongly encourages developers to update all of their projects," said a Themes Team representative in a recent announcement. "We recommend switching to local fonts. Fonts from Google can be easily downloaded and shipped with the theme. As a result, users will be able to work with such web fonts locally, which does not violate GDPR rules."

The main team members are now working on changing all default themes, from Twenty Twelve to Twenty Seventeen - they are being transferred to local web fonts. The issue had been discussed before, but was put on hold until a recent court case when it was brought up again. One user complained on the German support forums that he created a small site based on the Twenty Seventeen theme, after which he was threatened by site visitors, citing a court decision. Ignoring the rules is punishable by a fine of €250,000 per incident, or, alternatively, a six-month prison sentence if the site owner does not stop working through the Google CDN, thereby inadvertently publishing users' IP addresses.

I recommend looking at Twenty Twenty-Two to understand how to properly ship local web fonts via theme.json. I think you should follow the guide:


Newport, they caught up with so much fear ...
You could just write: "It is impossible - they will fine you." This is probably why the Term construct does not run. Google doesn't sleep. :)
Well, the developers will not immediately rush to change their themes until they are asked for money.
What should ordinary users do, do they finish everything with pens?

No. A good person made a little plugin called Local Google Fonts that detects the source of Google fonts and allows them to be downloaded for local use. Simple and easy.
"Install and forget" is the plugin category.
Enjoy. :)


Another useful plugin: OMGF | Host Google Fonts Locally. The description says it all, but briefly:
  • Makes fonts preload, this helps improve "Cumulative LayoutShift" in Page Speed.
  • Removes unused fonts in themes and plugins.
  • Specifies the fallback font stack.
  • If necessary, to speed up page loading, changes font families to system fonts.

TermTopic starter

Thank you all very much. Now everything works.
Fonts are loaded and served from a local directory via https.

By the way, I found a good plugin for VP with a huge number of Google fonts.
Easy Google Fonts
You can easily pick up an interesting one in the visual editor. Without dancing with a tambourine and writing scripts.
Of course, fonts should not be connected through it, due to the GDPR problem discussed above, but you can use it to check how a particular font will look on the site.


Web fonts are not needed, it is evil. They slow down the page display, as the text is not displayed until a huge, heavy font is loaded.
Why to use them and slow down website, I can't understand. Probably, site developers are unqualified and do not understand the consequences of using web fonts.

In the most popular operating systems like Windows, there is a sufficient number of high-quality built-in fonts, you can choose from them. Why Roboto or Open Sans is better than Arial or Calibri, I don't understand. For a layman in a small size, they generally all look the same.
 In addition, embedded fonts in Windows are optimized for pixel grid and look better on average than "blurred" web fonts without optimizations.
You don't have to think about cross-platform while 95% use windows. We specify the standard Windows font, we get a fast web site. For other platforms, you can either specify an alternative font, or at least a web font.

There is of course a problem that there may not be the right fonts on mobile.
 Well, then you can specify a web font for them - let their page load slowly. Although I would rather specify an alternative font like "sans".