bokmann / font-awesome-rails

the font-awesome font bundled as an asset for the rails asset pipeline
http://fortawesome.github.com/Font-Awesome/
MIT License
1.86k stars 244 forks source link

Simple font subsetting? #193

Closed david-a-wheeler closed 6 years ago

david-a-wheeler commented 6 years ago

My application only uses a few symbols from font awesome, and the font is one of the largest required components in the critical path.

It'd be great if I could just list the symbols I want, and font-awesome-rails would then create a subset file with ONLY those fonts. I imagine that there's a way to do that using the Rails asset pipeline, but I didn't see simple step-by-step instructions on how to do this.

There may not even need to be any more code; this may be just "please document step-by-step instructions on how to do this". I imagine many people only use a small subset of font awesome, and since fonts are typically on the critical path for display, it's nice to make them smaller.

Thanks so much!!

rmm5t commented 6 years ago

font-awesome-rails is just a wrapper for the core FontAwesome resources. i.e. A subset of the raw font files cannot be applied programmatically from these static resources.

However, you can build your own version of FA by following these instructions: https://github.com/FortAwesome/Font-Awesome/wiki/Customize-Font-Awesome

This somewhat defeats the purpose of using font-awesome-rails, but, in theory, if you're also able to take the newly generated font assets and get them in front of the asset path such that font_path prefers them over the assets included with this gem, you might be able to fully accomplish what you're after. https://github.com/bokmann/font-awesome-rails/blob/master/app/assets/stylesheets/font-awesome.css.erb#L7-L15

Overall, this is all currently outside the scope of gem; however, if there's something we can add to the included stylesheet here that would make it easier to reference customized font assets, I'd be willing to review a PR for that.