diff --git a/src/core/p5.Renderer.js b/src/core/p5.Renderer.js index 3ffba0a05b..ecb1680326 100644 --- a/src/core/p5.Renderer.js +++ b/src/core/p5.Renderer.js @@ -298,15 +298,12 @@ p5.Renderer.prototype.text = function(str, x, y, maxWidth, maxHeight) { } } else { // no text-height specified, show warning for BOTTOM / CENTER - if (this._textBaseline === constants.BOTTOM) { - return console.warn( - 'textAlign(*, BOTTOM) requires x, y, width and height' - ); - } - if (this._textBaseline === constants.CENTER) { - return console.warn( - 'textAlign(*, CENTER) requires x, y, width and height' - ); + if (this._textBaseline === constants.BOTTOM || + this._textBaseline === constants.CENTER) { + // use rectHeight as an approximation for text height + let rectHeight = p.textSize() * this._textLeading; + finalMinHeight = y - rectHeight / 2; + finalMaxHeight = y + rectHeight / 2; } } diff --git a/src/typography/attributes.js b/src/typography/attributes.js index 3f36edc413..bc40c67539 100644 --- a/src/typography/attributes.js +++ b/src/typography/attributes.js @@ -61,9 +61,9 @@ import p5 from '../core/main'; * textAlign(CENTER, BASELINE); * text('BASELINE', 0, 62, width); * - * line(0, 87, width, 87); + * line(0, 97, width, 97); * textAlign(CENTER, BOTTOM); - * text('BOTTOM', 0, 87, width); + * text('BOTTOM', 0, 97, width); * * describe(`The names of the four vertical alignments (TOP, CENTER, BASELINE, * and BOTTOM) rendered each showing that alignment's placement relative to a