-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Closed
Description
Most appropriate sub-area of p5.js?
- Accessibility
- Color
- Core/Environment/Rendering
- Data
- DOM
- Events
- Image
- IO
- Math
- Typography
- Utilities
- WebGL
- Build process
- Unit testing
- Internationalization
- Friendly errors
- Other (specify if possible)
p5.js version
2.0.5
Web browser and version
Chrome
Operating system
Windows
Steps to reproduce this
Steps:
- Use textToContours with 4 arguments, and use linebreak for texts.
- It works fine when alignment is LEFT and TOP.
- However, if alignment is CENTER,CENTER, it will not work properly.
Snippet:
let font;
async function setup() {
createCanvas(400, 400);
font = await loadFont('https://inaridarkfox4231.github.io/assets/fonts/SourceSerif4.ttf');
background(200);
textAlign(LEFT,TOP); // no error
//textAlign(CENTER, CENTER); // error
textSize(120);
// Get the point array.
let contours = font.textToContours("H\nY", width/2, height/2, { sampleFactor: 0.5 });
beginShape();
for (const pts of contours) {
beginContour();
for (const pt of pts) {
vertex(pt.x, pt.y);
}
endContour(CLOSE);
}
endShape();
}
case: LEFT,TOP

case: CENTER,CENTER

Additional Information
It seems to work fine with 6 arguments.

It's clear that no errors occur. However, I don't understand the specifications, so I don't know anything more. It's a wierd function. I can’t help.
Probably here is the cause for this:
_parseArgs
However, this is just a guess, and even if this was the cause, I don't know how to fix it.
That's all.