question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Jimp.loadFont(Jimp.FONT_SANS_8_BLACK) not working

See original GitHub issue

Expected Behavior

Load up a font

Current Behavior

Not loading up a font

Failure Information (for bugs)

browser.js:71 Uncaught (in promise) Error: error parsing font malformed file – no < pages > element at Object.callback (browser.js:71) at cbOnce (index.js:64) at XMLHttpRequest.loadFunc (index.js:131)

Steps to Reproduce

The following is react code

`const [imageData, setImageData] = useState(“”);

const handleSelectImage = (evt) => { console.log(“Handling Image Select”); const file = evt.target.files[0];

const reader = new FileReader();

if (file) {
  reader.readAsDataURL(file);
}

reader.addEventListener(
  "load",
  async () => {
    setImgSrcOld(reader.result);
    setImgSrcNew(reader.result);
    setImageData(reader.result);
  },
  false
);

};

const handleChange = async (evt) => { setSwitches({ …switches, [evt.target.name]: evt.target.checked }); let imageRes = await Jimp.read(imageData);

Jimp.read(imageRes).then((image) =>
  Jimp.loadFont(Jimp.FONT_SANS_8_BLACK).then((font) => {
    image.print(font, 10, 10, "Hello world!");
    setImgSrcNew(image);
  })
);

};`

Screenshots

Simply want to upload an image and write the example text to it

  • Jimp Version: 0.10.3
  • Operating System: Windows 10
  • Node version: 10.16.2

browser.js:71 Uncaught (in promise) Error: error parsing font malformed file – no < pages > element at Object.callback (browser.js:71) at cbOnce (index.js:64) at XMLHttpRequest.loadFunc (index.js:131)

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:7
  • Comments:8

github_iconTop GitHub Comments

3reactions
BernhardSmutscommented, Jan 20, 2021

Hi.

Unfortunately not. I was never able to implement it into my project and abandoned that feature in the project.

On Tue, 19 Jan 2021, 00:55 Vlad Vasilenko, notifications@github.com wrote:

@BernhardSmuts https://github.com/BernhardSmuts Hi! Did you fix it? If yes how did you do this?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/oliver-moran/jimp/issues/885#issuecomment-762504045, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFLKBMGVC2SKDWPRHHASZKTS2S37XANCNFSM4M55FM7A .

1reaction
Wyatth7commented, Oct 11, 2020

I’m getting this error too. I’ve done some digging around on Jimp’s docs, and I think I’ve figured out how their system works.

So, when using the print method (print(Jimp.[Your_Font])), Jimp finds the Your_Font.fnt file, and I believe it’s within this file where we are getting this error.

Product of print(Jimp.[Your_Font])

<info face="open-sans-16-white" size="16" bold="0" italic="0" charset="" unicode="" stretchH="100" smooth="1" aa="1" padding="2,2,2,2" spacing="0,0" outline="0"/>
  <common lineHeight="18" base="15" scaleW="1836" scaleH="20" pages="1" packed="0"/>
// Below is the <pages> element which is causing the error
  <pages>
    <page id="0" file="open-sans-16-white.png"/>
  </pages>
  <chars count="188">...

The <page /> component then calls your-file.png, and I guess something is wrong with the .png file.

I have yet to find the solution to this problem.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use the jimp.loadFont function in jimp - Snyk
To help you get started, we've selected a few jimp.loadFont ... Use Snyk Code to scan source code in minutes - no build...
Read more >
Error in Jimp.loadFont (use load-bmfont module) with React
Solved... I'm using the React App within a Java Web Framework in a JSP File. Jimp.loadFont(Jimp.FONT_SANS_32_WHITE).
Read more >
jimp - npm
Start using jimp in your project by running `npm i jimp`. ... as the second parameter, the image width and height will not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found