function textWrap(sentence) {
    sentence = stringify(sentence);
    if (lineHeight === void 0) lineHeight = Math.ceil(fontSize * 1.4);
    var words = split(sentence);
    var style = {
      "font-family": fontFamily,
      "font-size": fontSize,
      "font-weight": fontWeight,
      "line-height": lineHeight
    };
    var line = 1,
        textProg = "",
        truncated = false,
        widthProg = 0;
    var lineData = [],
        sizes = textWidth(words, style),
        space = textWidth(" ", style);

    for (var i = 0; i < words.length; i++) {
      var word = words[i];
      var wordWidth = sizes[words.indexOf(word)];
      word += sentence.slice(textProg.length + word.length).match("^( |\n)*", "g")[0];

      if (textProg.slice(-1) === "\n" || widthProg + wordWidth > width) {
        if (!i && !overflow) {
          truncated = true;
          break;
        }

        if (lineData.length >= line) lineData[line - 1] = trimRight(lineData[line - 1]);
        line++;

        if (lineHeight * line > height || wordWidth > width && !overflow || maxLines && line > maxLines) {
          truncated = true;
          break;
        }

        widthProg = 0;
        lineData.push(word);
      } else if (!i) lineData[0] = word;else lineData[line - 1] += word;

      textProg += word;
      widthProg += wordWidth;
      widthProg += word.match(/[\s]*$/g)[0].length * space;
    }

    return {
      lines: lineData,
      sentence: sentence,
      truncated: truncated,
      widths: textWidth(lineData, style),
      words: words
    };
  }
/**
      The inner return object and wraps the text and returns the line data array.
      @private
  */
The inner return object and wraps the text and returns the line data array.
The inner return object and wraps the text and returns the line data array .
function textWrap(sentence) {
    sentence = stringify(sentence);
    if (lineHeight === void 0) lineHeight = Math.ceil(fontSize * 1.4);
    var words = split(sentence);
    var style = {
      "font-family": fontFamily,
      "font-size": fontSize,
      "font-weight": fontWeight,
      "line-height": lineHeight
    };
    var line = 1,
        textProg = "",
        truncated = false,
        widthProg = 0;
    var lineData = [],
        sizes = textWidth(words, style),
        space = textWidth(" ", style);
    for (var i = 0; i < words.length; i++) {
      var word = words[i];
      var wordWidth = sizes[words.indexOf(word)];
      word += sentence.slice(textProg.length + word.length).match("^( |\n)*", "g")[0];
      if (textProg.slice(-1) === "\n" || widthProg + wordWidth > width) {
        if (!i && !overflow) {
          truncated = true;
          break;
        }
        if (lineData.length >= line) lineData[line - 1] = trimRight(lineData[line - 1]);
        line++;
        if (lineHeight * line > height || wordWidth > width && !overflow || maxLines && line > maxLines) {
          truncated = true;
          break;
        }
        widthProg = 0;
        lineData.push(word);
      } else if (!i) lineData[0] = word;else lineData[line - 1] += word;
      textProg += word;
      widthProg += wordWidth;
      widthProg += word.match(/[\s]*$/g)[0].length * space;
    }
    return {
      lines: lineData,
      sentence: sentence,
      truncated: truncated,
      widths: textWidth(lineData, style),
      words: words
    };
  }
function textWrap ( sentence ) { sentence = stringify ( sentence ) ; if ( lineHeight === void 0 ) lineHeight = Math . ceil ( fontSize * 1.4 ) ; var words = split ( sentence ) ; var style = { "font-family" : fontFamily , "font-size" : fontSize , "font-weight" : fontWeight , "line-height" : lineHeight } ; var line = 1 , textProg = "" , truncated = false , widthProg = 0 ; var lineData = [ ] , sizes = textWidth ( words , style ) , space = textWidth ( " " , style ) ; for ( var i = 0 ; i < words . length ; i ++ ) { var word = words [ i ] ; var wordWidth = sizes [ words . indexOf ( word ) ] ; word += sentence . slice ( textProg . length + word . length ) . match ( "^( |\n)*" , "g" ) [ 0 ] ; if ( textProg . slice ( - 1 ) === "\n" || widthProg + wordWidth > width ) { if ( ! i && ! overflow ) { truncated = true ; break ; } if ( lineData . length >= line ) lineData [ line - 1 ] = trimRight ( lineData [ line - 1 ] ) ; line ++ ; if ( lineHeight * line > height || wordWidth > width && ! overflow || maxLines && line > maxLines ) { truncated = true ; break ; } widthProg = 0 ; lineData . push ( word ) ; } else if ( ! i ) lineData [ 0 ] = word ; else lineData [ line - 1 ] += word ; textProg += word ; widthProg += wordWidth ; widthProg += word . match ( / [\s]*$ / g ) [ 0 ] . length * space ; } return { lines : lineData , sentence : sentence , truncated : truncated , widths : textWidth ( lineData , style ) , words : words } ; }
The inner return object and wraps the text and returns the line data array.
The inner return object and wraps the text and returns the line data array .