Jimp.loadFont(Jimp.FONT_SANS_8_BLACK) not working
See original GitHub issueExpected 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:
- Created 3 years ago
- Reactions:7
- Comments:8
Top GitHub Comments
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:
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 theYour_Font.fnt
file, and I believe it’s within this file where we are getting this error.Product of
print(Jimp.[Your_Font])
The
<page />
component then callsyour-file.png
, and I guess something is wrong with the.png
file.I have yet to find the solution to this problem.