我正在尝试在本地包含字体,因此没有CDN,如果有的话,这会容易得多。字体说明说在The_Land_Market.css
标签中包含head
The_Land_Market.css
@import url("//hello.myfonts.net/count/378995");
@font-face {font-family: 'PakenhamRg-Bold';src: url('webfonts/378995_0_0.eot');src: url('webfonts/378995_0_0.eot?#iefix') format('embedded-opentype'),url('webfonts/378995_0_0.woff2') format('woff2'),url('webfonts/378995_0_0.woff') format('woff'),url('webfonts/378995_0_0.ttf') format('truetype');}
所以我将文件放在我的Resources文件夹中,并包含了它
default.html.twig
{% stylesheets
'@FrontBundle/Resources/public/libraries/fonts/The_Land_Market.css'
'@FrontBundle/Resources/public/css/styles.css' filter='cssrewrite' %}
<link rel="stylesheet" href="{{ asset_url }}" type="text/css">
{% endstylesheets %}
如果我没记错的话,问题是The_Land_Market.css
中的网址不正确,我想我可能可以解决这个问题,但是即使如此,我仍不确定它是否能正常工作那是很多猜测。在webfonts
所在的目录中有一个The_Land_Market.css
文件夹。如果我可以正确地路径eot,woff,ttf,woff2文件,即使如此,我也可以确定这不是正确的方法,因为应该使用asset{{}}
路径来引用它们,因此该目录在生产模式下,更改不会破坏它。
我还考虑过做类似以下的事情
default.html.twig
<style type="text/css">
@font-face {
font-family: 'PakenhamRg-Bold';
src: url({{asset('webfonts/378995_0_0.eot')}}) format('opentype'),
url({{asset('webfonts/378995_0_0.eot?#iefix')}}) format('woff'),
url({{asset('webfonts/378995_0_0.woff2')}}) format('woff2');
}
</style>
但是我不确定URL {{asset()}}
所引用的是什么。