Skip to content

Conversation

Nitin2332
Copy link
Contributor

@Nitin2332 Nitin2332 commented Sep 4, 2025

Resolves #8052

PR Checklist

@perminder-17
Copy link
Collaborator

Hi, Thanks again for opening a PR on dev-2.0 branch. Actuallly, the reference looks something like this :
Screenshot from 2025-09-04 09-06-45

Can you please replace your code with this sketch : https://editor.p5js.org/aman12345/sketches/E0wMMg6ha which shows how trailing spaces are ignored.?

Copy link
Collaborator

@perminder-17 perminder-17 left a comment

Choose a reason for hiding this comment

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

Just some minor suggestion.

@@ -50,6 +50,10 @@ suite('Typography Attributes', function() {
test('should return a number for number input', function() {
assert.isNumber(myp5.textWidth(100));
});
test('should ignore leading and trailing spaces', function() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for adding tests.

Nitin2332 and others added 3 commits September 4, 2025 09:20
Comment on lines 820 to 821
* **Note:** In p5.js 2.0+, leading and trailing spaces are ignored.
* `textWidth(" Hello ")` returns the same width as `textWidth("Hello")`.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just last suggestion, I think you cannot add a note between two example sketches. If you want to add this, you should move it to line number - 758.

Copy link
Collaborator

@perminder-17 perminder-17 left a comment

Choose a reason for hiding this comment

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

Looks good!

@perminder-17 perminder-17 merged commit ca016c3 into processing:dev-2.0 Sep 5, 2025
2 checks passed
@Nitin2332 Nitin2332 deleted the fix/textwidth-spaces branch September 8, 2025 12:23
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