Skip to content

Conversation

perminder-17
Copy link
Collaborator

@perminder-17 perminder-17 commented Sep 12, 2025

Resolves #8079

@perminder-17 perminder-17 changed the title fixing-issue textToContours is broken under textAlign(CENTER,CENTER) and use linebreak Sep 12, 2025
Copy link
Contributor

@davepagurek davepagurek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great Perminder! Just left some very minor code format comments, otherwise good to go 🙂

);
// When width is not provided (e.g., fontBounds path), fall back to the widest line.
const maxWidth = boxes.length
? boxes.reduce((m, b) => Math.max(m, b.w || 0), 0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super minor, but I think since you provide the initial value of 0 in the reduce, we don't additionally need to have a ternary on boxes.length; the reduce will already return 0 here.

@@ -40,6 +40,16 @@ suite('p5.Font', function () {
assert.property(bbox, 'h');
});

test('fontBounds no NaN (multiline + CENTER)', async () => {
const pFont = await myp5.loadFont(fontFile);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the body of this test might be indented one time too many?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants