C
C#13mo ago
Uchuu

❔ 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
Tvde113mo ago
try changing
-src: url("fonts/In...
+src: url("/fonts/In...
-src: url("fonts/In...
+src: url("/fonts/In...
Uchuu
Uchuu13mo ago
Cheers
Tvde1
Tvde113mo ago
did it work? 😁
Uchuu
Uchuu13mo ago
Yeah, /fonts and .../fonts worked :)
Tvde1
Tvde113mo ago
ah nice. You want the css to retrieve it from yourwebsite.com/fonts/.. and not yourwebsite.com/home/abou/fonts/...
pox
pox13mo ago
Btw you can change to a wildcard pattern inside wwwroot
Accord
Accord13mo 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
More Posts