1

I'm looking for including fonts from CSS files in Symfony. 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
path linking CSS http://img11.hostingpics.net/pics/602795Capture.png

fonts http://img11.hostingpics.net/pics/302550Capture.png

What am i doing wrong ?

Johnrednex
  • 305
  • 5
  • 17
  • looks as though you didn't include the font filees to the fonts folder..? – JonSnow Mar 11 '15 at 10:40
  • Indeed I forgot two font files. Now I have an other "path" error. I edited my post. – Johnrednex Mar 11 '15 at 10:46
  • Ok, you need to include the jQuery library right before bootstrap. You can download it from jquery.com or just link to – JonSnow Mar 11 '15 at 11:07
  • can you show the tag linking your css file – Pete Mar 11 '15 at 11:32
  • @SchweizerSchoggi I added the lonk to jQuery. I edited my post to show the current browser error. – Johnrednex Mar 13 '15 at 08:05
  • @Pete I edited my post to show the tag linking my css file. – Johnrednex Mar 13 '15 at 08:06
  • Have a look at [this post](http://stackoverflow.com/questions/9500573/path-of-assets-in-css-files-in-symfony-2), I think symfony does some sort of url rewriting so the css file isn't actually in the same place as the assets (but I'm just guessing at this as I've not used symfony). You will need to work out the relative path to your fonts folder from the rewritten css and use that. – Pete Mar 13 '15 at 08:44
  • I have already checked this post to link my css files. In fact I also posted a solution too. However linking the font needs another trick. I'm now looking at [this post](http://stackoverflow.com/questions/23443773/symfony2-assetic-css-font-icons). – Johnrednex Mar 13 '15 at 08:57
  • yeah it looks like you need to dump the fonts ni the same way as you would the asset images – Pete Mar 13 '15 at 08:58
  • Thing is, I also needed to avoid writing `@MUSCoreBundle` when I use the filter `cssrewrite`, as it's written in the documentation. – Johnrednex Mar 16 '15 at 07:17

1 Answers1

1

It looks as though you didn't include the font files to the fonts folder..?

After your edit of the original question:

you need to include the jQuery library right before bootstrap. You can download it from jquery.com or just link to an online version.

At the end it should look like this exapmle:

    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="js/bootstrap.min.js"></script>
JonSnow
  • 573
  • 14
  • 48
  • I edited my post for jquery. I did include the font files to the fonts folder. The errors are still here. Any idea what is wrong ? – Johnrednex Mar 13 '15 at 08:11