I am running a basic node server and I have a CSS file that is trying to load a font from the server:
@font-face{
font-family: 'NiagaraSolid-Reg';
src: url('http://localhost:1111/NIAGSOL.TTF');
}
This is my attempt at serving the font file. Usually, this setup works for .html, .css, and .js files:
http.createServer(function(request,response){
var arguments=request.url.slice(1).split("/");
switch(arguments[0]){
case "NIAGSOL.TTF":
response.end(fs.readFileSync("website/NIAGSOL.TTF").toString());
break;
//etc
})
However, when I try this method, Chrome shows an error message:
Failed to decode downloaded font: http://localhost:1111/NIAGSOL.TTF
I have tried looking for solutions online, but everything I found was too complex for me to understand without prior knowledge of buffers, streams, binaries, encodings, etc. I need a simple explanation on how to serve a .tff
file as if you were explaining it to a five-year-old.
Thank you!