wordWrap(text, width, context) {
		let currentLine = "";
		const output = [];

		if (Array.isArray(text)) {
			// join into a single string
			text = text.join(" ");
		}
		// word splitting to be improved as it replaces \n by space if present
		const words = text.replace(/[\r\n]+/g, " ").split(" ");

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

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

		for (let i = 0; i < words.length; i++) {
			const word = words[i];
			const lineWidth = this.lineWidth(currentLine + word + " ", context);
			if (lineWidth < width) {
				// add the word to the current line
				currentLine += word + " ";
			} else {
				output.push(currentLine + "\n");
				currentLine = word + " ";
			}
		}
		// last line
		output.push(currentLine);

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

		return output;
	}
wrap the given text based on the given width
@param {string|string[]} text - the text to be wrapped
@param {number} width - maximum width of one segment of text in css pixel
@param {CanvasRenderingContext2D} [context] - reference to an active 2d context for canvas rendering
@returns {string[]} an array of string representing wrapped text