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.
Related
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';
}
I'm using bootstrap-wysiwyg inside a popover. Here's a demo (only the bold is actually working). Now as you can see - pressing Ctrl+B will set the text to bold, and pressing again will return it to normal.
That demo is working fine, but in my own project I'm working with local font-faces, i.e.:
#font-face {
font-family: BerninaSans;
src: url('theme/BerninaSans/normal/berninasans-condensedregular-webfont.eot');
src: url('theme/BerninaSans/normal/berninasans-condensedregular-webfont.eot?#iefix') format('embedded-opentype'),
url('theme/BerninaSans/normal/berninasans-condensedregular-webfont.woff') format('woff'),
url('theme/BerninaSans/normal/berninasans-condensedregular-webfont.ttf') format('truetype'),
url('theme/BerninaSans/normal/berninasans-condensedregular-webfont.svg#bernina_sanscondensed_regular') format('svg');
font-weight: normal;
font-style: normal;
}
#font-face {
font-family: BerninaSansBold;
src: url('theme/BerninaSans/bold/berninasans-condensedbold-webfont.eot');
src: url('theme/BerninaSans/bold/berninasans-condensedbold-webfont.eot?#iefix') format('embedded-opentype'),
url('theme/BerninaSans/bold/berninasans-condensedbold-webfont.woff') format('woff'),
url('theme/BerninaSans/bold/berninasans-condensedbold-webfont.ttf') format('truetype'),
url('theme/BerninaSans/bold/berninasans-condensedbold-webfont.svg#bernina_sanscondensed_bold') format('svg');
font-weight: bold;
font-style: normal;
}
And that somehow screws everything up - I can click Ctrl+B (or the button directly) to make the text bold, but clicking again doesn't return it to normal. It just stays bold. The button itself is behaving weirdly too, turns blue, but changes back to normal the second you press down any other key. I thought setting the font-weight for the second font-face to bold will sort it out because but it doesn't.
I have no idea how to set up that demo to recreate the problem (is there like a... font-face cdn or something?), hopefully someone knows the answer from similar experience or will give a helpful suggestion.
It turns out that I should give them all the same name.
According to this article, the right way to define a bold version for your font-face is to use the same font-family name, but with different attributes. That way, your browser knows that one is a bold version of the other
#font-face {
font-family: BerninaSans;
src: url('...');
font-weight: normal;
font-style: normal;
}
#font-face {
font-family: BerninaSans; // <----
src: url('...');
font-weight: bold;
font-style: normal;
}
Pretty neat.
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;
}
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;
}
I'm developing a website on my staging server in Firefox 3.6 at
http://downhamcottage.co.uk/test
I have a css file linked to the site which is
I get the lower fonts in the font stacking order eg the sans serif on initial page load and then the Museo 300 and 500 font kicks in as soon as the user clicks on to another page. It works ok in other browsers even in ie7! The #font-face style used in the stylesheet is as follows:
#font-face {
font-family: 'PermanentMarkerRegular';
src: url('../fonts/permanentmarker-webfont.eot#') format('eot'),
url('../fonts/permanentmarker-webfont.ttf') format('truetype'),
url('../fonts/permanentmarker-webfont.woff') format('woff'),
url('../fonts/permanentmarker-webfont.svg#webfontEHg8OqO7') format('svg');
font-weight: normal;
font-style: normal;
}
#font-face {
font-family: 'Museo300';
src: url('museo300-regular-webfont.eot');
src: url('../fonts/museo300-regular-webfont.eot#') format('eot'),
url('../fonts/museo300-regular-webfont.woff') format('woff'),
url('../fonts/museo300-regular-webfont.ttf') format('truetype'),
url('../fonts/museo300-regular-webfont.svg#webfontGEzJeS93') format('svg');
font-weight: normal;
font-style: normal;
}
#font-face {
font-family: 'Museo500';
src: url('museo500-regular-webfont.eot');
src: url('../fonts/museo500-regular-webfont.eot#') format('eot'),
url('../fonts/museo500-regular-webfont.woff') format('woff'),
url('../fonts/museo500-regular-webfont.ttf') format('truetype'),
url('../fonts/museo500-regular-webfont.svg#webfontZgaZZaau') format('svg');
font-weight: normal;
font-style: normal;
}
Any thoughts as to why this would happen on firefox 3.6 for the mac would be appreciated, as I say it looks great on other browsers?
From what I understand Firefox in general doesn't like css within ' it seems to need to be within "
ie:
#font-face {
font-family: "PermanentMarkerRegular";
src: url("../fonts/permanentmarker-webfont.eot") format("eot"),
url("../fonts/permanentmarker-webfont.ttf") format("truetype"),
url("../fonts/permanentmarker-webfont.woff") format("woff"),
url("../fonts/permanentmarker-webfont.svg#webfontEHg8OqO7") format("svg");
font-weight: normal;
font-style: normal;
}
Also you have a # at the end of your .eot file, I am not sure why you would need that
It might have been because it still wait for the fonts to be download. From Mozilla:
When Gecko displays a page that uses web fonts, it initially displays text using the best CSS fallback font available on the user's computer while it waits for the web font to finish downloading. As each web font finishes downloading, Gecko updates the text that uses that font. This allows the user to read the text on the page more quickly.