Grails 2.3 将 css font-face url 更改为“resource:/..."; [英] Grails 2.3 changes css font-face url to "resource:/..."

查看:15
本文介绍了Grails 2.3 将 css font-face url 更改为“resource:/...";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的 CSS 中包含一个自定义字体,如下所示:

I want to include a custom font in my CSS like this:

@font-face
{
    font-family: TheFont;
    src: url(fonts/SourceSansProLight.ttf);
}

CSS 随 Grails 2.3 一起提供,CSS 被修改成这样

The CSS is served with Grails 2.3 and the CSS is modified to become this

@font-face
{
    font-family: TheFont;
    src: url(resource:/css/fonts/fonts/SourceSansProLight.ttf);
}

生成的字体 url 方案未知,浏览器无法打开该文件.例如,Chrome 报告:

The resulting font url scheme is unknown and browsers can't open that file. Chrome, for example, reports:

GET resource:/css/fonts/fonts/SourceSansProLight.ttf net::ERR_UNKNOWN_URL_SCHEME 

/css/fonts 也被添加到原始 URL 中.

/css/fonts is prepended to the original URL as well.

如何指示 Grails 保留字体 URL 原样?

How can I instruct Grails to leave the font-face URL exactly as it is?

推荐答案

解决方案是在 Config.groovy 中禁用 CSS 处理:

The solution was to disable CSS processing in Config.groovy:

grails.resources.rewrite.css = false

我在 Grails 邮件列表.

这篇关于Grails 2.3 将 css font-face url 更改为“resource:/...";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆