r/webdev • u/Celrai_424 • Oct 31 '26
Question Need help with font problem
Hi i am an amateur dev.
So I want this project of mine to have a custom font; a locally imported one. I searched for sources at w3school and stackoverflow and I tried everything they said. But it doesn't seem to work. So I want to know what I'm doing wrong? I appreciate any help. Thank you in advance.
Also additional information:
The file location of my font is correct. project/project.html and project/zpix.ttf
I've checked with inspection tool, every element has the font-family: sans-serif, "Zpix"
There is also no error in the console. No error message. The font is loaded in.
I am using internal css.
Here is the code:
u/font-face {
font-family: "Zpix";
src: url("./zpix.ttf") format("truetype");
font-weight: normal;
font-style: normal;
}
* {
font-family: "Zpix", sans-serif !important;
}
4
u/norfbay Oct 31 '26
One other thing to check: the post shows
u/font-face. If that's literally in your CSS, it needs to be@font-face(Reddit may just have mangled it when you pasted).Also check the element's Rendered Fonts in DevTools, not only its computed
font-family. The computed value shows the requested font list; it doesn't prove Zpix actually drew the text. That helps distinguish a cascade/order problem from a font that loaded but isn't being used.3
u/tomhermans Oct 31 '26
Check your network tab (dev tools) if it actually loads the font file.
Next, in your comment you wrote font-family: sans-serif, "zpix"
In your code example it's the other way around. Your code example is correct, first the custom font, then the fallback.
2
u/No-Department-4561 Nov 02 '26
Convert the font to web safe format using Fontsquirrel and copy/paste the code that it gives you. That should also tell you if there’s some kind of encoding bug with the font itself.
4
u/[deleted] Nov 01 '26
[removed] — view removed comment
2
u/[deleted] Oct 31 '26
[removed] — view removed comment