Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

@font-face src: local - How to use the local font if the user already has it?

Tags:

css

font-face

What is the right way to use @font-face so that the browser will not download the font if the user already have it?

I am using @font-face to define DejaVu, which is already installed on my system (linux). Firefox is not downloading the font, but Chromium is downloading it every time!

My CSS code, based on font squirrel and that question look like this:

@font-face {     font-family: 'DejaVu Serif';     src: url('DejaVuSerif-webfont.eot');     src: local('DejaVu Serif'), url('DejaVuSerif-webfont.woff') format('woff'), url('DejaVuSerif-webfont.ttf') format('truetype'), url('DejaVuSerif-webfont.svg#webfontCFu7RF0I') format('svg');     font-weight: normal;     font-style: normal; }  /* ... @font-face definitions for italic and bold omitted ... */  @font-face {     font-family: 'DejaVu Serif';     src: url('DejaVuSerif-BoldItalic-webfont.eot');     src: local('DejaVu Serif Bold Italic'), url('DejaVuSerif-BoldItalic-webfont.woff') format('woff'), url('DejaVuSerif-BoldItalic-webfont.ttf') format('truetype'), url('DejaVuSerif-BoldItalic-webfont.svg#webfontQAewh7pf') format('svg');     font-weight: bold;     font-style: italic; } 
like image 609
dbarbosa Avatar asked Oct 01 '10 07:10

dbarbosa


People also ask

How do I use fonts locally?

You should change src:url("C:/path/to/ttf"); to src:url("file:///path/to/file") . Show activity on this post. Show activity on this post. Just add bellow code before all the styling of your css file and then you can use this font family for any selector inside within your css file.

How do I use face fonts in HTML?

You can use a <basefont> tag to set all of your text to the same size, face, and color. The font tag is having three attributes called size, color, and face to customize your fonts. To change any of the font attributes at any time within your webpage, simply use the <font> tag.


1 Answers

If you want to check for local files first do:

@font-face { font-family: 'Green Sans Web'; src:     local('Green Web'),     local('GreenWeb-Regular'),     url('GreenWeb.ttf'); } 

There is a more elaborate description of what to do here.

like image 192
Thariama Avatar answered Sep 22 '22 17:09

Thariama