Jimp: Load Custom Font Error

Created on 13 Dec 2017  路  4Comments  路  Source: oliver-moran/jimp

Hi Everyone!

When i try to load custom font (font.fnt), it gives me an error like "no such file or directory, ... font.png". Even if it is not a .png file, error says it is an .png file.

Could anyone help me to overcome this problem please?

CODE

Jimp.loadFont('font.fnt').then(function (font) {
    baseImage.print(font, 10, 10, "Hello World!");
    baseImage.write("output.png");
});

ERROR
(node:6476) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: ENOENT: no such file or directory, open 'C:UsersUSERNAMEDesktopjimp-exfont.png'
(node:6476) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Most helpful comment

Future Jimp users .
Don't use BMFont generator cuz that i converted my ttf and otf fonts with it and result was not good . Font converted but with black background frame .

陌nstead of BMFont generator use Hiero converter it is much better .

  • U can change color of font
  • U can change size of font
  • and etc. what i haven't used yet

All 4 comments

+1, I have exactly the same problem

It's coming from your .fnt generator, not the library.

Where did you generate your .fnt?
You should have received a .png with it.

If you open your .fnt file with your text editor, you'll notice there is a reference to the font.png file that contains all the glyphs.

Documenting this in the hope of helping someone in the future.

If you're using BMFont generator from angelcode, go into the 'Export options' menu via _Options_ -> _Export Options_ or by pressing T.

Then:

  • Set the font description to XML
  • Set the textures to PNG

And all should be good!

Future Jimp users .
Don't use BMFont generator cuz that i converted my ttf and otf fonts with it and result was not good . Font converted but with black background frame .

陌nstead of BMFont generator use Hiero converter it is much better .

  • U can change color of font
  • U can change size of font
  • and etc. what i haven't used yet
Was this page helpful?
0 / 5 - 0 ratings

Related issues

Favna picture Favna  路  4Comments

haydenbleasel picture haydenbleasel  路  6Comments

sesirimarco picture sesirimarco  路  3Comments

laino picture laino  路  5Comments

tutyamxx picture tutyamxx  路  4Comments