A
A
ArtemEfremov2020-05-19 18:02:02
JavaScript
ArtemEfremov, 2020-05-19 18:02:02

How to auto-wrap text in Node.JS?

Hello. How to auto-wrap text in Node.JS? I work with Canvas, I attach text to a photo. Well, something like creating quotes in the picture. The user writes a command to the bot with the text that is needed in the quote and it is made into a photo. How to make the text not be on the whole photo, but wrap itself on a new line if the number of characters exceeds a different value? And so that the words were transferred normally, and not in bits. It shouldn't be like this: "Quote from me,
now it will always be here" | It should be like this: "A quote from me,
now it will always be here"

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Yakimchuk, 2020-05-19
@yakimchuk-ry

There is a method for calculating text length, https://developer.mozilla.org/en-US/docs/Web/API/C... Knowing the text width and the canvas width, you can write a wrap text renderer.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question