-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
textWidth ignores leading and trailing spaces #8067
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
textWidth ignores leading and trailing spaces #8067
Conversation
Hi, Thanks again for opening a PR on dev-2.0 branch. Actuallly, the reference looks something like this : Can you please replace your code with this sketch : https://editor.p5js.org/aman12345/sketches/E0wMMg6ha which shows how trailing spaces are ignored.? |
There was a problem hiding this 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() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding tests.
Co-authored-by: Perminder Singh <[email protected]>
Co-authored-by: Perminder Singh <[email protected]>
src/type/textCore.js
Outdated
* **Note:** In p5.js 2.0+, leading and trailing spaces are ignored. | ||
* `textWidth(" Hello ")` returns the same width as `textWidth("Hello")`. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
Resolves #8052
PR Checklist
npm run lint
passes