C
C#17mo 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
Tvde117mo ago
try changing
-src: url("fonts/In...
+src: url("/fonts/In...
-src: url("fonts/In...
+src: url("/fonts/In...
Uchuu
UchuuOP17mo ago
Cheers
Tvde1
Tvde117mo ago
did it work? 😁
Uchuu
UchuuOP17mo ago
Yeah, /fonts and .../fonts worked :)
Tvde1
Tvde117mo ago
ah nice. You want the css to retrieve it from yourwebsite.com/fonts/.. and not yourwebsite.com/home/abou/fonts/...
pox
pox17mo ago
Btw you can change to a wildcard pattern inside wwwroot
Accord
Accord17mo 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