Reputation: 2139
I am working on Asp.net 4.0 with VS2010. I am trying to use a custom font.
I have a 'Fonts' folder which has font file.
The css is (css file in css folder)
@font-face {
font-family: "Trade Gothic20";
src: url('../Fonts/TradeGothicLTStd-BdCn20.otf');
The font works locally but when I move it to the server it doesn't work.
I have set Build Action Property to content.
What could be the reason?
I saw one question (below)
Do i need to write in config files? I have 'otf' extension file.
Please guide me.
Thanks.
Upvotes: 3
Views: 7048
Reputation: 24
I faced the same problem, what worked for me.
The path to the font file itself is the problem. For example paths like (../font.ttf) or (/font.ttf) or (font.ttf) did not work.
It worked when I provide absolute links https://www.mydomen.com/font.ttf
I've also tried to cover a wide range of support for different browsers
@font-face {
font-family: 'GreenWorld';
src:
url('https://www.zeleni-svet.com/Allison.ttf') format('truetype'),
url('https://www.zeleni-svet.com/Allison-Regular.eot'),
url('https://www.zeleni-svet.com/Allison-Regular.woff')
format('woff'),
url('https://www.zeleni-svet.com/Allison-Regular.woff2')
format('woff2'),
url('https://fonts.googleapis.com/css2?family=Allison&display=swap');
font-weight: normal;
font-style: normal;
}
Upvotes: 0
Reputation: 52474
Try entering full URL, without .. (instead of a reference):
Example:
src: url('http://devserver/MyPortal/Content/MvcGrid/Fonts/GridGlyphs.woff') format('woff');
or without the server name:
src: url('MyPortal/Content/MvcGrid/Fonts/GridGlyphs.woff') format('woff');
Upvotes: 0
Reputation: 140
Please also try to use different fonts format as some browsers only can view specific font formats
Like this @font-face { font-family: 'Trade Gothic20';
src: url('http://www.URL/fontname.eot');
src: url('http://www.URL/fontname.ttf') format('truetype'), url('http://www.URL/fontname.woff') format('woff'), url('http://www.URL/fontname.svg') format('svg');
font-weight: normal;
font-style: normal;
}
Upvotes: 1
Reputation: 54
Try this:
Hope this helps
Upvotes: 1