dist/bundle.js
/**
     * fitTextInBounds scales the region's text to fit inside the region's bounds, with no other transformations
     * @returns {Object} the scaled text as an opentype Path
     */
fitTextInBounds scales the region's text to fit inside the region's bounds, with no other transformations
@returns {Object} the scaled text as an opentype Path
fitTextInBounds scales the region ' s text to fit inside the region ' s bounds with no other transformations @returns { Object } the scaled text as an opentype Path
function fitTextInBounds() {
      let regionFont = wordmark.fonts[region.font];
      if (!regionFont) {
        console.error('Font file is not loaded for Bowlcut ' + wordmark.uniqueId);
        return;
      }
      let fontSize = region.bounds.height * wordmark.fudgeFactor;
      let regionText = '';
      for (let textIndex in region.slice) {
        if (region.slice[textIndex].length) {
          regionText += wordmark.text[textIndex].slice.apply(wordmark.text[textIndex], region.slice[textIndex]);
        }
        else {
          regionText += wordmark.text[textIndex];
        }
      }
      if (region.advanceWidthScale !== 1) {
        for (let glyphIndex = 0; glyphIndex < regionFont.glyphs.length; glyphIndex++) {
          let glyph = regionFont.glyphs.glyphs[glyphIndex];
          glyph.advanceWidth *= region.advanceWidthScale;
        }
      }
      let textPath = regionFont.getPath(regionText,0,0,fontSize);
      let textPathBounds = getPathElemBounds(parsePathElement(textPath,2));
      if (region.advanceWidthScale !== 1) {
        for (let glyphIndex = 0; glyphIndex < regionFont.glyphs.length; glyphIndex++) {
          let glyph = regionFont.glyphs.glyphs[glyphIndex];
          glyph.advanceWidth /= region.advanceWidthScale;
        }
      }
      let widthScale = 1;
      if (region.stretchToWidth || (textPathBounds.width > region.bounds.width)) {
        widthScale = region.bounds.width / textPathBounds.width;
      }
      let heightScale = (region.bounds.height / textPathBounds.height);
      scaleOpenPath(textPath, widthScale, heightScale);
      textPathBounds = getPathElemBounds(parsePathElement(textPath,2));
      let nx = region.bounds.x + region.bounds.width / 2 - textPathBounds.width / 2 - textPathBounds.x;
      let ny = region.bounds.y - textPathBounds.y;
      translateOpenPath(textPath, nx, ny);
      reducePathToLines(textPath, Math.pow(10, wordmark.precision));
      return textPath;
    }
function fitTextInBounds ( ) { let regionFont = wordmark . fonts [ region . font ] ; if ( ! regionFont ) { console . error ( 'Font file is not loaded for Bowlcut ' + wordmark . uniqueId ) ; return ; } let fontSize = region . bounds . height * wordmark . fudgeFactor ; let regionText = '' ; for ( let textIndex in region . slice ) { if ( region . slice [ textIndex ] . length ) { regionText += wordmark . text [ textIndex ] . slice . apply ( wordmark . text [ textIndex ] , region . slice [ textIndex ] ) ; } else { regionText += wordmark . text [ textIndex ] ; } } if ( region . advanceWidthScale !== 1 ) { for ( let glyphIndex = 0 ; glyphIndex < regionFont . glyphs . length ; glyphIndex ++ ) { let glyph = regionFont . glyphs . glyphs [ glyphIndex ] ; glyph . advanceWidth *= region . advanceWidthScale ; } } let textPath = regionFont . getPath ( regionText , 0 , 0 , fontSize ) ; let textPathBounds = getPathElemBounds ( parsePathElement ( textPath , 2 ) ) ; if ( region . advanceWidthScale !== 1 ) { for ( let glyphIndex = 0 ; glyphIndex < regionFont . glyphs . length ; glyphIndex ++ ) { let glyph = regionFont . glyphs . glyphs [ glyphIndex ] ; glyph . advanceWidth /= region . advanceWidthScale ; } } let widthScale = 1 ; if ( region . stretchToWidth || ( textPathBounds . width > region . bounds . width ) ) { widthScale = region . bounds . width / textPathBounds . width ; } let heightScale = ( region . bounds . height / textPathBounds . height ) ; scaleOpenPath ( textPath , widthScale , heightScale ) ; textPathBounds = getPathElemBounds ( parsePathElement ( textPath , 2 ) ) ; let nx = region . bounds . x + region . bounds . width / 2 - textPathBounds . width / 2 - textPathBounds . x ; let ny = region . bounds . y - textPathBounds . y ; translateOpenPath ( textPath , nx , ny ) ; reducePathToLines ( textPath , Math . pow ( 10 , wordmark . precision ) ) ; return textPath ; }
fitTextInBounds scales the region's text to fit inside the region's bounds, with no other transformations
 @returns {Object} the scaled text as an opentype Path
fitTextInBounds scales the region ' s text to fit inside the region ' s bounds with no other transformations @returns { Object } the scaled text as an opentype Path
//build region text string // if the advanceWidthScale is modified, apply it to the font glyphs //undo our changes to the font for other regions // Scale to fit bounds vertically // If width > bounds width, squish to fit // If stretchToWidth is active and width < bounds.width, fit bounds horizontally as well //update the bounds again //center the scaled text