【问题标题】:Why are my Google fonts not working?为什么我的 Google 字体不起作用?
【发布时间】:2013-05-29 19:00:30
【问题描述】:

我的 Google 字体似乎无法正常工作。我的 wordpress 主题带有一个自定义的 Googlefonts.php,它使用此代码来请求字体:

foreach($googlefonts as $getfonts) {

if(!in_array($getfonts, $default)) {
        $customfont = str_replace(' ', '+', $getfonts). ':400,400italic,700,700italic|' . $customfont;
}
}

if($customfont != ''){
echo "<link href='http://fonts.googleapis.com/css?family=" . substr_replace($customfont ,"",-1) . "&amp;subset=latin,latin-ext,cyrillic,cyrillic-ext,greek-ext,greek,vietnamese' rel='stylesheet' type='text/css'>";

}

我不明白 Google 字体 api 是如何工作的,我从来没有以这种方式使用过。

根据 Firebug,我对 api 的调用返回了一个错误的请求。这是上面这段代码现在发送给 Google 的 URL:

http://fonts.googleapis.com/css?family=Trebuchet+MS:400,400italic,700,700italic|Trebuchet+MS:400,400italic,700,700italic|Trebuchet+MS:400,400italic,700,700italic|Trebuchet+MS:400,400italic,700,700italic|Trebuchet+MS:400,400italic,700,700italic|Trebuchet+MS:400,400italic,700,700italic|Trebuchet+MS:400,400italic,700,700italic|Trebuchet+MS:400,400italic,700,700italic&subset=latin,latin-ext,cyrillic,cyrillic-ext,greek-ext,greek,vietnamese

有人可以向我解释为什么这不起作用吗?

PS:有人可能会想,你为什么要多次请求相同的字体。这是因为我的主题具有为 H1、H2、普通文本、菜单等获取不同字体的选项。

【问题讨论】:

    标签: google-font-api


    【解决方案1】:

    URL itself explains why it's not working - Google 没有 Trebuchet MS 字体。

    【讨论】:

    • 大声笑,那为什么我的主题在下拉列表中添加了 Trebuchet MS 以供选择?让我看看这个:)
    • 什么?该链接以某种方式格式错误,但如果您实际上将 url 粘贴到 url 栏中,它可以正常工作:fonts.googleapis.com/…
    • 或者至少它现在在我的 (linux) 计算机上运行良好,也许它以前不能运行,或者只适用于某些用户代理?
    猜你喜欢
    • 1970-01-01
    • 2015-01-17
    • 2022-01-07
    • 2015-04-08
    • 1970-01-01
    • 1970-01-01
    • 2013-09-19
    • 2019-04-21
    • 2016-07-29
    相关资源
    最近更新 更多