Reputation: 8312
I dont understand whats going on here because when I had this code on its own it was working (in FireFox):
@font-face {
font-family: 'mmfont';
src: url('/scripts/mmfont.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}
Then I added a second font in exactly the same manner, but only the first one was working:
@font-face {
font-family: 'mmfont2';
src: url('/scripts/mmfont2.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}
Then I used a font-generator to get an EOT file for IE9 and generate the @font-face code for me, but now neither font is working in any browser (I tried IE9, FF12, Chrome & Safari5).
I then put the @font-face CSS in its own '/scripts/fonts.css' file so that the fonts and CSS were in the same folder, and I tried to use the URLs both directly ('mmfont.ttf') and by the webroot folder ('/scripts/mmfont.ttf') but still neither way is working at all.
What am I doing wrong?
I had a typo when calling the first font 'mmfont' I did this: font-family: mm_font
but now that I fixed the typo, once again only the 1st font is working with the code below, and the second font mmfont2
is not working. I tried to re-arrange the order (define the 2nd font first) but it still wont work. So now I believe there is a problem with my font file, so I will try to get another copy and see how that goes.
There seems to be nothing wrong with the code. I used FireBug to do a Source Edit of the fonts.css file, and when I renamed the url for 'mmfont2' to 'mmfont.ttf' (the URL for the 1st font) it updated the page and the font loaded, however when I renamed it back to 'mmfont2.ttf' it went back to the default font of the browser. So I am now sure it is a problem with the font file rather than the code.
It looks like this 2nd font I'm using isn't a web-compatible font. Funnily, it turns out that all along the same font has another alias "Century Gothic" which is a web-safe font and works in all the browsers without even having to link any files!!
(I don't know if I should have this question closed or deleted)
@CHARSET "ISO-8859-1";
@font-face {
font-family: 'mmfont';
src: url('/scripts/mmfont.eot');
src: url('/scripts/mmfont.eot?#iefix') format('embedded-opentype'),
url('/scripts/mmfont.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'mmfont2';
src: url('/scripts/mmfont2.eot');
src: url('/scripts/mmfont2.eot?#iefix') format('embedded-opentype'),
url('/scripts/mmfont2.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}
<link rel="StyleSheet" href="/scripts/fonts.css" type="text/css">
/
/index.html
/scripts/
/scripts/mmfont.ttf
/scripts/mmfont.eot
/scripts/mmfont2.ttf
/scripts/mmfont2.eot
/scripts/fonts.css
Upvotes: 3
Views: 3245
Reputation: 11
Know it's over a year later but just incase anyone comes looking, I'm betting the questioner was hosting their website on AWS -- you have to create a CORS rule to get AWS to read @font-face kit. Try this fix as described here: http://blog.blenderbox.com/2012/10/12/serving-font-face-fonts-to-firefox-from-an-s3-bucket/
Upvotes: 1
Reputation: 4855
We couldn't figure out another way around, as it appeared all of our settings on Amazon were fine. Instead, we just embedded the font definition itself into a data-uri call, as seen below. Much of the font definition has been omitted to size constraints of answers in StackOverflow, but this should give you a good idea of our approach.
@font-face {
font-family: "PFDinTextPro-Light";
src: url("233cd7_2_0-webfont.eot");
}
@font-face {
font-family: "PFDinTextPro-Light";
font-style: normal;
font-weight: normal;
src: url("233cd7_2_0-webfont.eot?#iefix") format("embedded-opentype"), url("data:application/x-font-woff;charset=utf-8;base64,d09GRgABAAAAAFq4ABEAAAAAmrQAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABGRlRNAAABgAAAABwAAAAcYqvy...dRcDMyMXA5M2mM+m4LqJvRPKYQVy2CKhHBYgh9USyuGAaJOCaeMESnLMgHAYN3BBDecFinIdZ9LeyOxWBuTyALm8+XAuN5DLEwjn8oGM5Kr/zwAX4Qcq4HsC5woAufy1MG7kBhFtANGLRQMAAVB7j+oAAA==") format("woff"), url("233cd7_2_0-webfont.ttf") format("truetype");
}
Upvotes: 1
Reputation: 32152
Hey now correct to your font url in css as like this
url('mmfont.eot');
i think your font and css file in one folder of scripts
Upvotes: 1