-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Open
Labels
Description
Most appropriate sub-area of p5.js?
- Accessibility
- Color
- Core/Environment/Rendering
- Data
- DOM
- Events
- Image
- IO
- Math
- Typography
- Utilities
- p5.strands
- WebGL
- DevOps, Build process, Unit testing
- Internationalization (i18n)
- Friendly Errors
- Other (specify if possible)
p5.js version
2.0.3
Web browser and version
Chrome 137.0.7151.68
Operating system
MacOSX
Steps to reproduce this
Steps:
The bug happens when the text is aligned (center, center), and the text has multiple lines.

Snippet:
let font;
function preload() {
font = loadFont("./CourierPrime-Regular.ttf");
}
function setup() {
createCanvas(windowWidth, windowHeight);
const myText = "La Garita Stock Driveway Road";
const name = myText.split(" ").join("\n");
textFont(font);
textSize(12);
textAlign(CENTER, CENTER);
const bounds = font.textBounds(name, 200, 200);
rect(bounds.x, bounds.y, bounds.w, bounds.h);
text(name, 200, 200);
}
quinton-ashley