Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-21-2011, 04:39 PM   PM User | #1
listerdl
Regular Coder

 
Join Date: Mar 2011
Posts: 157
Thanks: 7
Thanked 0 Times in 0 Posts
listerdl is an unknown quantity at this point
Font Javascript and CSS - is this correct?

Hi - I use javascript to render font which works great.

However somtimes I notice that on some browsers it doesn't work and the end result is very ugly....this is rare but it does seem to happen.

In my CSS I have the following:

@font-face {
font-family: 'TitilliumMaps26L002';
src: local('../font/TitilliumMaps26L002-250wt') url('../font/TitilliumMaps26L002.otf') format('opentype');

Should the red font CSS code I highlighted be a direct path like the send line? The second line is direct but perhaps this is my problem that sometimes a browser just doesn't pick up the path to the correct font within the javascript?

Am I on the right track? Thanks!
listerdl is offline   Reply With Quote
Old 03-21-2011, 04:51 PM   PM User | #2
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,614
Thanks: 5
Thanked 865 Times in 842 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
No, the font-family property only contains the font name you use later in your stylesheet to display the font, and as a matter of fact you can choose whatever name you like, i. e. you could also write:
Code:
font-family: 'My super crazy CSS font';
src: local('../font/TitilliumMaps26L002-250wt') url('../font/TitilliumMaps26L002.otf') format('opentype');
As long as you use that later on, like, for example:
Code:
h1 {font: normal 18px "My super crazy CSS font", Arial, Helvetica, Sans-serif;}
However, it could be that you suffer from the local reference issue explained, among other useful things, in this article by Paul Irish.
Besides, your local reference is wrong anyway since you should not specify a path there but also reference the font name itself. This is because if other people have the font installed they don’t necessarily have the font installed where you have. The local reference is there so the font is taken from the user’s local hard drive before it’s downloaded.
__________________
Don’t click this link!

Last edited by VIPStephan; 03-21-2011 at 04:53 PM..
VIPStephan is offline   Reply With Quote
Old 03-22-2011, 11:12 AM   PM User | #3
listerdl
Regular Coder

 
Join Date: Mar 2011
Posts: 157
Thanks: 7
Thanked 0 Times in 0 Posts
listerdl is an unknown quantity at this point
thanks i really appreciate that -

Very good to know that basically my problem was that I was trying to force a path, i.e. ..../font/ which it seems was wrong and hence the issues I have been having. That is probably the answer!

Thanks again
listerdl is offline   Reply With Quote
Reply

Bookmarks

Tags
javascript and font

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:39 AM.


Advertisement
Log in to turn off these ads.