ThemeForest

Workaround for @font-face CSS validation error

47 posts
  • Has been a member for 2-3 years
  • Bought between 1 and 9 items
virgild says

@font-face is great but apparently CSS level 2.1 gives errors for both eot and ttf

Value Error : font-family Property font-family doesn't exist in CSS level 2.1 but exists in : "DroidSerif-Bold" "DroidSerif-Bold" 

Property src doesn't exist : url(fonts/DroidSerif-Bold.eot) url(fonts/DroidSerif-Bold.eot)

Value Error : font-family Property font-family doesn't exist in CSS level 2.1 but exists in : "DroidSerif-Bold" "DroidSerif-Bold" 

Property src doesn't exist : url(fonts/DroidSerif-Bold.ttf) format("truetype") url(fonts/DroidSerif-Bold.ttf) format("truetype")

This sort of sucks because you can’t put a CSS validated badge.. Can someone please share a way to fix this? if possible..

2 years ago
685 posts
  • Has been a member for 4-5 years
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Exclusive Author
  • Sold between 5 000 and 10 000 dollars
  • Bought between 10 and 49 items
  • Uruguay
  • Referred between 1 and 9 users
_rg_ says

You should also paste the css portion of that, just to see how you are using it. ;)

2 years ago
47 posts
  • Has been a member for 2-3 years
  • Bought between 1 and 9 items
virgild says

Sure! Here it is

@font-face {
    font-family: "DroidSerif-Bold";
    src: url(fonts/DroidSerif-Bold.eot);
}

@font-face {
    font-family: "DroidSerif-Bold";
    src: url(fonts/DroidSerif-Bold.ttf) format("truetype");
}

@font-face {
    font-family: "DroidSerif-Regular";
    src: url(fonts/DroidSerif-Regular.ttf) format("truetype");
}

.nav li{ font-family: "DroidSerif-Bold", serif; }

.title {font-family: "DroidSerif-Bold", serif;}

h4{ font-family: "DroidSerif-Bold", serif; }
2 years ago
33 posts
  • Has been a member for 2-3 years
  • Exclusive Author
  • Sold between 100 and 1 000 dollars
  • Bought between 1 and 9 items
CombinedPixels says

How bout a work around or some type of JavaScript hack to use @font-face with Google Chrome? :D

2 years ago
47 posts
  • Has been a member for 2-3 years
  • Bought between 1 and 9 items
virgild says

For Google Chrome convert to .woff

but @font-face seems to work on it without a walkaround

For valid CSS i guess I’ll just validate on CSS3 .

2 years ago
685 posts
  • Has been a member for 4-5 years
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Exclusive Author
  • Sold between 5 000 and 10 000 dollars
  • Bought between 10 and 49 items
  • Uruguay
  • Referred between 1 and 9 users
_rg_ says

i´m not sure, themeforest uses @font-face and validates on css2

now i see you have twice @font-face declaring same font “DroidSerif-Bold”.... also i´m not sure if that´s a good thing.

why not the same but this way:

@font-face { font-family: 'DroidSerif-Regular'; src: url('DroidSerif-Regular.eot'); src: local('DroidSerif-Regular'), url('DroidSerif-Regular.ttf') format('truetype'), }
2 years ago
404 posts
  • Has been a member for 2-3 years
  • Exclusive Author
  • Sold between 100 and 1 000 dollars
  • Bought between 10 and 49 items
  • United Kingdom
  • Referred between 1 and 9 users
JackGriffiths says

Not necessarily CSS , you could just use font replacement (Google Cufon. Cufon is an easy example to set up):

1. Download the cufon-yui.js 2. Convert your .tff font to a .js file (generator on cufon’s website) 3. Source the JS files in your section of your page 4. Add some more JS in the to replace specific CSS elements.

It’s very easy once you know how to set it up.

2 years ago
1842 posts
  • Has been a member for 3-4 years
  • Exclusive Author
  • Sold between 100 and 1 000 dollars
  • Bought between 10 and 49 items
  • Europe
  • Referred between 100 and 199 users
digitalimpact says

I’m using @font-face with a .ttf font (Rockwell) on one of my sites and works great in any browser (though I haven’t tested in Opera to be honest)

Why on earth would you want to add a “css-valid” badge? That stands for nothing really, because if you use browser-specific declarations (so only people with firefox see some cool effect), you still won’t validate and that doesn’t mean your CSS is bad.

I think these badges should go in the same drawer with table-based designs…

Just my 3.141592653589793… cents

EDIT : note that Cufon is used only for headings, and not for body text. And oh yeah, it crams your site with lots of elements (one element/word) :|

EDIT 2 : here’s my CSS code that works on IE, Firefox, Safari, Chrome and perhaps many others too

@font-face {
    font-family: Rockwell;
    src: url('fonts/Rockwell.ttf');
    }

.someclass {font-family:Rockwell, Times New Roman, Times, serif;}

I see it doesn’t validate the font-family either… not like I’d give a $h!7

2 years ago
404 posts
  • Has been a member for 2-3 years
  • Exclusive Author
  • Sold between 100 and 1 000 dollars
  • Bought between 10 and 49 items
  • United Kingdom
  • Referred between 1 and 9 users
JackGriffiths says
EDIT : note that Cufon is used only for headings, and not for body text. And oh yeah, it crams your site with lots of <canvas> elements (one element/word) :|

I believe you can define a new class/id/body element to replace by adding:

Cufon.replace ('body');

to your cufon replace JS in .

2 years ago
2524 posts
  • Has been a member for 3-4 years
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Contributed a Tutorial to a Tuts+ Site
  • Attended a Community Meetup
  • Interviewed on the Envato Notes blog
  • Envato Staff
  • Forum Moderator
  • Author had a Free File of the Month
  • Blog Editor
  • Exclusive Author
  • Sold between 10 000 and 50 000 dollars
  • Bought between 50 and 99 items
  • United States
  • Referred between 10 and 49 users
JeffreyWay says

Nobody cares about the “Valid CSS ” badge. As long as you know what why you’re doing it…don’t worry about fully passing the validation. :)

2 years ago
JeffreyWay is a moderator
by
by
by
by
by