I'm looking for including fonts from CSS files in Symfony using Assetic. The issue is the browser fails to load these fonts.
@font-face {
font-family: 'Corbert'; /*a name to be used later*/
src: url('fonts/Corbert-Regular.otf') format('opentype'),
url('fonts/Corbert-Regular.woff') format('woff'),
url('fonts/Corbert-Regular.ttf') format('truetype');
}
My path structure is
...
+-src/
| +-MyCompany/
| +-MyBundle/
| +-Resources/
| +-public/
| +-css/
| +-fonts/
My path linking the CSS files is
What am i doing wrong ?
The @font-face CSS at-rule specifies a custom font with which to display text; the font can be loaded from either a remote server or a locally-installed font on the user's own computer.
The @font-face rule allows custom fonts to be loaded on a webpage. Once added to a stylesheet, the rule instructs the browser to download the font from where it is hosted, then display it as specified in the CSS.
I found the solution :
Just put in your Document.html.twig where you link your css files:
<style type="text/css">
@font-face {
font-family: 'Corbert';
src: url({{asset('fonts/Corbert-Regular.otf')}}) format('opentype'),
url({{asset('fonts/Corbert-Regular.woff')}}) format('woff'),
url({{asset('fonts/Corbert-Regular.otf')}}) format('truetype');
}
</style>
Indeed if you put that in the css file, symfony doesn't seem to recognize the code. It's the same for the picture :
<style type="text/css">
body, html{
background-image:url({{ asset('images/wallpaper.png') }});
}
<style>
Nice Week-end !
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With