Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to import fonts in CSS?

Tags:

css

fonts

I want to use some fonts and I want it to work without having this font on the client computer. I have done this but it doesn't work:

@font-face {     font-family: EntezareZohoor2;     src: url(Entezar2.ttf) format("truetype"); }  .EntezarFont {     font-family: EntezareZohoor2, B Nazanin, Tahoma !important; } 
like image 539
Mohammad Avatar asked Jul 31 '12 09:07

Mohammad


People also ask

Can you use custom fonts in CSS?

Nope, it isn't possible to style your text with a custom font embedded via CSS, while preventing people from downloading it. You need to use images, Flash, or the HTML5 Canvas, all of which aren't very practical.

How do I use local fonts in CSS?

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.


1 Answers

Following lines are used to define a font in css

@font-face {     font-family: 'EntezareZohoor2';     src: url('fonts/EntezareZohoor2.eot'), url('fonts/EntezareZohoor2.ttf') format('truetype'), url('fonts/EntezareZohoor2.svg') format('svg');     font-weight: normal;     font-style: normal; } 

Following lines to define/use the font in css

#newfont{     font-family:'EntezareZohoor2'; } 
like image 153
Suresh kumar Avatar answered Sep 19 '22 15:09

Suresh kumar