Trying to turn on custom font on the page through the _Layout.cshtml file.

Actually here is the code:

 <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>@ViewBag.Title - My ASP.NET Application</title> <style type="text/css"> @@font-face { font-family: "San Francisco"; font-weight: 400; src: url("https://applesocial.s3.amazonaws.com/assets/styles/fonts/sanfrancisco/sanfranciscodisplay-regular-webfont.woff"); } .Text { font-family: "San Francisco"; } </style> @Styles.Render("~/Content/css") @Scripts.Render("~/bundles/modernizr") 

But the problem is that the font was Helvetica , and remained. There are no errors in dev console

What is the error, how to connect the font?

Thanks for the help!

  • Maybe you have somewhere in "~ / Content / css" the font is set to Helvetica, which replaces yours, try to specify a custom font after loading the main styles. Here's another good answer for stackoverflow.com/questions/12812441/… fonts - Alexander Kondratenko
  • hmm maybe in bootstrap styles, okay, thanks for trying @AlexanderKondratenko - Eugene Sukhomlyn
  • Yes, that's right, thanks! @AlexanderKondratenko - Eugene Sukhomlyn

1 answer 1

You have somewhere in "~ / Content / css" the Helvetica font is set which replaces your custom one, try specifying it after loading the main styles:

 <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>@ViewBag.Title - My ASP.NET Application</title> @Styles.Render("~/Content/css") @Scripts.Render("~/bundles/modernizr") <style type="text/css"> @font-face { font-family: "San Francisco"; font-weight: 400; src: url("https://applesocial.s3.amazonaws.com/assets/styles/fonts/sanfrancisco/sanfranciscodisplay-regular-webfont.woff"); } .Text { font-family: "San Francisco"; } </style> 

Perez comment