如何在Drupal 7上安装谷歌字体

EZD*_*ZDC 5 drupal

我在.info文件中添加了样式表并粘贴在google字体的url中,但是在firebug中它只显示整个页面,表明它没有正确链接.如何在drupal 7中链接谷歌字体?

小智 15

将其添加到template.php文件(位于主题文件夹中)中:

function YOURTHEMENAME_preprocess_html(&$variables) {
    drupal_add_css('http://fonts.googleapis.com/css?family=Raleway:400,100,700', array('type' => 'external'));
}
Run Code Online (Sandbox Code Playgroud)

(将YOURTHEMENAME替换为您主题的真实姓名).

然后在你的css文件中正确的css代码.就像是 :

body {
  font-family: 'Raleway', sans-serif;
}
Run Code Online (Sandbox Code Playgroud)


Cli*_*ive 1

只需使用贡献的Google Fonts 模块,您的生活就会变得更加轻松……它可以为您完成所有工作,并且已被多次证明有效。

  • 我们在更复杂的 drupal 站点上遇到了 fontyourface 的性能问题。如果您不需要全套功能,答案#1 仍然是最好的。 (2认同)