Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Font Awesome icons don't show up correctly during development, installed with bower

I scaffold my app with yo

yo gulp-webapp //I create a basic boilerplate with bootstrap sass

Then I install FontAwesome

bower install font-awesome --save

This is what I have on top of my main.scss

$icon-font-path: "../bower_components/bootstrap-sass-official/assets/fonts/bootstrap/";

// bower:scss
@import "../../bower_components/bootstrap-sass-official/assets/stylesheets/_bootstrap.scss";
@import "../../bower_components/fontawesome/scss/font-awesome.scss";
// endbower

Then I add this to my html page

<i class="fa fa-angle-right"></i>

And if I launch "gulp serve" It only show a white square, instead if I build with "gulp" the result html works correctly.

The result main.css contain all fa class so I think the problem is with this var

$fa-font-path:        "../fonts" !default;

This var is here: bower_components/font-awesome/scss/-variables.scss

like image 580
gagna Avatar asked Jan 14 '15 16:01

gagna


People also ask

How do I fix Font Awesome icons not showing?

If you installed the Free Font Awesome version but try adding Pro icons to your web pages, they won't show. The solution to this is either you use the alternative free icons or upgrade to a Pro subscription/license.

How do I make Font Awesome icons accessible?

If an icon is not an interactive element The simplest way to provide a text alternative is to use the aria-hidden="true" attribute on the icon and to include the text with an additional element, such as a <span> , with appropriate CSS to visually hide the element while keeping it accessible to assistive technologies.

How do I give Font Awesome icons in CSS?

Add Icons to HTML We recommend using <i> element with the Font Awesome CSS classes for the style class for the style of icon you want to use and the icon name class with the fa- prefix for the icon you want to use.

How do I fix Font Awesome icons not showing in Wordpress?

To fix this problem, firstly you need to go to your admin dashboard. Go to the “Elementor” > “Settings” and open the “Advanced” tab. Here you need to find the “Load Font Awesome 4 Support” option and activate it.


2 Answers

Try to set the

$fa-font-path: "fonts" !default;

in the main.scss file before the @import declarations.

That did the trick for me. Also, from the font awesome page (http://fortawesome.github.io/Font-Awesome/get-started/) it states:

PRO: Custom LESS or SASS

Use this method to customize Font Awesome 4.2.0 using LESS or SASS.

Copy the font-awesome/ directory into your project.

Open your project's font-awesome/less/variables.less or font-awesome/scss/_variables.scss and edit the @fa-font-path or $fa-font-path variable to point to your font directory.

@fa-font-path: "../font";

The font path is relative from your compiled CSS directory. Re-compile your LESS or SASS if using a static compiler. Otherwise, you should be good to go. Check out the examples to start using Font Awesome!

like image 144
kpagan Avatar answered Nov 15 '22 07:11

kpagan


I use the gulp build process from generator-gulp-angular which uses wiredep to inject the bower dependencies.

But for some reasons the fontawesome does not work out of the box. Actually I had following problems:

  • The font-awesome.css was not injected in the index.html
  • When building the dist version the font files were not present in the fonts directory

Finally I found this very helpful message by silvenon

Append overrides to your bower.json:

{
    "name": "webapp",
    "dependencies": {
        "modernizr": "~2.6.2",
        "jquery": "~1.11.0",
        "fontawesome": "~4.0.3"
    },
    "devDependencies": {},
    "overrides": {
        "fontawesome": {
            "main": [
                "css/font-awesome.css",
                "fonts/fontawesome-webfont.eot",
                "fonts/fontawesome-webfont.woff",
                "fonts/fontawesome-webfont.ttf",
                "fonts/fontawesome-webfont.svg"
             ]
         }
     }
}

After that the wiredep task will inject the css in the index.html and also copy the font files to the fonts folder.

like image 43
RenRen Avatar answered Nov 15 '22 08:11

RenRen