I have a simple node server and I have a CSS file that requests a font from my server:
@font-face{
font-family: 'NiagaraSolid-Reg';
src: url('http://localhost:1111/NIAGSOL.TTF');
}
This is what I attempted to do. It normally works with .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
})
But when I do this, in Chrome I get the error message: Failed to decode downloaded font: http://localhost:1111/NIAGSOL.TTF
In searching for an answer, everything I came across was too complicated for me to understand becuase it required prerequisite knowledge of a lot of things. I'm completely illiterate when it comes to buffers and streams and binaries and encodings etc. I need a simple "explain-like-I'm-five" answer for how to serve a .tff
file.
Thanks!