Font Awesome icons not being shown - css

I'm struggling with webpack to manage my assets right now.
I've installed font-awesome with yarn, and imported the .css files in my web page.
My problem is that, even though my html recognises the classes from font-awesome.css, the icons im trying to use are shown ass squares filled with four numbers (which identify the icon)
My webpack code is:
// webpack.config.js
var Encore = require('#symfony/webpack-encore');
const HandlebarsPrecompiler = require('webpack-handlebars-precompiler');
Encore
// the project directory where all compiled assets will be stored
.setOutputPath('web/build/')
// .addEntry('fs', 'empty')
// the public path used by the web server to access the previous directory
.setPublicPath('/build')
.addEntry('fonts/glyphicons-halflings-regular.ttf', './node_modules/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf')
.addEntry('fonts/glyphicons-halflings-regular.eot', './node_modules/bootstrap/dist/fonts/glyphicons-halflings-regular.eot')
.addEntry('fonts/glyphicons-halflings-regular.svg', './node_modules/bootstrap/dist/fonts/glyphicons-halflings-regular.svg')
.addEntry('fonts/glyphicons-halflings-regular.woff', './node_modules/bootstrap/dist/fonts/glyphicons-halflings-regular.woff')
.addEntry('fonts/glyphicons-halflings-regular.woff2', './node_modules/bootstrap/dist/fonts/glyphicons-halflings-regular.woff2')
.addEntry('fonts/font-awesome', './node_modules/components-font-awesome/css/fontawesome.css')
.addEntry('fonts/fontawesome-webfont.eot', './node_modules/font-awesome/fonts/fontawesome-webfont.eot')
.addEntry('fonts/fontawesome-webfont.svg', './node_modules/font-awesome/fonts/fontawesome-webfont.svg')
.addEntry('fonts/fontawesome-webfont.ttf', './node_modules/font-awesome/fonts/fontawesome-webfont.ttf')
.addEntry('fonts/fontawesome-webfont.woff', './node_modules/font-awesome/fonts/fontawesome-webfont.woff')
.addEntry('fonts/fontawesome-webfont.woff2', './node_modules/font-awesome/fonts/fontawesome-webfont.woff2')
.addEntry('css/bootstrap', './node_modules/bootstrap/dist/css/bootstrap.css')
.addEntry('css/bootstrap-theme', './node_modules/bootstrap/dist/css/bootstrap-theme.css')
.addEntry('css/bootstrap-datepicker', './node_modules/bootstrap-datepicker/dist/css/bootstrap-datepicker.css')
.addEntry('css/app', './src/SgbBundle/Resources/public/css/app.css')
// export the final configuration
module.exports = Encore.getWebpackConfig();
The thing is that in the inspector, when I see the rules being used in some html content like
<i class="fa fa-graduation-cap fa-4x" aria-hidden="true" id="icon"></i>
recognises the 'fa' class, the 'fa-4x' class but no the 'fa-graduation-cap' class. And the icon is shown as an empty square.
Thanks.

I've found the answer.
I've installed two versions of font-awesome via Yarn add.
One is components-font-awesome and the other one just font-awesome.
If you check on my webpack configuration, Im adding files from this two dependencies.
.addEntry('fonts/font-awesome', './node_modules/components-font-awesome/css/fontawesome.css')
.addEntry('fonts/fontawesome-webfont.eot', './node_modules/font-awesome/fonts/fontawesome-webfont.eot')
I solved my issue by just using font-awesome
.addEntry('fonts/font-awesome', './node_modules/font-awesome/css/fontawesome.css')
.addEntry('fonts/fontawesome-webfont.eot', './node_modules/font-awesome/fonts/fontawesome-webfont.eot')
And deleting 'components-font-awesome'.
To sum up, I was trying to use files from two same but different packages.

fa-graduation-cap is a new icon class in Font Awesome 5.0.0. The equivalent icon class in version 4 was fa-mortar-board.
So you'd need to make sure that you're loading Font Awesome 5 and not 4 if you want to use that v4 name. It's not evident from your code listing above which version of Font Awesome you're loading.
You can find a reference on upgrading from version 4 to version 5, including the full list of icon classes that changed from v4 to v5 here.
Or if you're stuck in Font Awesome 4 and you need a version 4 reference to lookup icon names and codes, make sure you use the older one here. A link to that is found in the footer links on fontawesome.com.

try adding it from CDN, The link is below
https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css
There is No error in tag

Related

Target Angular 4 CSS to a single page div

Good afternoon.
Premise: I’m not a web developer and I have little familiarity with all these new names that emerge as mushrooms from one moment to the next. Then I ask you not to give nothing for granted.
My question is very simple: I want to target bootstrap 4 style only on a specific elements (e.g. a div) of my page: the rest of the page hasn't to be involved with this styles.
I notice that a colleague of mine used LESS on an older bootstrap version but I red that it is not support in Bootrastrap 4.
Any ideas?
Thanks,
Sergio
I think to have found the solution but I'd like know if it is the right way.
Here my steps:
I downloaded Bootstrap 4 files using
npm install bootstrap#4.0.0-alpha.6
from dos prompt inside a local folder
Then I modified bootstrap.scss file placed inside node_modules\bootstrap\scss surrounding all code with a class (e.g. .thisismyclass{...})
I then downloaded Koala from this site
http://koala-app.com/
I added the entire local folder (where the boostrap files are) in the Koala UI.
Automatically it create the .css files near the scss files with the reference to my manually added class.
Now, in my page, I added the refernce to my new css and then I added my main class to the div which must use Bootstrap styles.
It's right?
Thanks,
Sergio

Bootstrap not including any glyphicons

First time using bootstrap. I added "bootstrap":"3.3.7" to my dependencies in my bower.json file and it adds to my wwwroot/lib folder but I know it's supposed to include a fonts folder in the bootstrap directory, but it's not there. I tried downloading the bootstrap.zip file from their website, extracting that file and then adding the fonts folder included in that download to my bootstrap directory, but it still didn't work. I've tried looking in bootstrap.css file for the #font-face for glyphicons but there are none. I am just learning how to implement everything into an ASP.Net Core app so I'm new to these technologies.
I think the #font-face is defined in fontawesome. Also, unless you have at least one html element using the font, it will not be requested. So you need to use the font in a style rule (the #font-face doesn't count).
Therefore, download fontawesome and then add an element to your html and then the font will be requested. An element like this for example:
<span class="glyphicon glyphicon-asterisk"></span>

Extend FontAwesome with IcoMoon

In a project with the Meteor javascript framework, I'm using Fontawesome to display my icons.
I want to add my custom icons to FontAwesome. Looking around, I understand that IcoMoon is exactly the tool I need.
But I don't understand how I can add an icon taken in IcoMoon to FontAwesome.
Can someone help me :)
Thanks
This is not a meteor question, but an icomoon question. The answer is that you don't add an icomoon set to font-awesome, rather you let them run together side by side.
What is meteor specific is how you can access those fonts, so they will need to be in your /public/directory.
You can find an example of this through my meteor starter set. You would put your extracted icomoon fonts inside of that /assets/ directory. Then inside of /client/less/ (or sass if you use that) you would put your icomoon file as an import. Finally from your main less file you would import the file like #import "/less/icomoon.import.less"; at the top of your document.

Bootstrap SASS in Visual Studio 2013 wrong font path

So,
I have used bower to install bootstrap SASS files into my application.
I am using AngularJS and want to use my own directory structure instead of the default Content path defined by MVC.
So I have installed https://github.com/twbs/bootstrap-sass and in my core SASS file I have imported the bootstrap SASS like this:
#import "../bower_components/bootstrap-sass/assets/stylesheets/bootstrap";
everything loads in my application and the site is definitely using bootstrap, but whenever I try to use a glyphicon I just get a square instead of the icon. Looking in the console I can see that the path to the glyphicons is wrong. It is showing:
http://localhost:58859/assets/fonts/bootstrap/glyphicons-halflings-regular.ttf
but it should be
http://localhost:58859/assets/bootstrap-sass/assets/fonts/bootstrap/glyphicons-halflings-regular.ttf
Now I "could" edit the variables file and change this line:
// [converter] If $bootstrap-sass-asset-helper if used, provide path relative to the assets load path.
// [converter] This is because some asset helpers, such as Sprockets, do not work with file-relative paths.
$icon-font-path: if($bootstrap-sass-asset-helper, "bootstrap/", "../fonts/bootstrap/") !default;
to something like this:
// [converter] If $bootstrap-sass-asset-helper if used, provide path relative to the assets load path.
// [converter] This is because some asset helpers, such as Sprockets, do not work with file-relative paths.
$icon-font-path: "/assets/bootstrap-sass/assets/fonts";
but whenever someone loads my project from github and bower resolves bootstrap my changes to that file will be lost. I have noted in their documentation they talk about sprockets and mincer, but I have never used these so I have no idea what they are for.
My question is, can I change the font path without editing the SASS file directly?

Glyphicon Pro in Bootstrap 3

I would like to use Glyphicons Pro (Social and Filetypes as well). But bootstrap has a different way for icons.
In bootstrap: glyphicon glyphicon-ok
In glyphicon: glyphicon ok
IMHO the last option is better.
My question is: how can I use glyphicons pro in bootstrap, as the glyphicon class is already reserved by halflings.
My ideas:
remove halflings from bootstrap, and use the one provided by glyphicon
integrate the pro icons into bootstrap, but the mentioned question needs to be answered first
There are many similar questions on stackoverflow, and they are either about replacing halflings or not properly answered.
You should compile a Bootstrap version without the gylphicons component here.
Just uncheck Glyphicons under components, then go to the bottom and click "Compile and download".
After that you can include Glyphicons Pro without conflict in class names.
The following approach worked for me as of Bootstrap 3.3.6:
Download and extract Bootstrap source locally.
you#home:~$ mkdir bs3_src && cd bs3_src/
you#home:~bs3_src/$ git clone https://github.com/twbs/bootstrap.git .
Extract Glyphicons Pro package and navigate to the "Glyphicons Regular" family glyphicons.less file under (src)/glyphicons_pro/glyphicons/web/html_css/less. Replace bootstrap/less/glyphicons.less with this one. Replace all of the halfling font files with their glyphicons-regular.* counterparts from the PRO source into bootstrap/fonts/. If you desire the .social and .filetype fonts, add glyphicons-filetypes.less and glyphicons-social.lessfrom their respective subfolders into bootstrap/less/ (don't forget to push their font files to bootstrap/fonts/ as well).
Open bootstrap/less/bootstrap.less for editing. You are looking for the early import declarations:
...
#import "glyphicons.less";
// Extras go here:
#import "glyphicons-filetypes.less";
#import "glyphicons-social.less";
...
Install node/npm and grunt if you haven't done so yet as per Bootstrap's "Getting Started" section's instructions. Proceed:
you#home:~/bs3_src$ npm install
you#home:~/bs3_src$ grunt dist
By now your bootstrap/dist/ folder should have a glorious set of combined *.css, *.min.css and *.map files with the appropriate font families, along with all of the other PRO add-on goodies. Copy it's sub-folders into your project's assets and link accordingly.
The good thing about this approach is that it can be automated as a workflow (check this related post) to incorporate periodic updates from Bootstrap or Glyphicons, not to mention any custom .less that needs to be compiled.
As far as overriding the class schemes, i.e. "glyphicons glyphicons-ok" => "gi gi-ok": Any regex or repl type operation on the source less files before compiling would quickly achieve this. You'll simply have to be vigilant to make sure any of your other third-party apps aren't affected adversely.

Resources