H
H
Habr2020-06-02 13:12:27
Node.js
Habr, 2020-06-02 13:12:27

Why question marks when writing an image in JimpJS?

When saving an image, the Cyrillic text is converted to "question" marks, how can I fix this? https://github.com/oliver-moran/jimp

Jimp.read('./data/stats.jpg', (err, image) => {
        if (err) throw err;
        Jimp.loadFont(Jimp.FONT_SANS_64_WHITE).then(font => {
            image.print(
                font, 1, 1, {
                    text: 'Тест'
                }, 500, 500
            );
            image
                .quality(60)
                .write('./data/stats/test.jpg')
        });
    });

This image is saved:
5ed6264c55b16070618501.jpeg

Answer the question

In order to leave comments, you need to log in

2 answer(s)
H
Habr, 2020-06-02
@RozmarinUS

The creation of the font https://github.com/libgdx/libgdx/wiki/Hiero helped. And its loading Jimp.loadFont('...')

V
Viacheslav Gordeiko, 2020-06-02
@Coral_Reef

Change file encoding to utf-8

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question