From bef791a316b750a2289d29d933037d6657cfea80 Mon Sep 17 00:00:00 2001 From: RandomGamingDev Date: Thu, 9 May 2024 10:56:32 -0400 Subject: [PATCH 1/3] added WebGL text error and textFont documentation update --- src/typography/loading_displaying.js | 18 ++++++++++++++++++ src/webgl/text.js | 3 ++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/typography/loading_displaying.js b/src/typography/loading_displaying.js index f625db3d99..09399bfdda 100644 --- a/src/typography/loading_displaying.js +++ b/src/typography/loading_displaying.js @@ -364,6 +364,24 @@ p5.prototype.text = function(str, x, y, maxWidth, maxHeight) { * *
* + * // WEBGL Example + * function preload() { + * createCanvas(100, 100, WEBGL); + * textFont('Courier New'); // In WebGL textFont has to be executed in preload + * } + * + * function setup() { + * background(200); + * textSize(24); + * text('hi', 35, 55); + * + * describe('The text "hi" written in a black, monospace font on a gray background.'); + * } + * + *
+ * + *
+ * * function setup() { * background('black'); * fill('palegreen'); diff --git a/src/webgl/text.js b/src/webgl/text.js index b5d642cc81..94921d9e73 100644 --- a/src/webgl/text.js +++ b/src/webgl/text.js @@ -642,7 +642,8 @@ class FontInfo { p5.RendererGL.prototype._renderText = function(p, line, x, y, maxY) { if (!this._textFont || typeof this._textFont === 'string') { console.log( - 'WEBGL: you must load and set a font before drawing text. See `loadFont` and `textFont` for more details.' + 'WEBGL: you must load and set a font before drawing text. See `loadFont` and `textFont`' + + '(both of which have to be executed in preload() for WebGL mode) for more details.' ); return; } From 7b5ea506b771c04ef9ebbeb9d1729e706066de1b Mon Sep 17 00:00:00 2001 From: RandomGamingDev Date: Thu, 9 May 2024 11:03:30 -0400 Subject: [PATCH 2/3] correction --- src/typography/loading_displaying.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/typography/loading_displaying.js b/src/typography/loading_displaying.js index 09399bfdda..ff9bff7093 100644 --- a/src/typography/loading_displaying.js +++ b/src/typography/loading_displaying.js @@ -366,8 +366,8 @@ p5.prototype.text = function(str, x, y, maxWidth, maxHeight) { * * // WEBGL Example * function preload() { - * createCanvas(100, 100, WEBGL); - * textFont('Courier New'); // In WebGL textFont has to be executed in preload + * createCanvas(100, 100, WEBGL); + * textFont('Courier New'); // In WebGL textFont has to be executed in preload * } * * function setup() { From b92d95f9fff30967f7c510c20027f96f10aeb4d3 Mon Sep 17 00:00:00 2001 From: RandomGamingDev Date: Thu, 9 May 2024 12:17:25 -0400 Subject: [PATCH 3/3] updated error to be even more specific --- src/webgl/text.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/webgl/text.js b/src/webgl/text.js index 94921d9e73..aff8a8db96 100644 --- a/src/webgl/text.js +++ b/src/webgl/text.js @@ -643,7 +643,7 @@ p5.RendererGL.prototype._renderText = function(p, line, x, y, maxY) { if (!this._textFont || typeof this._textFont === 'string') { console.log( 'WEBGL: you must load and set a font before drawing text. See `loadFont` and `textFont`' + - '(both of which have to be executed in preload() for WebGL mode) for more details.' + '(both of which have to be executed in preload() for WebGL mode when loading a new font) for more details.' ); return; }