How to embed a .ttf and .eot file as one font? - html

I'm having trouble getting my font compatible on all browsers. The .ttf file works on all browsers except explorer. Here is my current code:
#font-face {
font-family: Gotham;
src: url("../Gotham-Book.eot"),
src: url("../Gotham-Book.eot#iefix") format('embedded-opentype');
src: url("../Gotham-Book.ttf") format("truetype");
}

You have too many src: declarations, thus overriding the IE hacks with a new one. Browser sees only tff in your example.
You should have only two, the first being a separate one. Notice how the middle line with fonts has a , instead of ; at the end and how there's no src: in the last oe.
#font-face {
font-family: Gotham;
src: url("../Gotham-Book.eot"),
src: url("../Gotham-Book.eot#iefix") format('embedded-opentype'),
url("../Gotham-Book.ttf") format("truetype");
}

Related

font-family crash with #font-face src

Good day,
I have a css, code is as follow:
#font-face {
font-family: 'dax-regularregular';
src: url('../fonts/daxregular-webfont.eot');
}
body {
font-family: 'dax-regularregular';
}
And, in my html code, I simply code:
<b>this is bold</b> + this is normal
And this is display correctly in chrome, but not in IE (All become normal, not bold).
If I remove the body{} in my css file, then IE will working fine.
If I remove either font-family or src inside #font-face, then IE will working fine.
I do some research on internet, found that .eot file will not support for chrome, that's why chrome wont affected and display correctly. (Not sure my understanding is correct or not)
Kindly advise. And suggest your solution if you have.
** Edit **
#font-face {
font-family: 'dax-regularregular';
src: url('../fonts/daxregular-webfont.eot');
src: url('../fonts/daxregular-webfont.eot?#iefix') format('embedded-opentype'),
url('../fonts/daxregular-webfont.woff') format('woff'),
url('../fonts/daxregular-webfont.ttf') format('truetype'),
url('../fonts/daxregular-webfont.svg#dax-regularregular') format('svg'),
url('../fonts/daxbold-webfont.eot');
font-weight: normal;
font-style: normal;
}
** Edit version 2 **
This solution can fix IE 9, IE 10, and IE 11 issue. But,
This solution introduce new issue to IE 8, which is , normal word will be bold, and the bold word will become "more bold" ( become fatter ). I saw from internet, IE 8 is not support the #font-face rule with the WOFF format (only support for EOT format). So, i take out those url except eot, but still facing the problem.
I change my css code to as follow, but still same hit issue in IE 8:
#font-face {
font-family: 'dax-regularregular';
src: url('../fonts/daxbold-webfont.eot');
src: url('../fonts/daxbold-webfont.eot?#iefix') format('embedded-opentype');
font-weight: bold;
font-style: normal;
}
As your code shows that you have included only .eot format webfont in body in css. The .eot format will work only on IE.
Now since you have added only url('../fonts/daxregular-webfont.eot') [notice 'regular'], the IE browser showing your text in regular or not-in-bold format. So if you want to display your text in-bold format on IE, you would need to add an additional url('../fonts/daxbold-webfont.eot') [notice 'bold'] definition in your css and also the relevant font in your font folder.
Now, why chrome displays it properly? I doubt if chrome would be showing your text in your desired font i.e. dax or .eot. Since you have not defined .woff font in your css (which chrome normally requires), most probably using some other font defined in some other css on your page.
To display your page consistently across all browsers using for custom font you would need to add all fonts definition in your css including adding the same in your font folder -
`#font-face {
font-family: 'dax-regularregular';
src: url('../fonts/daxregular-webfont.eot');
src: url('../fonts/daxregular-webfont.eot?#iefix') format('embedded-opentype'),
url('../fonts/daxregular-webfont.woff2') format('woff2'),
url('../fonts/daxregular-webfont.woff') format('woff'),
url('../fonts/daxregular-webfont.ttf') format('truetype'),
url('../fonts/daxregular-webfont.svg#svgFontName') format('svg');
}`
UPDATE:
First, other then font definition mentioned above you'll also have to add other font formats definitions in your css like
for bold,
#font-face {
font-family: 'dax-bold';
src: url('../fonts/daxbold-webfont.eot');
src: url('../fonts/daxbold-webfont.eot?#iefix') format('embedded-opentype'),
url('../fonts/daxbold-webfont.woff2') format('woff2'),
url('../fonts/daxbold-webfont.woff') format('woff'),
url('../fonts/daxbold-webfont.ttf') format('truetype'),
url('../fonts/daxbold-webfont.svg#svgFontName') format('svg');
}
for semibold,
#font-face {
font-family: 'dax-semibold';
src: url('../fonts/daxsemibold-webfont.eot');
src: url('../fonts/daxsemibold-webfont.eot?#iefix') format('embedded-opentype'),
url('../fonts/daxsemibold-webfont.woff2') format('woff2'),
url('../fonts/daxsemibold-webfont.woff') format('woff'),
url('../fonts/daxsemibold-webfont.ttf') format('truetype'),
url('../fonts/daxsemibold-webfont.svg#svgFontName') format('svg');
}
and so on including relevant fonts in font folder, whichever you need.
Second, for getting these fonts. Not sure but I think your dax font seems a licensed font and not the free one. If yes, then you can convert all above mentioned formats using the ttf / otf font which would have been installed in your system's 'Font' folder. To convert just copy the 'regular' or 'bold' font from that font folder on your desktop and then convert it using website like 'Font Squirrel'
UPDATE 2
The IE needs .eot version web-font only, having .woff won't affect text in any IE version. So don't fear of .woff.
You need to correct your font definition, which is still incorrect in your last post -
for regular or unbold font,
#font-face {
font-family: 'dax-regularregular';
src: url('../fonts/daxregular-webfont.eot');
src: url('../fonts/daxregular-webfont.eot?#iefix') format('embedded-opentype');
}
for bold format font,
#font-face {
font-family: 'dax-bold';
src: url('../fonts/daxbold-webfont.eot');
src: url('../fonts/daxbold-webfont.eot?#iefix') format('embedded-opentype');
}
Your html should look like this -
<p style="font-family: 'dax-regularregular';"><span style="font-family: 'dax-bold';">bold text lying here</span> unbold text lying here</p>
It should work proper across.
Note: Have shown applying font in inline tag to demonstrate html structure, please use your class for the same.
Try adding different types of fonts and specifying there type as well..
#font-face {
font-family: 'dax-regularregular';
src: url('../fonts/daxregular-webfont.eot'); /* IE9 Compat Modes */
src: url('../fonts/daxregular-webfont.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('../fonts/daxregular-webfont.woff2') format('woff2'), /* Super Modern Browsers */
url('../fonts/daxregular-webfont.woff') format('woff'), /* Pretty Modern Browsers */
url('../fonts/daxregular-webfont.ttf') format('truetype'), /* Safari, Android, iOS */
url('../fonts/daxregular-webfont.svg#svgFontName') format('svg'); /* Legacy iOS */
}
Add more font file like
font-family: 'dax-regularregular';
src: url('dax-regularregular.eot');
src: url('dax-regularregular.eot?#iefix') format('embedded-opentype'),
url('dax-regularregular.woff') format('woff'),
url('dax-regularregular.ttf') format('truetype'),
url('dax-regularregular.svg#open_sansregular') format('svg');
Generate your font blow link
http://www.fontsquirrel.com/tools/webfont-generator

#font face is not working

I am trying to add Futura web font to my webpage but when i add this to a independent css file which named fonts.css
#font-face {
font-family: futura;
src: url('/fonts/Futura LT Bold.ttf')
}
Then i added this to my main css file :
h1{
font-family: futura;
}
But the font does not change when i explore my files with web inspector(firefox) i see that the font family is sat to futura but when i check for the font i get this :
But futura is not like that (serif font) my files hierarchy is like this
Root folder
Page.htm
JS
Java.js
css
fonts.css
style.css
fonts
Futura LT Book.ttf
Futura LT Light.ttf
What might be wrong ?
Update : I use firefox
maybe your font file have a problem and it is not for web.
you can use one of the online convertor like http://www.font2web.com/ to convert the font to all font format files and use css below for your font-face implementation
#font-face {
font-family: 'Conv_FREESCPT';
src: url('fonts/FREESCPT.eot');
src: local('☺'), url('fonts/FREESCPT.woff') format('woff'), url('fonts/FREESCPT.ttf') format('truetype'), url('fonts/FREESCPT.svg') format('svg');
font-weight: normal;
font-style: normal;
}
try this
replace:
#font-face {
font-family: futura;
src: url('/fonts/Futura LT Bold.ttf')
}
with:
#font-face {
font-family: futura;
src: url("../fonts/Futura LT Bold.ttf")
}
I think you need double period (..) on your src, which means you go up one folder and then look for the folder behind the slash. For example:
src: url('../fonts/Futura LT Bold.ttf')
Another problem could be that your browser might not support . ttf font-files, you need to add .eot.

Font not rendering?

I have the following CSS (generated byn SASS):
#font-face {
font-family: "locust";
src: url(/assets/LOCUST.TTF) format("truetype");
src: url(/assets/LOCUST.svg) format("svg"); }
The path seems accessible - I'm on localhost:3000 and if I can download/see the fonts by typing localhost:3000/assets/LOCUST.TTF, for instance.
Yet Firefox don't render the font:
<h1 style="font-family: locust;">Test</h1>
I'm using Rails, but I don't think the problem is related, since the HTML and CSS generated seems correct to me, and the fonts are accessible. If I knew what I need to generate, most likely I would know how to fix.
Asset URL
Here is code we use:
#app/assets/stylesheets/fonts.css.scss
#font-face {
font-family: 'Lato';
src: asset_url('layout/fonts/lato/lato-hairline-webfont.eot');
src: asset_url('layout/fonts/lato/lato-hairline-webfont.eot?#iefix') format('embedded-opentype'),
asset_url('layout/fonts/lato/lato-hairline-webfont.woff') format('woff'),
asset_url('layout/fonts/lato/lato-hairline-webfont.ttf') format('truetype'),
asset_url('layout/fonts/lato/lato-hairline-webfont.svg#latohairline') format('svg');
font-weight: 100;
font-style: normal;
}
Notice asset_url is used -- this provides a CSS-compatible path to the url (hence why you're not able to access the path)
WebFonts
If you have full rights to use the font, you'd be better using the WebFont generator here: http://www.fontsquirrel.com/tools/webfont-generator
This creates cross-browser webfont files in .tff, .woff, .svg and .eot formats

Font Face not working in Internet Explorer?

Can anyone tell me why Internet Explorer is not picking up the Font-Face I have specified below:
http://www.droneboylaundry.com/homepage
I have checked it multiple times can't see any issues in the CSS:
#font-face {
font-family: 'BertholdAkzidenzGroteskCondensed';
src: url('http://www.droneboylaundry.com/fonts/akzidenzgroteskbe-cn.eot');
src: url('http://www.droneboylaundry.com/fonts/akzidenzgroteskbe-cn.eot') format('embedded-opentype');
src: url('http://www.droneboylaundry.com/fonts/akzidenzgroteskbe-cn.woff') format('woff');
src: url('http://www.droneboylaundry.com/fonts/akzidenzgroteskbe-cn.ttf') format('truetype');
src: url('http://www.droneboylaundry.com/fonts/akzidenzgroteskbe-cn.svg#BertholdAkzidenzGroteskCondensed') format('svg');
}
IE8 has bugs loading the eot files.
If you add a question mark to the end of the url for all the eot includes, it should work:
src: url('http://www.droneboylaundry.com/fonts/akzidenzgroteskbe-cn.eot?');
EDIT: From Paul Irish's Bulletproof #font-face Syntax:
#font-face {
font-family: 'BertholdAkzidenzGroteskCond';
src: url('http://www.droneboylaundry.com/fonts/akzidenzgroteskbe-cn.eot?') format('eot'),
url('http://www.droneboylaundry.com/fonts/akzidenzgroteskbe-cn.woff') format('woff'), url('http://www.droneboylaundry.com/fonts/akzidenzgroteskbe-cn.ttf') format('truetype');
}
EDIT 2: IE has another bug where the font-family name can't be longer than 31 characters. I updated the code above to reflect this change.

#font-face rendering on webkit browsers [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
#font-face anti-aliasing on windows and mac
This is my css:
#font-face {
font-family: 'Museo500Regular';
src: url('../fonts/Museo500/MuseoSans_500.eot');
src: local('?'),
url('../fonts/Museo500/MuseoSans_500.woff') format('woff'),
url('../fonts/Museo500/MuseoSans_500.ttf') format('truetype'),
url('../fonts/Museo500/MuseoSans_500.svg#webfontr3rD8cn7') format('svg');
font-weight: normal;
font-style: normal;
}
.loginUser form h2{
font-family: Museo500Regular,sans-serif;
font-size: 17px;
font-weight: bold;
}
On IE,Firefox,Opera render well only on webkit browser is not rendering well, can anyone tell me why ? :|
To get proper bold text, you need to use a bold (700) version of the font. If you use another weight and just ask browsers to bold it, they may algorithmically thicken the strokes, and this results in poor or awful rendering, depending on browser.
Rohit: I am sure that was just a typo, as it would break in all browsers
Have you tried the following method:
#font-face {
font-family: 'Museo500Regular';
src: url('../fonts/Museo500/MuseoSans_500.eot?#iefix') format('embedded-opentype'),
url('../fonts/Museo500/MuseoSans_500.woff') format('woff'),
url('../fonts/Museo500/MuseoSans_500.ttf') format('truetype'),
url('../fonts/Museo500/MuseoSans_500.svg#webfontr3rD8cn7') format('svg');
}
It has always worked for me..
Otherwise it might be an error in your Woff file, since that is the one webkit uses
Try this:
font-family: 'Museo500Regular';
src: url('../fonts/Museo500/MuseoSans_500.eot');
src: url('../fonts/ubuntu-r-webfont.eot?#iefix') format('embedded-opentype'),
url('../fonts/Museo500/MuseoSans_500.woff') format('woff'),
url('../fonts/Museo500/MuseoSans_500.ttf') format('truetype'),
url('../fonts/Museo500/MuseoSans_500.svg#webfontr3rD8cn7') format('svg');
Also try adding the following to the .htaccess
AddType application/vnd.ms-fontobject .eot
AddType font/ttf .ttf
AddType font/otf .otf