views:

79

answers:

2

Hi guys I have this code in my css file from the @fontsquirrel generator

/// changed the code to how it is now ///

@font-face {
font-family: 'AdLibRegular';
src:    url('../fonts/adlib-webfont.eot');
src:    local('☺'), url('../fonts/adlib-webfont.woff') format('woff'), 
        url('../fonts/adlib-webfont.ttf') format('truetype'), 
        url('../fonts/adlib-webfont.svg#webfontmAc00Ivp') format('svg');
font-weight: normal;
font-style: normal;
}

.AdLib {
        font-weight: normal;
        font-style: normal;
        line-height:normal;
        font-family: 'AdLibRegular', sans-serif;
}

this is stored in a folder called css and the fonts are stored in a folder called fonts.

I can't get this to work when in the html page I'm calling it for example

<h1 class="AdLib">Testing Testing 1 2 3</h1>

I can't work out what I'm doing wrong at all.

Any ideas?

thanks in advance stu

//// I have now changed them all to url ('../fonts/adlib etc and it still doesn't work. I'm previewing locally - is this it?

A: 

I've run into problems with font-face where the URL starts with a '/' - try editing the src URL to be a relative URL:

eg

@font-face {
font-family: 'AdLibRegular';
src:    url('../fonts/adlib-webfont.eot');
}

(obviously point to the correct folder location)

What
@What when the *relative* URL starts with `/` it's called an **absolute** URL and points to the root of your site.
Frankie
Oops, of course it is - edited. I'm still sure that I've had problems with font-face and absolute URLs in the past though.
What
(`/foo` is still a relative URL—a rooted relative URL. An *absolute* URL includes the whole URL from the scheme at the beginning, `http://...`)
bobince
@bobince, I let my language take the best out of my. You syntax is correct. `/foo` is a relative URL. Taken from W3: *A URL is an absolute URL if resolving it results in the same output regardless of what it is resolved relative to, and that output is not a failure.*
Frankie
A: 

could be a problem with the path, where is the font folder located according to the css file?

if the font folder is in the css folder you should use the following path:

src:    url('fonts/adlib-webfont.eot');

if it's next to the css map you need to use the following path:

src:    url('../fonts/adlib-webfont.eot');

../ is used to go back a folder

krike
I have done this but it still doesn't work. The @font-face is in the css file at the top and the .AdLib class is in the same css file at the bottom :) very puzzling.
stuart robson
sure the folder is named fonts and not just font? typo I used to make :), what are you using btw as local server? wamp or xamp?
krike