measureText(text, context) {
		let strings;

		if (!Array.isArray(text)) {
			strings = ("" + text).split("\n");
		} else {
			strings = text;
		}

		if (typeof context !== "undefined") {
			// save the previous context
			context.save();

			// apply the style font
			setContextStyle(context, this.ancestor);
		}

		// compute the bounding box size
		this.width = this.height = 0;

		for (let i = 0; i < strings.length; i++) {
			this.width = Math.max(
				this.lineWidth(strings[i].trimEnd(), context),
				this.width,
			);
			this.height += this.lineHeight();
		}
		this.width = Math.ceil(this.width);
		this.height = Math.ceil(this.height);

		// compute the bounding box position
		this.x = Math.floor(
			this.ancestor.textAlign === "right"
				? this.ancestor.pos.x - this.width
				: this.ancestor.textAlign === "center"
					? this.ancestor.pos.x - this.width / 2
					: this.ancestor.pos.x,
		);
		this.y = Math.floor(
			this.ancestor.textBaseline.search(/^(top|hanging)$/) === 0
				? this.ancestor.pos.y
				: this.ancestor.textBaseline === "middle"
					? this.ancestor.pos.y - this.lineHeight() / 2
					: this.ancestor.pos.y - this.lineHeight(),
		);

		if (typeof context !== "undefined") {
			// restore the context
			context.restore();
		}

		return this;
	}
measure the given text size in CSS pixels
@param {string} text - the text to be measured
@param {CanvasRenderingContext2D} [context] - reference to an active 2d context for canvas rendering
@returns {TextMetrics} this