Why font-awesome icons are not displayed in Mozilla firefox? [duplicate] - html

I am having an issue with using a font accessed via a relative URL.
#font-face {
font-family: 'ElegantIcons';
src:url('../src_main/fonts/ElegantIcons.eot');
src:url('../src_main/fonts/ElegantIcons.ttf') format('truetype'),
url('../src_main/fonts/ElegantIcons.svg#ElegantIcons') format('svg'),
url('../src_main/fonts/ElegantIcons.woff') format('woff'),
url('../src_main/fonts/ElegantIcons.eot?#iefix') format('embedded-opentype');
font-weight: normal;
font-style: normal;
}
When I access the web page the font doesn't work and in the console I get this:
downloadable font: download failed (font-family: "ElegantIcons" style:normal weight:normal stretch:normal src index:1): status=2147500037
source: file:///...snipped.../src_main/fonts/ElegantIcons.woff # file:///...snipped.../src_poke/fonts-style.css
Accessing the file by copying/pasting the URL into the browser address bar shows that it is the correct URL as I can download the font.

A hat tip to Jonathan Kew's response on a relevant mozilla bugzilla entry:
I believe this is working as designed. AIUI, the issue here is that
for a page loaded from a file:// URI, only files in (or below) the
same directory of the filesystem are considered to be "same origin",
and so putting the font in a different subtree (../font/) means it
will be blocked by security policy restrictions.
You can relax this by setting security.fileuri.strict_origin_policy to
false in about:config, but as this gives the page access to your
entire local filesystem, it's something to be used with caution.
To summarise, the "fix" without re-arranging your files:
Open about:config
Set security.fileuri.strict_origin_policy to false
Beware of the security implications
The best way is, however, to make sure any resources are accessible without going back up the file system first.
Note: the origin policy is calculated based on the html, NOT the css file! So a font file right besides an css file might not work, which is very confusing. (At least this is what I thought was the case with Firefox!)
Follow ups:
eradman comments:
It's the other way around: relative paths are relative to the CSS file.
chrylis responds:
You'd think that, but the actual code in Firefox doesn't seem to agree.

For local file we have to use local()
For external we have to use url()
According to the document https://developer.mozilla.org/en-US/docs/Web/CSS/#font-face
For example
src:local('../src_main/fonts/ElegantIcons.eot');

#CharlesGoodwin #eradman Actually, both statements about the origin seem true except that they probably talk about two different things: same-origin check is based on the originating HTML file, while relative URLs for font faces are resolved relative to the CSS file containing the #font-face rule.
Moreover, originating HTML file is not the file that uses the font. I have the following local file structure.
<base-directory>/index.htm
<base-directory>/ARPLS/toc.htm
<base-directory>/dcommon/css/fonts.css
<base-directory>/dcommon/fonts/myfont.woff
fonts.css references myfont.css via url(../fonts/myfont.woff) and toc.htm reference fonts.css via <link ... href="../dcommon/css/fonts.css">. index.htm has a hyperlink to toc.htm.
Now, I have bookmarked both index.htm and toc.htm. If I use the index.htm bookmark, the font is rendered correctly. If I use the toc.htm bookmark, the font fails to load. I guess this is because myfont.woff is in a sub-directory of the directory containing index.htm but not of the directory containing toc.htm.
Observed in Firefox 38.6.

Try adding this to your web.config
<system.webServer>
<staticContent>
<clientCache cacheControlCustom="public" cacheControlMode="UseMaxAge" cacheControlMaxAge="365.00:00:00" />
<remove fileExtension=".woff" />
<remove fileExtension=".woff2" />
<mimeMap fileExtension=".woff" mimeType="application/x-font-woff" />
<mimeMap fileExtension=".woff2" mimeType="application/font-woff2" />
</staticContent>

Usually this happens when the original source css has relative font face declaration like so ../fonts/some-font.woff, and you compile that source CSS into bundle.css which resides at some other path. So that way you lose the path to font.

I have been running into this issue since the latest update (about 1.5 weeks ago). This thread specifically, plus the comments in Bugzilla helped me to understand the problem as a security feature. The solution that I found (eventually) was to take my Firefox preferences off of "strict" security and set to standard/default. "Strict" even says it will break some sites, so I think that this goes to the above point that this issue is by-design.

Related

Local css file loads, direct address fails

Here is the HTML I am having problems with:
<link rel="stylesheet" href="http://resources.8thdaystudio.com/neonlights.css" type="text/css" />
I have a copy of the css file in my page's local folder, and when I put neonlights.css in the href, it works. I have a copy in my resources server to use from any of my pages, but it's not applying the css when I do the direct link. Using inspect in Chrome it's not showing me an error loading the file but still not applying the css.
it is observed that the url:
http://71.57.185.233:82/neonlights.css loads as text/css
but http://resources.8thdaystudio.com/neonlights.css loads as text/html.
It's due to your server's configuration as you indicated. I have verified this in Fiddler.
Through some reading about MIME types I figured out that the likely problem is my server. I'm running Servers Ultimate Pro on an Android device and I believe it's sending the file with the incorrect type.

Cannot Get FontAwesome Working in IE 11 with MVC 5

I have a new MVC 5 Project and I am trying to get FontAwesome to display icons from the _Layout page. It works fine in Chrome, Firefox, and even the Page Inspector in Visual Studio. When I launch the site in IE 11, it just shows a blank space.
What I've tried so far:
Making sure the font-awesome.css and fonts are being downloaded to the browser
Checking the paths to the directory where the fonts exists is correct
Loading from the BundleConfig and just putting the links directly on the Layout page
Installing FontAwesome using Nuget and tried an Nuget Html Helper for FontAwesome
Tried added MIME types for the fonts to the web.config
Tried using CDNs and Fully qualified paths instead of relative links
Tried several variations of the markup
Validated no errors in the Console or 404s in the Network Debugger
I'm not sure what else I can try and feel like I've spent WAAAY to much time just trying to get some icons to work. It's just frustrating because the site looks really good in Chrome and Firefox.
I am using a Template I downloaded from WrapBootstrap, but their examples work in IE 11, and I've tried to mimick their markup as best I can.
Below is the markup in the Layout page I am using and this comes directly from their Template and it works in FF/Chrome.
<i class="icon-dashboard"></i>
and I tried
<i class="fa fa-dashboard"></i>
Any guidance on troubleshooting would be appreciated.
It's not really that complicated. If it works in Chrome and Firefox it will work in IE11. My guess is that you've either switched the rendering engine to IE7 at some point and forgot, accidentally clicked the compatibility mode button (which renders as IE7), or otherwise are working in compatibility mode (depending on your local or GP settings, if this is a work machine, compatibility mode may be the default for local and/or intranet sites).
I just had this issue but found that it was actually caused by the fact the font files reside on a different subdomain. Adding an Access-Control-Allow-Origin header when serving the fonts solves the problem.
Apache .htaccess snippet
<FilesMatch "\.(ttf|otf|eot|woff)$">
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
</IfModule>
</FilesMatch>
nginx virtual host file snippet
location ~* \.(eot|otf|ttf|woff)$ {
add_header Access-Control-Allow-Origin *;
}
More information can be found here (original source for snippets).
Another possibility (which I just spend 4 hours debugging) is that IE-11 is falling back to an older document compatibility mode without your knowledge. The thing to do is make sure the auto-detected target really reads "Edge". In my case it was blank.
The files were downloading.
The MIME types and headers were right.
My document had the right compatibility meta tag set.
I could surf just fine.
The console showed no JS errors (or errors of any kind).
Yet still no Fontawesome.
Turns out if your HD is running low on space as my VM was and the available temp cache falls below a certain size, IE silently reverts to showing all websites in compatibility mode (no matter what your settings are in regard to when to use compatibility mode).
Try this in your web.config. It should work for Font-awesome 4.7:
<system.webServer>
<staticContent>
<remove fileExtension=".svg" />
<remove fileExtension=".eot" />
<remove fileExtension=".woff" />
<remove fileExtension=".woff2" />
<remove fileExtension=".otf" />
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
<mimeMap fileExtension=".eot" mimeType="application/vnd.ms-fontobject" />
<mimeMap fileExtension=".woff" mimeType="application/font-woff" />
<mimeMap fileExtension=".woff2" mimeType="font/woff2" />
<mimeMap fileExtension=".otf" mimeType="application/font-sfnt" />
</staticContent>
</system.webServer>

Is putting your favicon.ico file in a non-root path a bad idea?

When and how do browsers request the favicon.ico file? Do they always check for it in root, or do they read the content of the webpage first to see if the page specifies the location?
I have my favicon.ico path in /images
There is the following tag in each of my pages:
<link rel="shortcut icon" href="images/favicon.ico">
When I load the page in my browser, it seems to work (I can see the file), but I don't know whether they are making bad requests to my root folder first (where the file doesn't exist), and are later making a request to the link.
I want to minimze 404's and wasted bandwidth, by the browser making incorrect calls to my site.
EDIT: I'm looking for some insight into how browsers work, and request this file, so my site structure is efficient.
Remember that not all requests to your site are for HTML pages! Requests for non-HTML content, like bare image files (e.g, viewing http://example.com/image.jpeg directly in the browser), cannot see a <link> tag. Therefore, they must fall back to searching for the shortcut icon in the standard location at /favicon.ico.
This still doesn't mean that this needs to be the canonical location, though! You can still keep it in /images/favicon.ico if you want - just make sure that a redirect is in place from /favicon.ico to wherever your preferred location is.

Where is the favicon defined for this site?

Looking at the source for Skype.com, I cannot find any <link rel="shortcut icon"> tag (or anything similar), and yet, the icon is clearly showing up in FireFox. Where are they defining the favicon?
http://www.skype.com/en/ (right click to view source)
Unless otherwise defined, the browser will look for the favicon in the root with the filename favicon.ico
www.skype.com/favicon.ico
As far as I know you need the exact name favicon.ico for the browser to detect it. That might be different in other browsers, but if you want to use .png instead of .ico for some reason it would be safer to call it out manually for browser compatibility even if the newer browsers are seeing it.
By default browsers will look in the root web directory for favicon.ico when a path is not explicitly specified by a <link> tag.

#font-face working when local but not when upload to hosting space

I am building a website and I attempting to get cross-browser compatibility with a free font named Tex Gyre Cursor.
So far I have tried several ways which I have found searching though Google.
Site 1, Site 2 & Site 3
They have worked when testing them locally on Chrome, Firefox, Safari and Opera. Not on IE though. I'm not to bothered about IE since it's a massive pain in the arse and I have set Tahoma as the back-up font for this.
The problem arises after I have uploaded my files via FTP File Manager. The web host is GoDaddy.
I have uploaded the font files too.
I visit the site but the font is Tahoma, this occurs on all browsers previously mentioned.
I'm at my wits end and cannot discern the problem.
This was my first attempt with the CSS:
#font-face{
font-family:'TexGyreCursor';
src: url('fonts/texgyrecursor.eot');
src: local('texgyrecursor'),
local('texgyrecursor'),
url('fonts/texgyrecursor.ttf') format('truetype'),
url('fonts/texgyrecursor.svg#font') format('svg'),
url('fonts/texgyrecursor.otf');
}
My second attempt:
#font-face{
font-family:'TexGyreCursor';
src: url('fonts/texgyrecursor.eot');
src: url('fonts/texgyrecursor.otf');
}
If anymore information is needed please let me know :)
I recently had this issue, I was designing on windows machine with xampp and uploading to linux server.
I finally figured out that the font files were CamelCase and the css code was all lowercase.
It didn't bother my local machine, but linux sees CAPITALS.font and capitals.font as 2 seperate files.
You might want to check to see if that is issue your having.
I have come across many font embedding issues, whether it's hosting the fonts and CSS file on a different server or IE being an absolute !#?#.
In IE, press 12 which will bring up your developer tools and check to see what error is shown (if any). If you're being shown any of the following errors:
CSS3111: #font-face encountered unknown error.
my-font.eot
CSS3117: #font-face failed cross-origin request. Resource access is restricted.
my-font.eot?
I'd suggest following a thread I opened a few months ago which might help: #font-face import not working in offline website/different host using online fonts via CSS in IE only. This was an issue for IE only so wouldn't be surprised if you're having the same issue. I had other issues when transferring the font to a different server.
For any future font embedding, I would strongly suggesting using the following CSS code and ensuring all file types involved are converted correctly:
#font-face {
font-family:'My-Font';
src:url('../includes/fonts/my-font.eot');
src:url('../includes/fonts/my-font.eot?#iefix') format('embedded-opentype'),
url('../includes/fonts/my-font.woff') format('woff'),
url('../includes/fonts/my-font.ttf') format('truetype'),
url('../includes/fonts/my-font.svg#my-font') format('svg');
font-weight:normal;
font-style:normal;
}
just wanna help you guys quick,
First: Put this in .htaccess
<FilesMatch "\.(ttf|otf|eot)$">
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
</IfModule>
</FilesMatch>
Secondly: Go to where you have hosted the site, in my case it's cpanel and check for the file permission, it should be 755 from the fonts folder till the font(s).
There shouldn't be any errors with the code; it should be a browser or network problem.
Try clearing all the cache and reloading the page several times.
If that still doesn't work, go to Chrome, load the page, press F12, go the the Network tab, and reload the page. See if the browser loads the font CSS file and the fonts.
If there is a 404 Not Found error, point your browser to the font files directly (yourdomain.com/fonts/texgyrecursor.ttf).
If you can't access the font file directly, check whether or not you've uploaded it. Then check the permissions of the file.
If that still doesn't work, try to add the <link> tag that Google Webfonts provides, then uploading.
Hope that fixes it!
Exactly! the solution is to call fonts from css respecting case sensitive. for example is not the same call like this: url (font / arial.ttf) a ARIAL.TTF file must be url (font / ARIAL.TTF)
I've just had the same problem, turns out there was a capital letter on my "Fonts" folder, I renamed it woth FileZila and now it works just fine!
The server has utf8 support. So, it is not necessary to install language fonts separately. If you need an additional fonts to be installed in your website upload the font file in your websites font folder. But, if any language is not supporting than you need to enable the support of utf8 on you server. You can do it by putting below mentioned code in head tag-
<meta http-equiv=Content-Type content=text/html; charset=utf-8 />
I've had the similar issue - and just resolved it by replacing the font URL/path.
1. add this into your head tag
<meta http-equiv=Content-Type content=text/html; charset=utf-8 />
identify your font family on your script, you can find it on the font link/url on your script.
this is mine:
<link href='http://fonts.googleapis.com/css?family=Roboto:400,100,100italic,300,300italic,400italic,500italic,700,500,700italic,900,900italic' rel='stylesheet' type='text/css'>
from the above details, I can find the font family is ROBOTO.
then I visit GoogleFont Website - then find my required font.
my font:
search font: roboto
category: sans-serif
once you found the required font - click on the 'select this style' button, then you will get the link/path like this:
link rel="preconnect" href="https://fonts.googleapis.com"
link rel="preconnect" href="https://fonts.gstatic.com" crossorigin
link href="https://fonts.googleapis.com/css2?family=Roboto:wght#100;400&display=swap" rel="stylesheet"
copy it to your script.
clear your browser cookies/cache or try it on private browser (incognito)