【问题标题】:Use a google font and include only [A-Z] and '&'使用谷歌字体并且只包含 [A-Z] 和 '&'
【发布时间】:2013-09-09 14:12:31
【问题描述】:

有没有办法使用谷歌字体并让它只加载[A-Z]& & 字符?

我想这样做是为了减小大小并缩短加载时间,因为我只会使用基本的拉丁数字和字母。

如果必须,我可以自己托管字体,并且操作字体包是合法的,但不确定是否需要自托管以及如何操作谷歌的字体包。

我已经这样指定A-Z

http://fonts.googleapis.com/css?family=Inconsolata&text=ABCDEFGHIJKLMNOPQRSTUVWXYZ

但是指定& 很麻烦。这两个都不起作用:

<link href='http://fonts.googleapis.com/css?family=Inconsolata&text=ABC&amp;' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Inconsolata&text=ABC&' rel='stylesheet' type='text/css'>

【问题讨论】:

    标签: webfonts google-webfonts google-font-api


    【解决方案1】:

    在包含 google 字体时无法指定字符范围。唯一的方法是像这样指定每个字符:

    http://fonts.googleapis.com/css?family=Inconsolata&text=ABCDEFGHIJKLMNOPQRSTUVWXYZ
    

    【讨论】:

    • 如果您只需要设置标题样式,则可以加载更少的字符:http://fonts.googleapis.com/css?family=Inconsolata&amp;text=MyHeader
    【解决方案2】:

    You can include special characters by url-encoding their UTF-8 representation.

    & (U+0026) 在 UTF-8 中是 26,所以你的 url 应该有:

    &text=ABCDEFGHIJKLMNOPQRSTUVWXYZ%26
    

    这是一个方便的工具: http://www.url-encode-decode.com/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-04-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-24
      • 2012-08-05
      相关资源
      最近更新 更多