I'm creating a p5 project in which I create text from a string, wrap it using the 'WORD' option and add it to the canvas. As an example:
let font;
function preload() {
font = loadFont('SomeFont.otf');
}
function setup() {
createCanvas(400, 400);
background(220);
enteredText = 'This is an exmple of a long text that should split';
textWrap(WORD);
textSize(30);
textAlign(CENTER, CENTER);
textFont(font);
textLeading(0.83 * 30);
rectMode(CENTER);
fill(0);
noStroke();
text(enteredText, width / 2, height / 2, 20 , 20);
}
I'd like to get a bounding shape for the text, in order to add some images on the frame.
How can I get this shape?
I thought about using textBounds()
, but I also don't have the multiline string since textWrap()
is doing it for me.
Any ideas? Re-writing textWrap()
by myself feels like an overkill since there are so many properties for it.
Thanks!