【问题标题】:Google Fonts: How to load specific glyphs for only one of the weights of a loaded setGoogle Fonts:如何仅为加载集的一个权重加载特定字形
【发布时间】:2020-09-09 12:26:20
【问题描述】:

因此,我们可以使用text= 指定要加载的字形。

<link href="https://fonts.googleapis.com/css2?family=Nunito+Sans:wght@900&text=HEADER&display=swap" rel="stylesheet">

另外,我们可以同时加载多个权重:

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

我不知道(也无法在任何地方找到答案)是如何组合这些行。也就是说:我需要完整的权重 400 和 700,但只需要权重 900 的特定字形。

我尝试了几种组合,但都不起作用。当我简单地打两个电话时,我只得到第一行的权重。当我在一次调用中组合它们时,我只会得到所有权重的指定字形。

不起作用的示例:

<link href="https://fonts.googleapis.com/css2?family=Nunito+Sans:wght@400;700;900&text=HEADER&display=swap" rel="stylesheet">

<link href="https://fonts.googleapis.com/css2?family=Nunito+Sans:wght@400;700&family=Nunito+Sans:wght@900&text=HEADER&display=swap" rel="stylesheet">

谢谢!

【问题讨论】:

    标签: html customization webfonts google-fonts


    【解决方案1】:

    在这里工作正常:

    .nunito { font-family: Nunito Sans }
    .w4 { font-weight: 400 }
    .w7 { font-weight: 700 }
    .w9 { font-weight: 900 }
    <link href="https://fonts.googleapis.com/css2?family=Nunito+Sans:wght@400;700&display=swap" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Nunito+Sans:wght@900&text=HEADR&display=swap" rel="stylesheet">
    <div class="nunito">
    <span class="w4">NOT THE HEADER full set</span><br>
    <span class="w7">NOT THE HEADER full set</span><br>
    <span class="w9">NOT THE HEADER full set</span>
    </div>

    【讨论】:

    • 您好,感谢您的回答,但我看到的是:pasteboard.co/JqjHgR1.png。对于所有权重,仅加载字形“HEADER”。我需要的是,对于重量为 400 和 700 的所有字形都已加载,而对于重量为 900 的“HEADER”已加载。谢谢!
    • 对不起,误解了你的问题,但是通过调用两次它对我来说很好。 (编辑以反映这一点)
    • 你说得对,现在我复制你的台词就可以了。我不知道第一次出了什么问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-03
    • 1970-01-01
    • 1970-01-01
    • 2014-01-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多