myname
myname

Reputation: 1309

How to add custom font in asp.net mvc 5

I am working on a asp.net mvc5 project and I want to add a font to the project. I used the below code, but I don't get proper answer and I need help. Please help me.

 <style type="text/css">
    @font-face
     {
        font-family: 'Dense'; 
        src: url('Dense-Regular.ttf'); 
     }
     .classname 
     {
        font-family: 'Dense';
     }
    </style>

and I get this error

The name 'font' does not exist in the current context

Upvotes: 10

Views: 32279

Answers (2)

user11040830
user11040830

Reputation:

Download Dense-Regular.ttf file to your computer. Then add this .ttf file to your Asp.net Project's "Font" folder and restart this project. Then write font-family: 'Dense'; and it works perfectly.

Upvotes: 0

osmanraifgunes
osmanraifgunes

Reputation: 1468

 <style type="text/css">
@@font-face
 {
    font-family: 'Dense'; 
    src: url('Dense-Regular.ttf'); 
 }
 .classname 
 {
    font-family: 'Dense';
 }
</style>

Cancel @ character. It is a custom character for mvc. To use it inside css use it as @@.

Upvotes: 12

Related Questions