V
V
Vasily2014-07-29 17:32:20
symfony
Vasily, 2014-07-29 17:32:20

How to properly include FontAwesome in a Symfony2 project?

Such a thing - in the project it was decided to use fontawesome, the files of which were successfully copied to

@AcmeDemoBundle/Resources/public/css/plugin
@AcmeDemoBundle/Resources/public/fonts

composer update successfully transferred them to, respectively,
web/bundles/acmedemo/
but the trouble is, they are not picked up in the project and that's it, accessing
../fonts/fontawesome-webfont.woff
throws a 404 error
only helps to prescribe such a footcloth in the config
assets:
#        fontawesome-webfont-woff:
#            inputs:
#                - @AcmeDemoBundle/Resources/public/fonts/fontawesome-webfont.woff
#            output: fonts/fontawesome-webfont.woff
#        
#        fontawesome-otf:
#            inputs:
#                - @AcmeDemoBundle/Resources/public/fonts/FontAwesome.otf
#            output: fonts/FontAwesome.otf
#        fontawesome-webfont-eot:
#            inputs:
#                - @AcmeDemoBundle/Resources/public/fonts/fontawesome-webfont.eot
#            output: fonts/fontawesome-webfont.eot
#        
#        fontawesome-webfont-svg:
#            inputs:
#                - @AcmeDemoBundle/Resources/public/fonts/fontawesome-webfont.svg
#            output: fonts/fontawesome-webfont.svg
#            
#        fontawesome-webfont-ttf:
#            inputs:
#                - @AcmeDemoBundle/Resources/public/fonts/fontawesome-webfont.ttf
#            output: fonts/fontawesome-webfont.ttf
#        
#        glyphicons-halflings-regular-eot:
#            inputs:
#                - @AcmeDemoBundle/Resources/public/fonts/glyphicons-halflings-regular.eot
#            output: fonts/glyphicons-halflings-regular.eot
#            
#        glyphicons-halflings-regular-svg:
#            inputs:
#                - @AcmeDemoBundle/Resources/public/fonts/glyphicons-halflings-regular.svg
#            output: fonts/glyphicons-halflings-regular.svg
#            
#        glyphicons-halflings-regular-ttf:
#            inputs:
#                - @AcmeDemoBundle/Resources/public/fonts/glyphicons-halflings-regular.ttf
#            output: fonts/glyphicons-halflings-regular.ttf
#        
#        glyphicons-halflings-regular-woff:
#            inputs:
#                - @AcmeDemoBundle/Resources/public/fonts/glyphicons-halflings-regular.woff
#            output: fonts/glyphicons-halflings-regular.woff

in this case, after console assetic:dump (in the dev environment, respectively), everything works and this is certainly good, but for each font, prescribe everything like that, who faced it? Or who has real projects with the implementation of fontawesome share experience

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
faost, 2014-07-30
@faost

If you are using css then you can use the cssrewrite filter . But in this case, you will not be able to use the @AcmeFooBundle syntax, it is written about it below.
I use LESS in my projects, in this case everything becomes much simpler: you just need to redefine the variable that stores the path to the fonts .
Example:
src/Acme/DemoBundle/Resourcel/public/app.less (the project's main less file):

@import 'lib/fontawesome/less/font-awesome.less'; // подключаем fontawesome
@fa-font-path: "/bundles/acmedemo/fonts"; // переопределяем путь к шрифтам

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question