I have been using Font-Awesome and its icons for a while now, and it has been working just fine.
Today, however, it only displays blank squares instead of icons. I have read many other related questions, but none of those cases apply to me. As I said, it worked before, and I did not make any changes to the Font-Awesome files (I am using a downloaded version of FA, not the CDN) or to the HTML templates that display the icons.
So I want to start debugging the process. One example is this:
<i style="color: orange" class="fa fa-exclamation-triangle"></i>
However, I cannot find any urls in the CSS of the affected elements, when inspecting with Chrome. What I do see on every icon element though, is something like this:
.fa-warning:before, .fa-exclamation-triangle:before {
content: "\f071";
}
Where \f071 is the "blank square" character.
So my question is:
Where do the icons come from, and how can I debug no-show FA icons, in general?
UPDATE
I found out that \f071 and its friends are actually symbols referring to icons, stored in the font files. The fact that they show up as blank squares seems to indicate that the font has not been loaded successfully.
However, I checked and the client downloads fonts/fontawesome-webfont.woff and fonts/fontawesome-webfont.ttf just fine.
Also, the elements' font is correctly set through the fa class:
font-family: normal normal normal 14px/1 FontAwesome
What else is necessary to make sure, a font has loaded successfully?
UPDATE
I solved it: Font file(s) were corrupted/not delivered properly. That's always something to check out first!
FontAwesome is... a font!
This means you'll have a set of characters, which are (visually) icons. These characters are generally contained between \e000 and \f8ff (which are private use area's characters).
When you see this code:
.fa-warning:before, .fa-exclamation-triangle:before {
content: "\f071";
}
It means the \f071 character will be displayed in the pseudo-element. It's coupled with this code, which loads FontAwesome font for .fa elements:
#font-face {
font-family: 'FontAwesome';
src: url('../fonts/fontawesome-webfont.eot?v=4.2.0');
src: url('../fonts/fontawesome-webfont.eot?#iefix&v=4.2.0') format('embedded-opentype'), url('../fonts/fontawesome-webfont.woff?v=4.2.0') format('woff'), url('../fonts/fontawesome-webfont.ttf?v=4.2.0') format('truetype'), url('../fonts/fontawesome-webfont.svg?v=4.2.0#fontawesomeregular') format('svg');
font-weight: normal;
font-style: normal;
}
.fa {
display: inline-block;
font: normal normal normal 14px/1 FontAwesome;
font-size: inherit;
text-rendering: auto;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
Seeing a white square can means:
your font is not loaded (most common problem)
your font is not well created (re-download it)
your CSS is missing the font declaration (#font-face {})
your CSS is missing the font call (font: normal normal normal 14px/1 FontAwesome;)
How to debug:
Check that you're using the right class name (.fa .fa-foo)
Check that your FontAwesome CSS is loaded (it should be the case as you're seeing the square)
Double-check that your font is loaded. There could have a path issue, like font/ folder instead of fonts/
Have a look on your .htaccess. People often makes strong rules which affect assets.
If everything is ok, try to re-download the font (font files could have been corrupted)
Related
Here is the problem. So everything works fine for me on my machine, localhost and when the website is uploaded to online host. But I got my friends to go to the site to check if everything is working and the regular Roboto font loads fine but the thin version of it doesn't. I originally just had the import link from google for the font but later added the font face import code that I found on here but that doesn't work too. I even tried adding the font-weight property but it still doesn't work.
I need help my head hurts real bad here's the code enjoy
Top of the css file
#import url('https://fonts.googleapis.com/css2?family=Roboto&display=swap');
#font-face {
font-family: 'Roboto';
src: local('Roboto'), url(fonts/Roboto-Regular.ttf) format('ttf');
}
#font-face {
font-family: 'Roboto thin';
src: local('Roboto thin'), url(fonts/Roboto-Thin.ttf) format('ttf');
}
Class for one of the texts that uses the font
.txt2 { /* text */
font-family: 'Roboto thin';
font-size: 24px;
color: white;
text-align: center;
margin-top: 1%;
margin-bottom: 5%;
margin-left: 20%;
margin-right: 20%;
font-weight: 100;
}
The #font-face is loading a local file, but also, import in my experience doesn't work like how you expect. I'm on mobile so I can't get too detailed but I usually call the fonts url in the html using a tag in the head. This has the added benefit of the browser being able to pull that file in asynchronously, rather than after the css file loads, which will give you a small speed increase.
More than likely this code is actually failing for you too, but your browser has the font in cache and it's safe to use so it does. Or you have robot installed outright.
EDIT: Alright, I'm on a desktop now, and want to clarify some things.
#font-face defines a font and how it can be called. It gives it a name, where the font files are stored, and if it's considered italicized, normal, etc.
The Google Fonts file you are calling contains that information, it's whole purpose is to define the things you are putting in your #font-face lines.
As I said, #import is a bit tricky.
First and foremost, make sure your #import statement is the very first thing your CSS file contains. If you only have one #import, it should be the first line.
Using Google Fonts' other option, the HTML , will work marginally faster. The difference may stop your users from seeing a flicker of the wrong font on their first page load.
Remove the #font-face rules you have altogether, they are overwriting your imports.
As a best practice, give your font-family rule a fallback. font-family: 'Roboto thin', arial, sans-serif;
I found a gorgeous font called Slim Joe on a webpage whose link I posted below.
Even though I spent quite some time searching through their code, I couldn't find how/where exactly they included the font. I can see it being used in their CSS file (font: Slim-Joe), but I don't see where it's included in their html.
Could someone help me with including this font in my html? I understand what to do/how it looks like when I'm browsing through fonts that Google is offering (since they make it pretty easy to include in my HTML), but I can't do anything about this specific font.
The webpage where it's included:
http://presentation.creative-tim.com/ (where it says "creative tim")
How the font looks like:
https://befonts.com/big-john-slim-joe-font.html
You can include fonts into your website by css #font-face rule.
This requires having either the otf or ttf font file on your server.
To make this work you use the font-family property to name font. This is what you will use later to reference the font you have downloaded. Then you use src to map it to a ttf or otf file downloaded somewhere on your machine.
Declare it like
#font-face {
font-family: john-slim-joe;
src: url(myFontsFolder/john-slim-joe.ttf);
}
Use it like
p{
font-family: john-slim-joe;
}
To add a font to your website:
Locate the CSS file.
Create or locate your fonts folder.
Use the CSS's #font-face property to add your font file via url. This is also where you will name your font. Here's an example to follow from W3School.com's CSS #font-face Rule
After that, you can use the "font-family" property.
Hope this helps!
The website you are referring (http://presentation.creative-tim.com/) has imported the font files from given directory. Take Look at the Html header and you will find the following line:
<link href="/assets/css/fonts/Rubik-Fonts.css" rel="stylesheet" />
On this file, you can see how they imported and declared Slim-Joe font.
#font-face {
font-family: 'Slim-Joe';
src:url('../../fonts/Slim-Joe/Slim-Joe.eot?d7yf1v');
src:url('../../fonts/Slim-Joe/Slim-Joe.eot?#iefixd7yf1v') format('embedded-opentype'),
url('../../fonts/Slim-Joe/Slim-Joe.woff?d7yf1v') format('woff'),
url('../../fonts/Slim-Joe/Slim-Joe.ttf?d7yf1v') format('truetype');
font-weight: normal;
font-style: normal;
}
And usage by the nav bar css:
.navbar .navbar-brand {
font-weight: 600;
margin: 5px 0px;
padding: 20px 15px;
font-size: 20px;
font-family: "Slim-Joe";
letter-spacing: 0;
}
I'm trying to use my owns icons instead of images on my site but when I load icons from Fontastic or Iconmoon it doesn't work neither in chrome or safari, do I need a bootstrap or there is a mistake in my code?
This is the CSS from Fontastic
#font-face {
font-family: "untitled-font-1";
src:url("untitled-font-1.eot");
src:url("untitled-font-1.eot?#iefix") format("embedded-opentype"),
url("untitled-font-1.woff") format("woff"),
url("untitled-font-1.ttf") format("truetype"),
url("untitled-font-1.svg#untitled-font-1") format("svg");
font-weight: normal;
font-style: normal;
}
and how i tried to call the icon
<i class="icon-closeicon"></i>
When adding a custom icon font (such as something from icomoon) you have to do a few things.
Import the font with #font-face
Make sure you are importing the necessary css rules (ex. .icon-location:before {content: "\e947";})
Make sure your elements have the proper font-family value (the icon font you just loaded)
Make sure your elements have the correct .class name (the name of the icon you wish to call)
I have a suspicion that you are missing one of these steps (especially considering you didn't link the code in your question).
Here is an example fiddle of how a complete import of an icon font should look.
I am curretly creating a simple website. In the contact information section, I am adding this html entry ☎ for phone (right before the phone number), and this html entry ✉ for email address (right before the email address). The idea is to display those two characters as solid black characters (or any color for that matter if I choose to change the font color in CSS).
Anyway, what I ended up with is the emoji character represented by those two codes. I do not want this. I do not want the emoji representation to be displayed. I would like to see html representation as shown in the following two links:
http://www.fileformat.info/info/unicode/char/260e/index.htm
http://www.fileformat.info/info/unicode/char/2709/index.htm
(in the two links above, notice the 'phone' and the 'envolope' at the top of the page, this is what I want).
The font I am using is 'Lucida Console', and it is part of developing a theme in WordPress.
How can I do this?
Update
This seems to be a problem with WordPress. My html is part of a WordPress theme. When I try the solution with standalone web-pages, it works. However, when I try it within a theme set of files, only emoji is displayed.
So the question now becomes, how do I ensure this works in WordPress properly?
Update 2
It is suggested that this is question is a duplicate of Inconsistent Unicode Emoji Glyphs/Symbols
This is not a duplicate question. Just because they both deal with emoji, does not make them both duplicates. My question deals with emoji showing up in a web page when using a WordPress theme, the other question deals with inconsisten emoji characters in mobile devices.
You should include a webfont with support for the characters you want to use.
To include an icon font in your CSS, use the following code :
#font-face {
font-family: 'myfont';
src:url('fonts/myfont.eot?-td2xif');
src:url('fonts/myfont.eot?#iefix-td2xif') format('embedded-opentype'),
url('fonts/myfont.woff?-td2xif') format('woff'),
url('fonts/myfont.ttf?-td2xif') format('truetype'),
url('fonts/myfont.svg?-td2xif#myfont') format('svg');
// Different URLs are required for optimal browser support
// Make sure to :
// 1) replace the URLs with your font's URLs
// 2) replace `#myfont` with the name of your font
font-weight: normal; // To avoid the font inherits boldness
font-style: normal; // To avoid font inherits obliqueness or italic
}
.emoji {
font-family: 'myfont', Verdana, Arial, sans-serif; // Use regular fonts as fallback
speak: none; // To avoid screen readers trying to read the content
font-style: normal; // To avoid font inherits obliqueness or italic
font-weight: normal; // To avoid the font inherits boldness
font-variant: normal; // To avoid the font inherits small-caps
text-transform: none; // To avoid the font inherits capitalization/uppercase/lowercase
line-height: 1; // To avoid the font inherits an undesired line-height
-webkit-font-smoothing: antialiased; // For improved readability on Webkit
-moz-osx-font-smoothing: grayscale; // For improved readability on OSX + Mozilla
}
You can then include your symbol like this:
<span class="icon">☎</span>
<span class="icon">✉</span>
If you don't know a webfont that supports your character, you can easily create one yourself using the Icomoon App. See also my open source Emoji icon font for an example of an Icon font with support for Emoji characters, which I created with the Icomoon App.
More info:
Create webfont with Unicode Supplementary Multilingual Plane
symbols
If I'm not wrong this is what you want
#phone{
font-family:Lucida Console;
font-size:32px;
color:red;
}
#email{
font-family:Lucida Console;
color:#e3e3e3;
font-size:30px;
}
<div id="phone">PHONE ☎</div>
<div id="email">EMAIL ✉</div>
To force the font renderer to use the non-emoji version, you can try using a Variation Selector.
<div>PHONE EMOJI ☎️</div>
<div>EMAIL EMOJI ✉️</div>
<div>PHONE TEXT ☎︎</div>
<div>EMAIL TEXT ✉︎</div>
See more: http://unicode.org/Public/8.0.0/ucd/StandardizedVariants.html
Chrome 26.0.1410.64m on Windows 8 has problems rendering WebFonts. It is a known problem and a solution is to first serve the svg version of the font instead of the woff version. It fixes the anti-aliasing and makes font look pretty again.
The downside of this method is the weird rendering inside the element inside select inputs.
I added a jsfiddle to see it in action : http://jsfiddle.net/4mSpv/6/.
The CSS is as simple as it can be.
#font-face {
font-family: 'Montserrat';
src: url('https://raw.github.com/louh/website/master/fonts/montserrat-regular-webfont.svg#montserratregular') format('svg');
font-weight: 400;
font-style: normal;
}
select {
font-family: 'Montserrat', sans-serif;
}
I remove the local installation of a font and noticed an other windows 7 computer doing the same. Anyone knows what is going on with chrome? (IE, Firefox, Safari all render fine)
PS: Other browser fonts not included in JSFiddle to filter out the problem and each browser have their own quirks (not allowing font-size etc) but render the text fine
There is no way to solve this problem.
This is NOT a Regression issue and is existing from M24.
I submitted a bug report and it Weird character rendering in option menu
As automaticoo stated, it is a known issue with Chrome. However, you can workaround the issue with a technique mentioned in the selected answer for this post: Google Webfonts Render Choppy in Chrome on Windows.
#media screen and (-webkit-min-device-pixel-ratio:0) {
select {
font-family: Arial; /* standard font */
}
}
That way you can use whatever font you want for browsers that still work, and replace it with a generic HTML font for Chrome.
So, I was actually looking for an answer for this, and I stumbled upon this question. I noticed this bug still exists today ( I just met it, such a happy meeting... ). Now I only found 1 solution, which is placing the svg font last in the #font-face declaration (this also means including all other formats). The only problem is that, when you for exampling try fixing the font rendering (to make it all smooth and stuff) you'd actually put the svg first.
Here are some examples to demonstrate it
1: SVG font last, no crisp font, options are displayed right
#font-face {
font-family: 'OpenSansLight';
src: url('../font/OpenSans-Light-webfont.eot');
src: url('../font/OpenSans-Light-webfont.eot?#iefix') format('embedded-opentype'),
url('../font/OpenSans-Light-webfont.woff') format('woff'),
url('../font/OpenSans-Light-webfont.ttf') format('truetype'),
url('../font/OpenSans-Light-webfont.svg#open_sanslight') format('svg');
font-weight: normal;
font-style: normal; }
So as you can see, the options in the select box show just fine, but the font really isn't that crips, just look at "Register" (you might notice this better in comparison with my second example)
2: SVG font last, crisp font, stupid options in select
#font-face {
font-family: 'OpenSansLight';
src: url('../font/OpenSans-Light-webfont.eot');
src: url('../font/OpenSans-Light-webfont.eot?#iefix') format('embedded-opentype'),
url('../font/OpenSans-Light-webfont.svg#open_sanslight') format('svg'),
url('../font/OpenSans-Light-webfont.woff') format('woff'),
url('../font/OpenSans-Light-webfont.ttf') format('truetype');
font-weight: normal;
font-style: normal; }
Now you will see that the font is a lot more crisp but the select is really stupid.
I suggest adding another font-face with the svg last just for select's. This will keep your fonts crisp throughout the website but display the options just fine.