Jimp: Cannot load custom font into Jimp

Created on 28 Nov 2016  路  9Comments  路  Source: oliver-moran/jimp

Heyo,

I've been attempting to load a custom font into Jimp and get this error. The TrueType font is attached with the issue along with the BMfont conversion done using Littera.

Font Files

Anyone have any suggestions as to next steps? I'm not sure how to find the exact cause

Cheers,
Nelly

Most helpful comment

In fact, Bitmap fonts xml have a kernings xml tag that seems to be required by Jimp.

I've solved the problem supra adding the following code to the end of your font file:

<kernings count="0">
</kernings>

All 9 comments

I'm getting this error as well

(node:74513) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: cannot parse font file Cannot read property '0' of undefined

After some more testing, I think it just depends on the font. Maybe if the font is missing certain characters?

This is still happening.

font.zip
font2.zip
font3.zip

I tried these three formats with varying success. One of them gave me the error described in the issue and the other two ended up not writing anything to the file.

In fact, Bitmap fonts xml have a kernings xml tag that seems to be required by Jimp.

I've solved the problem supra adding the following code to the end of your font file:

<kernings count="0">
</kernings>

I merged in those two PRs for the bmfont modules. Let me know if there's anything else!

@mattdesl I just tested it and it works! Thanks for the quick response.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Allaphy picture Allaphy  路  42Comments

oliver-moran picture oliver-moran  路  16Comments

mkondel picture mkondel  路  14Comments

AtaS picture AtaS  路  22Comments

cancerberoSgx picture cancerberoSgx  路  64Comments