如何在 Google WebFont Loader 中调整样式

发布于 2025-01-18 03:04:33 字数 971 浏览 2 评论 0原文

我有这段代码可以异步加载 Google 字体以避免渲染阻塞,我在结束代码的 之前就有了它。

<script type="text/javascript">
      WebFontConfig = {
        google: {
          families: ['Poppins:300,400,500,600,700']
        }
      };
      (function(d) {
        var wf = d.createElement('script'),
          s = d.scripts[0];
        wf.src = 'https://ajax.googleapis.com/ajax/libs/webfont/1.6.26/webfont.js';
        wf.async = true;
        s.parentNode.insertBefore(wf, s);
      })(document);
    
    </script>

问题是数字的宽度不同?风格? 我希望 TextArea 中的所有数字都相同,而不是如下所示: Imgur

PS:我正在使用 Poppins,如果我以常见的方式加载字体(<链接href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap" rel="stylesheet">) 此错误确实不会发生。

我从 Google WebFont Loader 获取的代码

I have this code that asynchronously loads Google Fonts to avoid render blocking, I have it before ending the </body> of my code.

<script type="text/javascript">
      WebFontConfig = {
        google: {
          families: ['Poppins:300,400,500,600,700']
        }
      };
      (function(d) {
        var wf = d.createElement('script'),
          s = d.scripts[0];
        wf.src = 'https://ajax.googleapis.com/ajax/libs/webfont/1.6.26/webfont.js';
        wf.async = true;
        s.parentNode.insertBefore(wf, s);
      })(document);
    
    </script>

The problem is that the numbers have different widths? styles?
I want all the numbers to be the same in my TextArea and not look like this:
Imgur

PS: I am using Poppins and if I load the fonts in a common way (<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap" rel="stylesheet">) this error does not happen.

The code I took from Google WebFont Loader

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文