Using importable-fonts give illegible skewed text results
paramsinghvc opened this issue · comments
Using this in my node server gives the skewed output
import standard from "figlet/importable-fonts/Standard.js";
figlet.parseFont("Standard", standard);
figlet.text(
"Anobisssss",
{
font: "Standard"
},
function(err, data) {
console.log(data);
}
);
While specifying without parseFont
works fine, figlet("Anobis", { font: "Red Phoenix" }, (...))
Thank you for reporting this, the second way you mentioned is how you're meant to use the library for Node.js apps. If your app is running in Node, you also don't need to import the fonts, see the "Basic Usage - Node.js" section of the README.md. The "importable-fonts" folder was something I created as a way for webpack-based front-end libraries to use the app (I'll be adding official documentation for it later on, but was letting it sit while I think about it).
However, I am interested in why this would be happening. What version of Node are you using and how are you running your code? I tried mocking up an example using your example code, but I can't get it to run.
It's working in my dev environment, but on the production environment I'm using Docker to build the image using multi-stage build. In the end, I'm only storing the build files in the image, discarding everything else like node_modules and stuff for small image size.
Now, since the path for the flf files is being evaluated in the runtime, it comes in the production as ../../../node_modules/figlet/fonts/xyz.flf
which resolves to nothing as throws error.
I just published a new version of the library - 1.2.4. I've updated the importable-fonts. They should now display correctly for you. The feature had been undocumented since I haven't had much time to try it out. I think I solved the issue you were seeing above as I was able to replicate it in a webpack setup. So doing it that way is probably best for your setup.
Working fine now. Thanks a lot. Btw, may I know what was the issue and how did you solve it. Because I too tried to debug it by comparing the JS file with the FLF file in diffcecker, there were exactly same. Where was the issue precisely?
The issue was the escaping of the Blackslash character for the importable-fonts. The feedback I got on the idea seem to be positive in the React thread - #32 (comment), however, I just noticed that someone in the other thread mentioned the fonts were slightly off (which was due to the Blackslash character not appearing). When I some time I'll add some tests for the importable-fonts and then add this method to the documentation.