embedded font on website won't display in IE or Chrome - css

I have the following font setup in the CSS for a wordpress based site I'm building and the fonts display fine in FF, but not at all in IE(9) or Chrome(latest).
/* =Typography
-------------------------------------------------------------- */
#font-face {
font-family: 'Humanist';
src: url('fonts/humanist521lightbt-webfont.eot');
src: url('fonts/humanist521lightbt-webfont.eot?#iefix') format('embedded-opentype'),
url('fonts/humanist521lightbt-webfont.woff') format('woff'),
url('fonts/Humanist521LightBT.ttf') format('truetype'),
url('fonts/humanist521lightbt-webfont.svg#webfontregular') format('svg');
font-weight: normal;
font-style: normal;
}
#font-face {
font-family: 'HumanistIT';
src: url('fonts/humanist521lightitalicbt-webfont.eot');
src: url('fonts/humanist521lightitalicbt-webfont.eot?#iefix') format('embedded-opentype'),
url('fonts/humanist521lightitalicbt-webfont.woff') format('woff'),
url('fonts/Humanist521LightItalicBT.ttf') format('truetype'),
url('fonts/humanist521lightitalicbt-webfont.svg#webfontregular') format('svg');
font-weight: normal;
font-style: normal;
}
#font-face {
font-family: 'HumanistBo';
src: url('fonts/humanist777blackbt-webfont.eot');
src: url('fonts/humanist777blackbt-webfont.eot?#iefix') format('embedded-opentype'),
url('fonts/humanist777blackbt-webfont.woff') format('woff'),
url('fonts/Humanist777BlackBT.ttf') format('truetype'),
url('fonts/humanist777blackbt-webfont.svg#webfontregular') format('svg');
font-weight: normal;
font-style: normal;
}
When I need to use the font for an element, I just add font-family: 'Humanist', Arial, sans-serif;
The fonts are stored in the theme's directory in folder called "fonts".
Am I doing something wrong or missing something for it to work with other browsers?
Thanks

Internet Explorer 9 and less has some issues displaying .TTF files. It does not support embedded fonts via the CSS3 scheme without first converting into supported formats (.svg, .ttf, .eot, etc.). However, you can tweak your #Font-Face Syntax to support this.
With Chrome not displaying the correct font, this is due to different browsers having different needs. You can find more information in the second link in the more information below.
A side note as well: if your font is hosted on Google Fonts, embed a link into your website instead of hosting it yourself.
TLDR; need a comprehensive list of #font-face types
More information:
SO Question - IE problems with True Type Font files
SO Question - Font-Face problem in Chrome
Further Hardening of the Bulletproof Syntax - Fontspring.
Bulletproof #font-face syntax - Paul Irish

To use the font for an HTML element, then we need to use the #font-face rule of power full features of CSS3 that supported in many modern browser. CSS property font-family of HTML is used to defined the font name which we want to embed ans src property used to defined the path of the font to be embed.
#font-face
{
font-family: myfont;
src: url('(fontfile.eot') format('embedded-opentype'),
url('(fontfile.woff') format('woff'),
url('(fontfile.ttf') format('truetype'),
url('(fontfile.svg#(fontfile') format('svg');
}
div,h2
{
font-family:myfont;
}

Related

Custom fonts are blank and appear on loading

Our custom fonts are loaded but until they are loaded no text is displayed. This also happens with fonts loaded from Google Fonts.
Any idea why this is happening and how to use a fallback?
The following CSS is served:
#font-face {
font-family: 'ProximaNova';
src: url( '/media/fonts/proximanova-bold-webfont.eot');
src: url('/media/fonts/proximanova-bold-webfont.eot?#iefix') format('embedded-opentype'),
url('/media/fonts/proximanova-bold-webfont.woff') format('woff'),
url('/media/fonts/proximanova-bold-webfont.ttf') format('truetype'),
url('/media/fonts/proximanova-bold-webfont.svg#wf') format('svg');
font-weight: 700;
font-style: normal;
}
#font-face {
font-family: 'ProximaNova';
src: url('/media/fonts/proximanova-regular-webfont.eot');
src: url('/media/fonts/proximanova-regular-webfont.eot?#iefix') format('embedded-opentype'),
url('/media/fonts/proximanova-regular-webfont.woff') format('woff'),
url('/media/fonts/proximanova-regular-webfont.ttf') format('truetype'),
url('/media/fonts/proximanova-regular-webfont.svg#wf') format('svg');
font-weight: 400;
font-style: normal;
}
#font-face {
font-family: 'ProximaNova';
src: url('/media/fonts/proximanova-extrabold-webfont.eot');
src: url('/media/fonts/proximanova-extrabold-webfont.eot?#iefix') format('embedded-opentype'),
url('/media/fonts/proximanova-extrabold-webfont.woff') format('woff'),
url('/media/fonts/proximanova-extrabold-webfont.ttf') format('truetype'),
url('/media/fonts/proximanova-extrabold-webfont.svg#wf') format('svg');
font-weight: 800;
font-style: normal;
}
body, h1, h2, h3, button, input {
font-family: 'ProximaNova', tahoma, sans-serif;
}
While experimenting, we tried loading the custom fonts with JS after the page loaded - with the same effect. Is it a problem with the font file or is it related to Chrome's implementation of custom fonts?
This is most likely expected behavior at the moment. (See Chris Coyier's short explanation.)
Some browsers detect whether text should be displayed using a custom font, and they wait for that font to be loaded before displaying the text. This gives you a flash of invisible content (also known as FOIC). It avoids the layout shifting that can occur when text is displayed in one font and then updated to another (sometimes known as a flash of unstyled content, or FOUC). It looks like Chrome prefers the first method at the moment.
The Filament Group has published an article with workaround for this default behavior. I'm not sure how much their JS solution differs from what you tried. They're doing essentially the same thing—asynchronously loading the custom font declarations—but they also load the font directly in their async CSS file as a data URI. That may be what makes the difference.

#font-face does not work in iOS and Android

For one of my current web projects I'm using a Candara font, here's how I refer to it in my stylesheet:
#font-face {
font-family: "Candara",sans-serif;
src: url("../fonts/Candara_gdi.otf"); format('otf'),
url("../fonts/Candara_gdi.woff"); format('woff'),
url("../fonts/Candara.woff2"); format('woff2'),
url("../fonts/Candara_gdi.eot"); format('eot'),
url("../fonts/Candara_gdi.ttf"); format('truetype'),
url("../fonts/Candara_gdi.svg#Candara-Regular"); format('svg');
font-style: normal;
font-weight: normal;
}
After testing the site on mobile devices, I've noticed that Candara is not showing (the mobile devices render the fallback font, which is in this case 'sans-serif'). On the other hand, there's no problem with this font on all other desktop browsers, including the notorious IE family and Mozilla.
I'd like to mention that when I wanted to generate a webfont package here, there was a warning saying that Microsoft has blacklisted this font (see the screenshot of the warning):
Hence, I had to "manually" convert this font using some other online solutions. Any ideas on the issue and how to resolve it?
You need to remove the semi-colons after your url-declarations. A semi-colon ends the declaration for the src.
#font-face {
font-family: "Candara",sans-serif;
src: url("../fonts/Candara_gdi.otf") format('otf'),
url("../fonts/Candara_gdi.woff") format('woff'),
url("../fonts/Candara.woff2") format('woff2'),
url("../fonts/Candara_gdi.eot") format('eot'),
url("../fonts/Candara_gdi.ttf") format('truetype'),
url("../fonts/Candara_gdi.svg#svgCandara_gdi") format('svg');
font-style: normal;
font-weight: normal;
}

Custom font is not working in Firefox.

I have searched for its solution, and I think, I'm doing everything like the suggestions, but it is still not working. Custom font works on Chrome, IE, but not in Firefox. I have used font face generator to generate fonts and the code. I have placed the #font-face code in header, custom.css file (in theme_root/css/) and also in style.css, but it is not working.
Placed this in header.php:
<style>
#font-face {
font-family: 'Bebas Neue';
src: url('fonts/bebasneue.eot');
src: url('fonts/bebasneue.eot?#iefix') format('embedded-opentype'),
url('fonts/bebasneue.svg#Bebas Neue') format('svg'),
url('fonts/bebasneue.woff') format('woff'),
url('fonts/bebasneue.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}
</style>
Placed this in style.css:
#font-face {
font-family: 'Bebas Neue';
src: url('fonts/bebasneue.eot');
src: url('fonts/bebasneue.eot?#iefix') format('embedded-opentype'),
url('fonts/bebasneue.svg#Bebas Neue') format('svg'),
url('fonts/bebasneue.woff') format('woff'),
url('fonts/bebasneue.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}
Placed this in custom.css:
#font-face {
font-family: 'Bebas Neue';
src: url('../fonts/bebasneue.eot');
src: url('../fonts/bebasneue.eot?#iefix') format('embedded-opentype'),
url('../fonts/bebasneue.svg#Bebas Neue') format('svg'),
url('../fonts/bebasneue.woff') format('woff'),
url('../fonts/bebasneue.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}
Working everywhere, except Firefox. I'm confused
http://tour.khujbo.com
Also, this font works in html pages in Firefox fine. I have used this font in this template and it works on Firefox: http://khujbo.com. Seems to me, that the problem with Firefox and WordPress combination.
What should I do?
I don't think you need to define this font-face everywhere. You can place the CSS only in custom.css. And, you have defined the "Bebas Neue" font-face in your header.php with wrong URL. CSS is trying to get the font (woff, ttf, etc) from http://tour.khujbo.com/fonts/. Please correct your CSS with the right location.
BTW, my suggestion would be, you just place and load the CSS only from custom.css and remove all other definitions.
Hope this will solve your problem.
you must always be sure that the font is legal to use on your site.
However Firefox and Chrome should both support TTF.
get more info from here.
be sure u converted font to all format try this site to do http://everythingfonts.com/font-face and the path should be right !
#font-face {
font-family: 'GE SS Unique';
src: url('../../fonts/GE_SS_Unique_Light.eot');
src: url('../../fonts/GE_SS_Unique_Light.eot?#iefix') format('embedded-opentype'),
url('../../fonts/GE_SS_Unique_Light.woff') format('woff'),
url('../../fonts/GE_SS_Unique_Light.ttf') format('truetype'),
url('../../fonts/GE_SS_Unique_Light.svg#GE_SS_Unique_Light') format('svg');
font-weight: normal;
font-style: normal;}
h1,h2,h3,h4,h5,h6{
font-family: 'GE SS Unique';
}

Why do we include TTF files in font-face declaration?

If we have the following font-face setup (generated from fontsquirrel.com)
#font-face {
font-family: 'FrescoSansProNormal';
src: url('frescosanspro-normal-webfont.eot');
src: url('frescosanspro-normal-webfont.eot?#iefix') format('embedded-opentype'),
url('frescosanspro-normal-webfont.woff') format('woff'),
url('frescosanspro-normal-webfont.ttf') format('truetype'),
url('frescosanspro-normal-webfont.svg#FrescoSansProNormal') format('svg');
font-weight: normal;
font-style: normal;
}
What browser instance are we covering by using the truetype format? Aren't all the browsers covered by the other 3 (woff, eot, svg)?
Older Android browsers (namely 2.1~2.3) can't render woff/eot/svg. see http://caniuse.com/#search=woff

How do You Add Several font-faces to Separate Tags?

For a website I'm working on, the client wanted to use Roboto (by Google) as their main font. Several of the elements on the page use different styles of Roboto, such as Roboto Thin of Roboto Light. However, I have used the the #font-face selector to make the browser render the text in Roboto. My problem is that the design requires the use of different weights, not in the standard Roboto text. I'm not sure if I'm being clear enough. If you need clarification or a specific example, please ask.
PS: I found a similar thread about a similar problem, however, they use system fonts in conjuction with their #font-face. Using #fontface, how do I apply different styles to different font-families?
How do You Add Several font-faces to Separate Tags?
#font-face {
font-family: 'Crystal';
src: url('../fonts/crystalnormal.eot');
src: url('../fonts/crystalnormal.eot?#iefix') format('embedded-opentype'),
url('../fonts/crystalnormal.woff') format('woff'),
url('../fonts/crystalnormal.ttf') format('truetype'),
url('../fonts/crystalnormal.svg#crystalnormal') format('svg');
font-weight: normal;
font-style: normal;
}
#font-face {
font-family: 'FreestyleC';
src: url('../fonts/freestyle.eot');
src: url('../fonts/freestyle.eot?#iefix') format('embedded-opentype'),
url('../fonts/freestyle.woff') format('woff'),
url('../fonts/freestyle.ttf') format('truetype'),
url('../fonts/freestyle.svg#freestyle') format('svg');
font-weight: normal;
font-style: normal;
}
foo {
font-family:FreestyleC;
}
bar {
font-family:Crystal;
}

Resources