How do I "pull-out" only the dozen icons I actually use?

All we need is an easy explanation of the problem, so here it is.

I have an angular project that is built using grunt which uses maybe a dozen icons from font-awesome. Currently, I’m including and thus distributing the entire font-awesome library. Is there a way to “pull-out” only the icons I actually use (preferably as part of the build process)?

I’ve seen the icomoon app, and that seems to give me the result I want, but it’s a manual process to update when icon usage changes.

How to solve :

I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.

Method 1

First use Font-Awesome-SVG-PNG to get individual SVG files for each Font Awesome icon.

font-awesome-svg-png --color black --sizes 128 --no-png

Then using grunt-webfont, combine the icons of your choosing (from the SVGs generated in the previous step) into a custom webfont.

For example, if you only want to include icons which have angle- keyword in your webfont, then the grunt task would be like –

webfont: {
    icons: {
        src: 'black/svg/angle-*.svg',
        dest: 'build/fonts'
    }
}

Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply