-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Open
Labels
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.4
Web browser and version
Firefox 142.0 (64bit)
Operating system
MacOSX
Steps to reproduce this
In 2.0.4 the textWidth()
function does not measure leading and trailing white space and treats a string comprising entirely of spaces as an empty string.
I suspect that the string being measured is being 'trimmed' of leading and trailing white space prior to calculating the text width.
Steps:
Run the code snippet:
- In 1.11.0 both p5js and js report the same text width
- In 2.0.4 the Javascript function behaves the same as before but the p5js textWidth function measures the text ignoring the leading and trailing spaces.
Snippet:
function setup() {
createCanvas(640, 400);
let s = " Quark ";
console.log(textWidth(s));
console.log(drawingContext.measureText(s).width);
}
ksen0