From 55b6725d7b1ecd12b3feaced6d432649225712c8 Mon Sep 17 00:00:00 2001 From: Yukti Nandwana Date: Tue, 17 Mar 2026 02:32:06 +0530 Subject: [PATCH 1/2] feat: add FES warning for zero or negative textSize --- src/typography/attributes.js | 8 ++++++++ 1 file changed, 8 insertions(+) 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); }; From 0a0789fa9f0aad59800ce08586bc729d2fe25be0 Mon Sep 17 00:00:00 2001 From: Yukti Nandwana Date: Wed, 18 Mar 2026 13:58:04 +0530 Subject: [PATCH 2/2] test: add unit test for zero or negative textSize FES warning --- test/unit/typography/attributes.js | 10 ++++++++++ 1 file changed, 10 insertions(+) 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() {