❔ ASP.NET Core Custom Font Not Applied

site.css
body {
margin-bottom: 60px;
font-family: Intro, sans-serif;
}

@font-face {
font-family: Intro;
src: url("fonts/Intro-Trial-Rg.otf");
}

@font-face {
font-family: Intro;
font-weight: bold;
src: url("fonts/Intro-Trial-Bd.otf");
}
body {
margin-bottom: 60px;
font-family: Intro, sans-serif;
}

@font-face {
font-family: Intro;
src: url("fonts/Intro-Trial-Rg.otf");
}

@font-face {
font-family: Intro;
font-weight: bold;
src: url("fonts/Intro-Trial-Bd.otf");
}
The fonts are copied to the output directory
<ItemGroup>
<Content Include="..\.dockerignore">
<Link>.dockerignore</Link>
</Content>
<Content Update="wwwroot\fonts\Intro-Trial-Bd.otf">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Update="wwwroot\fonts\Intro-Trial-Rg.otf">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<Content Include="..\.dockerignore">
<Link>.dockerignore</Link>
</Content>
<Content Update="wwwroot\fonts\Intro-Trial-Bd.otf">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Update="wwwroot\fonts\Intro-Trial-Rg.otf">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
However, the font is not applied to my body. It just falls back to the default. What's wrong? Folder Structure:
7 Replies
Tvde1
Tvde12y ago
try changing
-src: url("fonts/In...
+src: url("/fonts/In...
-src: url("fonts/In...
+src: url("/fonts/In...
Patrick Square
Patrick SquareOP2y ago
Cheers
Tvde1
Tvde12y ago
did it work? 😁
Patrick Square
Patrick SquareOP2y ago
Yeah, /fonts and .../fonts worked :)
Tvde1
Tvde12y ago
ah nice. You want the css to retrieve it from yourwebsite.com/fonts/.. and not yourwebsite.com/home/abou/fonts/...
pox
pox2y ago
Btw you can change to a wildcard pattern inside wwwroot
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server