【问题标题】:path from drupal theme css to font files从 drupal 主题 css 到字体文件的路径
【发布时间】:2016-01-20 09:45:10
【问题描述】:

我正在尝试在我的 drupal 网站中包含我自己的字体。我在“sites/all/themes/mytheme/css”文件夹中的主题中有一个 custom.css 文件。我的字体在我的 'sites/all/themes/mytheme/fonts' 文件夹中。从我的主题文件夹中的 template.php 调用 css。 这是我现在的 CSS 代码:

@font-face {
    font-family: 'slashbadass_black';
    src: url('../fonts/Myfont.eot');
    src: url('../fonts/Myfont.eot?#iefix') format('embedded-opentype'),
         url('../fonts/Myfont.woff2') format('woff2'),
         url('../fonts/Myfont.woff') format('woff'),
         url('../fonts/Myfont.ttf') format('truetype'),
         url('../fonts/Myfont.svg#slashbadass_black') format('svg');
    font-weight: normal;
    font-style: normal;
} 

那么这条路好吗?对于我所看到的字体系列现在不可用。

【问题讨论】:

    标签: css url drupal fonts path


    【解决方案1】:

    如上所述,路径是正确的。 “sites/all/themes/mytheme/css/styles.css”将搜索“sites/all/themes/mytheme/fonts/”下的字体文件。

    愚蠢的问题:您是否正确设置了将在您的 css 上使用字体的 html 标签?像 body { font-family: 'slashbadass_black'; }

    使用 firebug (FireFox) 或开发人员工具栏 (Chrome)(F12 快捷键)检查服务器响应(网络选项卡),以确保字体是否由服务器提供。即:

    GET css?family=Open+Sans 200 OK 127.0.0.1 473 B 
    127.0.0.1:80
    

    如果还是有问题,可以考虑使用模块https://www.drupal.org/project/fontyourface

    【讨论】:

    • 不是那么愚蠢的问题,因为失败是由于一些更愚蠢的东西,在开发环境中有字体但在服务器中没有。
    猜你喜欢
    • 1970-01-01
    • 2016-08-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多