lib/util/Text.js
function layoutNext(lines, maxWidth, fakeText) {

  var originalLine = lines.shift(),
      fitLine = originalLine;

  var textBBox;

  for (;;) {
    textBBox = getTextBBox(fitLine, fakeText);

    textBBox.width = fitLine ? textBBox.width : 0;

    // try to fit
    if (fitLine === ' ' || fitLine === '' || textBBox.width < Math.round(maxWidth) || fitLine.length < 2) {
      return fit(lines, fitLine, originalLine, textBBox);
    }

    fitLine = shortenLine(fitLine, textBBox.width, maxWidth);
  }
}
function layoutNext(lines, maxWidth, fakeText) {

  var originalLine = lines.shift(),
      fitLine = originalLine;

  var textBBox;

  for (;;) {
    textBBox = getTextBBox(fitLine, fakeText);

    textBBox.width = fitLine ? textBBox.width : 0;

    // try to fit
    if (fitLine === ' ' || fitLine === '' || textBBox.width < Math.round(maxWidth) || fitLine.length < 2) {
      return fit(lines, fitLine, originalLine, textBBox);
    }

    fitLine = shortenLine(fitLine, textBBox.width, maxWidth);
  }
}
function layoutNext ( lines , maxWidth , fakeText ) { var originalLine = lines . shift ( ) , fitLine = originalLine ; var textBBox ; for ( ; ; ) { textBBox = getTextBBox ( fitLine , fakeText ) ; textBBox . width = fitLine ? textBBox . width : 0 ; // try to fit if ( fitLine === ' ' || fitLine === '' || textBBox . width < Math . round ( maxWidth ) || fitLine . length < 2 ) { return fit ( lines , fitLine , originalLine , textBBox ) ; } fitLine = shortenLine ( fitLine , textBBox . width , maxWidth ) ; } }
Layout the next line and return the layouted element.

Alters the lines passed.

@param  {Array<String>} lines
@return {Object} the line descriptor, an object { width, height, text }
Layout the next line and return the layouted element .