#font-face doesn't work - css

I downloaded a font inlove-light-wf.ttf, in order to use the rule #font-face.
I have in my folder: home.html and inlove-light-wf.ttf.
In my CSS I have :
#font-face {
font-family: 'Inlove';
src: url('inlove-light-wf.ttf');
font-weight: normal;
font-style: normal;
}
#definicao{
text-align:center;
color:#0080C0;
font-family:'Inlove';
font-size:24px;
margin-top:20px;
border-top:solid #999 thin;
padding: 20px 40px 3px 40px;
height:290px;
background-color:#EFEFEF;
}
#definicao{
text-align:center;
color:#0080C0;
font-family:'Inlove';
font-size:24px;
margin-top:20px;
border-top:solid #999 thin;
padding: 20px 40px 3px 40px;
height:290px;
background-color:#EFEFEF;
}
But it doesn't work.

One source of the problem could be if your css is in a separate file that isn't in the root folder. For example, if you keep all of your css files in a 'css' folder, you'll need to modify the font url to be relative to that file, not to the root folder. In this example it would be src: url('../inlove-light-wf.ttf');
Furthermore, not all browsers can use .ttf font files. You have to declare alternative font formats in the #font-face css.
Here's a modified #font-face declaration to get you started. I would also recommend reading more here and here.
#font-face {
font-family: 'Inlove';
src: url('inlove-light-wf.eot'); /* IE9 Compat Modes */
src: url('inlove-light-wf.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('inlove-light-wf.woff') format('woff'), /* Modern Browsers */
url('inlove-light-wf.ttf') format('truetype'), /* Safari, Android, iOS */
url('inlove-light-wf.svg#svgFontName') format('svg'); /* Legacy iOS */
}

The #font-face rule usually doesn't support some old browsers. I usually use font-face generator which will generate css file from your font that you need to include, and all browsers will show it correctly.

I had problems with font too. When font was working in IE wasn't on iPhone and when was working on iPhone wasn't in IE. Here is my code (i don't know why it works this way, but it does for me):
#font-face{
font-family:"Royal Chicken";
src: url(../gradivo/font/RoyaChicken.eot);
src: url(../gradivo/font/RoyalChicken.ttf) format("truetype"), /* Safari, Android, iOS */
url(../gradivo/font/RoyalChicken.eot?#iefix) format("embedded-opentype"), /* IE6-IE8 */
url(../gradivo/font/RoyalChicken.woff) format("woff"), /* Pretty Modern Browsers */
url(../gradivo/font/RoyalChicken.svg#RoyalChicken) format("svg");
}
#font-face{
font-family:"Royal Chicken";
src: url(../gradivo/font/RoyaChicken.eot);
}
#font-face{
font-family:"Royal Chicken";
src: url(../gradivo/font/RoyalChicken.ttf) format("truetype");
}
It may help you. :)

Related

rails and bootstrap with custom fonts?

I am trying to learn how to use custom fonts however I keep getting a jquery error I think it is? while trying to load the fonts.
It's this error here:
jquery.self-c64a74367bda6ef8b860f19e74df08927ca99d2be2ac934e9e92d5fd361e0da4.js?body=1:3735 GET http://localhost:3000/assets/fonts/dayslater/dayslater.ttf
I have added this line inside application.rb:
config.assets.paths << Rails.root.join("app", "assets", "fonts")
my css:
#font-face {
font-family: 'dayslater';
src: url('fonts/dayslater/dayslater.ttf') format('truetype');
}
please note that these bits of CSS are in different files but even in the same file they do not work.
#dayslat {
font: 3em 'dayslater';
font-weight: bold;
color: white;
text-align:center;
}
I was just wondering why it will not work thank you
I managed to get this working, thanks to Igor.
He pointed out that instead of having
font: 3em 'dayslater';
It should instead be:
font-family: 'dayslater';
font-size: 3em;
and also adding this line in application.rb:
config.assets.precompile << /\.(?:svg|eot|woff|ttf)\z/
however what the problem was, rails now automatically detects font files,
so when I had
fonts/--font folder--/font.ttf
It should have been:
--font folder--/font.ttf
Try this:
#dayslat {
font-family: 'dayslater';
font-size: 3em;
font-weight: bold;
color: white;
text-align:center;
}
add in application.rb below string:
config.assets.precompile << /\.(?:svg|eot|woff|ttf)\z/
in your css use:
#font-face {
font-family: 'MyWebFont';
src: url('webfont.eot'); /* IE9 Compat Modes */
src: url('webfont.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('webfont.woff2') format('woff2'), /* Super Modern Browsers */
url('webfont.woff') format('woff'), /* Pretty Modern Browsers */
url('webfont.ttf') format('truetype'), /* Safari, Android, iOS */
url('webfont.svg#svgFontName') format('svg'); /* Legacy iOS */
font-style: normal;
font-weight: normal;
}
with your own font-name

How to use custom fonts in CakePHP?

I am trying to use a custom font in CakePHP but it doesn't seem to be working.
I am getting the font from http://www.dafont.com/ssf4-abuket.font (A Street Fighter font!!). And I store the ttf font file to webroot/css.
This is my CSS:
#font-face {
font-family: 'SF';
src: url('StreetFighter.ttf') format('truetype');
}
p {
height: 50%;
margin: 30px 0;
text-align: center;
font-size: 2.2rem;
font-family: 'SF';
color: #000;
}
However, when I use a different font such as the Arkitech from http://www.1001freefonts.com/ with the same code but different filename it works.
As you are only having a .ttf file for your font-face, not all browsers can use .ttf font files. You have to declare alternative font formats in the #font-face css.
You can generate these other font formats with an online converter. (for example: http://freedockstar.com/fontface/).
Then you need to have the following font-face declaration:
#font-face {
font-family: 'SF';
src: url('StreetFighter.eot'); /* IE9 Compat Modes */
src: url('StreetFighter.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('StreetFighter.woff') format('woff'), /* Modern Browsers */
url('StreetFighter.ttf') format('truetype'), /* Safari, Android, iOS */
url('StreetFighter.svg') format('svg'); /* Legacy iOS */
}
I've tried your font with this tool and it generates a working preview of your webfont.

#font-face fonts within bootstrap css not displaying in firefox

I am able to display fonts in chrome, but not in firefox. I'm wondering if this is an issue because I'm using the bootstrap framework. Here's my code:
#font-face
{
font-family:"bodyFont";
src: url("http://caseymmiller.com/galapagos/fonts/museosans_300.otf");
}
body
{
margin: 0;
font-family: "bodyFont";
font-size: 15px;
line-height: 20px;
color: #333333;
background-color: #ffffff;
}
Also, upon uploading it to my server, only one font is now appearing in chrome... and local sourcing wasn't working so I removed it. I am quite confused. http://caseymmiller.com/galapagos/bootstrapInvasive/Invasive.html
This is what I have in the css now. I tried what you listed before, but when sourcing both urls for each font, none of them would appear. That's why some are commented out right now. These are the sources that I want to use from now on.
#font-face
{
font-family:"headerFont";
src: url("http://livinggalapagos.org/static/Fonts/qhyts__.ttf");
/*src: url("http://livinggalapagos.org/static/Fonts/qhyts__.woff");*/
}
#font-face{
font-family:"subHeadFont";
src: url("http://livinggalapagos.org/static/Fonts/museosans_500.ttf");
src: url("http://livinggalapagos.org/static/Fonts/museosans_500.woff");
}
#font-face{
font-family:"bodyFont";
src: url("http://livinggalapagos.org/static/Fonts/museosans_300.ttf");
/*src: url("http://livinggalapagos.org/static/Fonts/museosans_300.woff");*/
}
#font-face is a complicated property. Here are some resources that might help you to code a "cross-browser" #font-face.
https://developer.mozilla.org/pt-BR/docs/CSS/#font-face
http://www.fontsquirrel.com/tools/webfont-generator
I'm wondering if you don't have a typo in 2 of your properties?
src: url('fonts/museosans_300-.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('fonts/museosans_300-.ttf') format('truetype'), /* Safari, Android, iOS */
Shouldn't these two be
src: url('fonts/museosans_300-webfont.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('fonts/museosans_300-webfont.ttf') format('truetype'), /* Safari, Android, iOS */
Note the added webfont at the end of the file paths.
Be sure to clear your browser cache after making these changes as well.
Good luck!

Font-family not working properly on live server

I am using font-family "angelina". Its working properly on local server. But its not working on live server. It also working on live server just only on my computer. But its not working on any other computers.
I check it in all browsers on other computers but its not working.
I am using CSS code like this
#font-face {
font-family: MyCustomFont;
src: url("ANGELINA.eot") /* EOT file for IE */
}
#font-face {
font-family: MyCustomFont;
src: url("ANGELINA.TTF") /* TTF file for CSS3 browsers */
}
.test_font{
font-family: angelina;
font-size: 36px;
font-weight: bold;
}
You need to have all kinds of font extensions on server to support all browsers.
#font-face {
font-family: MyCustomFont;
src: url('ANGELINA.eot');
src: url('ANGELINA.eot?') format('☺'),
url('ANGELINA.woff') format('woff'),
url('ANGELINA.ttf') format('truetype'),
url('ANGELINA.svg#webfontssbCkuz5') format('svg');
}
You can find all font extensions on this site http://www.google.com/webfonts
It supposed to be:
#font-face {
font-family: angelina;
src: url("ANGELINA.eot") /* EOT file for IE */
}
#font-face {
font-family: angelina;
src: url("ANGELINA.TTF") /* TTF file for CSS3 browsers */
}
if you want to call font-family: angelina;

Css3 #fontface is not working with Chrome 17 and Firefox 10

I'm trying this code For the #fontface for an arabic font :
#font-face {
font-family: 'MothnnaFont';
src: url('fonts/mothnna.eot'); /* IE9 Compat Modes */
src: url('fonts/mothnna.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('fonts/mothnna.woff') format('woff'), /* Modern Browsers */
url('fonts/mothnna.ttf') format('truetype'), /* Safari, Android, iOS */
url('fonts/mothnna.svg#svgMothnnaFont') format('svg'); /* Legacy iOS */
}
I'm using the font in a class named demo :
.demo
{
font-family:'MothnnaFont',Sans-Serif;
width:800px;
margin:10px auto;
text-align:center;
border:1px solid #666;
padding:10px;
direction: rtl;
}
This code is working on ie but it's not working on firefox 10 or chrome 17
Here is a demo http://tmr.hyperphp.com/font/demo.html
Here is how the font should look like
So anybody can help me to make this font appear a cross all browsers ?
Solved: just downloaded the font and converted it again and it's all working now
thank you all for helping
This syntax of embedding web-fonts is not bulletproof anymore.
Try using the Fontspring syntax instead:
#font-face {
font-family: 'MothnnaFont';
src: url('fonts/mothnna.eot?#iefix') format('embedded-opentype'),
url('fonts/mothnna.woff') format('woff'),
url('fonts/mothnna.ttf') format('truetype'),
url('fonts/mothnna.svg#svgMothnnaFont') format('svg');
}
It's just the first double appearance of the "src"-attribute you have to fix.
This will solve your problem.
For more information about the syntax, take a look at this source. And by the way, fontsquirrel is also using this syntax as its default.

Resources