diff --git a/src/typography/attributes.js b/src/typography/attributes.js index d6a5eb8d5e..f815f9216a 100644 --- a/src/typography/attributes.js +++ b/src/typography/attributes.js @@ -191,6 +191,14 @@ p5.prototype.textLeading = function(theLeading) { */ p5.prototype.textSize = function(theSize) { p5._validateParameters('textSize', arguments); + + // New FES Warning Logic + if (arguments.length > 0 && theSize <= 0) { + p5._friendlyError( + `textSize() was called with a value of ${theSize}. ` + + 'Text size must be a positive number greater than 0 to render correctly and prevent text overlapping when wrapping.' + ); + } return this._renderer.textSize(...arguments); }; diff --git a/test/unit/typography/attributes.js b/test/unit/typography/attributes.js index ebfa6b552f..112e6e900d 100644 --- a/test/unit/typography/attributes.js +++ b/test/unit/typography/attributes.js @@ -73,6 +73,16 @@ suite('Typography Attributes', function() { myp5.textSize('30'); }); }); + // NEW TEST ADDED + test('should trigger FES warning if textSize is 0 or negative', function() { + p5.disableFriendlyErrors = false; + expect(function() { + myp5.textSize(0); + }).to.generateFriendlyError(); + expect(function() { + myp5.textSize(-5); + }).to.generateFriendlyError(); + }); }); suite('p5.prototype.textStyle', function() {