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.
Related
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");
}
My website uses custom fonts. They work on all browsers, except Internet Explorer (version 11.0.9600).
The CSS code:
#font-face {
font-family: 'almoni-dl';
font-weight: 700; /*(bold)*/
font-style: normal;
src: url('https://assets.mywebsite.com/fonts/almoni-dl-aaa-700.eot?#iefix') format('embedded-opentype'),
url('https://assets.mywebsite.com/fonts/almoni-dl-aaa-700.woff') format('woff'),
url('https://assets.mywebsite.com/fonts/almoni-dl-aaa-700.ttf') format('truetype');
}
html {
font-family: 'almoni-dl','Trebuchet MS',Helvetica,sans-serif;
}
What I've tried so far:
The fonts use an absolute path to a sub-domain. The response for these fonts includes the header Access-Control-Allow-Origin:*. I also tried using a relative path, no luck.
The fonts themselves are downloaded correctly, returning code 200.
Cache was cleared several times.
The fonts' Content-Types are: woff = application/font-woff; ttf = application/octet-stream; eot = application/vnd.ms-fontobject.
Other websites (such as www.newyorker.com) display custom fonts correctly on the same browser.
I also tried the following syntax:
#font-face {
font-family: 'almoni-dl';
font-weight: 700; /*(bold)*/
font-style: normal;
src: url('https://assets.kalir.co.il/fonts/almoni-dl-aaa-700.eot');
src: url('https://assets.kalir.co.il/fonts/almoni-dl-aaa-700.eot?#iefix') format('embedded-opentype'),
url('https://assets.kalir.co.il/fonts/almoni-dl-aaa-700.woff') format('woff'),
url('https://assets.kalir.co.il/fonts/almoni-dl-aaa-700.ttf') format('truetype');
}
What else could be wrong?
In the font-family property in css, try typing the actual full name of the font, if that doesn't work, try using the full filename (minus the extension) as the font-family.
IE has known issues finding the font if the font-family name is different than what it expects!
I have a DIN Regular True Type Font which I import and declare like this:
#font-face {
font-family: 'DINRegular';
src: url('../fonts/DINBek-Regular.ttf') format('truetype'),
}
body {
font-family: 'DINRegular', Tahoma, Geneva, sans-serif;
}
However, I have an accordion in my site that always comes back Times New Roman. The Font Family in the code inspector is "DINRegular", but the rendered font on the "Computed" tab says the font is Times New Roman. Any ideas how to fix?
there is a comma after format('truetype') - deleted and add a semi colon
format('truetype');
also remove the quotes from the font family declaration in body so it's
font-family: DINRegular, Tahoma, Geneva, sans-serif;
also, if your browser doesn't support .ttf here's an example of a fuller font declaration:
#font-face {
font-family: 'myfont';
src: url('myfont.eot');
src: url('myfont.eot?#iefix') format('embedded-opentype'),
url('myfont.woff2') format('woff2'),
url('myfont.woff') format('woff'),
url('myfont.ttf') format('truetype'),
url('myfont.svg#myfont') format('svg');
}
after adding the other formats
You're only defining a .ttf font, you need to define other formats like .woff .eot and .otf. You can generate these types by using your .ttf font through through Font Squirrel Webfont generator.
One thing to make sure is that you have the proper license for the font you're trying to use online.
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
insdie my CSS files i am referencing fonts suc as :-
http://fonts.googleapis.com/css?family=Droid+Sans:regular&subset=latin
But now i need to download these CSS and add them to my host, instead of downloading them from google. but the problem i am facing is that when i try to download the related CSS files by access the above link from my IE it downlaod the following :-
#font-face {
font-family: 'Droid Sans';
font-style: normal;
font-weight: 400;
src: url(http://themes.googleusercontent.com/static/fonts/droidsans/v4/s-BiyweUPV0v-yRb-cjciFQlYEbsez9cZjKsNMjLOwM.eot);
src: local('Droid Sans'), local('DroidSans'), url(http://themes.googleusercontent.com/static/fonts/droidsans/v4/s-BiyweUPV0v-yRb-cjciFQlYEbsez9cZjKsNMjLOwM.eot) format('embedded-opentype'), url(http://themes.googleusercontent.com/static/fonts/droidsans/v4/s-BiyweUPV0v-yRb-cjciBsxEYwM7FgeyaSgU71cLG0.woff) format('woff');
}
While on firefox it shows the following :-
#font-face {
font-family: 'Droid Sans';
font-style: normal;
font-weight: 400;
src: local('Droid Sans'), local('DroidSans'), url(http://themes.googleusercontent.com/static/fonts/droidsans/v4/s-BiyweUPV0v-yRb-cjciBsxEYwM7FgeyaSgU71cLG0.woff) format('woff');
}
So i got lost on which url() i should download ? the woff or the tff ?? or both ?
EDIT
I have replaced this
#import url(https://fonts.googleapis.com/css?family=Karla|Ubuntu);
with
/*#import url(https://fonts.googleapis.com/css?family=Karla|Ubuntu);*/
#font-face {
font-family: 'Karla';
font-style: normal;
font-weight: 400;
src: url('~/Content/fonts/8gO-GQO6h3meAtqRrd890A.eot');
src: local('Karla'), local('Karla-Regular'), url('~/Content/fonts/8gO-GQO6h3meAtqRrd890A.eot') format('embedded-opentype'), url('~/Content/fonts/azR40LUJrT4HaWK28zHmVA.woff') format('woff');
}
#font-face {
font-family: 'Ubuntu';
font-style: normal;
font-weight: 400;
src: url('~/Content/fonts/_tMhxyW6i8lbI7YsUdFlGA.eot');
src: local('Ubuntu'), url('~/Content/fonts/_tMhxyW6i8lbI7YsUdFlGA.eot') format('embedded-opentype'), url('~/Content/fonts/_xyN3apAT_yRRDeqB3sPRg.woff') format('woff');
}
But the fonts effect did not work ? although when using the #import i can see the fonts effect, while when i reference them locally they stopped working.
Thanks
If you do need to use the fonts locally (rather than linking to Google's hosted versions), then they provide a download link on each font's page (in the top right)1.
The download link offers the option to 'Download the font families in your Collection as a .zip file'. If you do that, you'll get all the different versions (.ttf/.eot etc) that are needed for cross-browser #font-face support2.
You should have a good reason for doing so however: linking to the hosted version is simpler, and you'll automatically be using the latest version of each font.
Different browsers require different formats (the multiple src's in your CSS). Again though, if you're not familiar with what's required just stick with linking to Google's hosted files.