Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <svg id="hey"></svg>

<div class="Texts">
  <svg class="convert">Daniel</svg>
  <svg class="convert">Diekmeier</svg>
  <svg class="convert">ist ein Software-</svg>
  <svg class="convert">Entwickler</svg>
  <svg class="convert">und Designer</svg>
  <svg class="convert">und wohnt gerade in Berlin</svg>
  <svg class="convert">Aber</svg>
  <svg class="convert">lasst uns darueber</svg>
  <svg class="convert">lieber keinen Schlaf verlieren</svg>
  <svg class="convert">Denn</svg>
  <svg class="convert">wir sollen heiter</svg>
  <svg class="convert">Raum</svg>
  <svg class="convert">um Raum</svg>
  <svg class="convert">durchschreiten</svg>
  <svg class="convert">und an keinem</svg>
  <svg class="convert">wie an einer</svg>
  <svg class="convert">Heimat</svg>
  <svg class="convert">haengen.</svg>
</div>
              
            
!

CSS

              
                @font-face {
  font-family: 'Source Sans Pro';
  font-style: normal;
  font-weight: 900;
  src: local('Source Sans Pro Black'), local('SourceSansPro-Black'), url(//fonts.gstatic.com/s/sourcesanspro/v10/toadOcfmlt9b38dHJxOBGBPPOa1q11iOmmM9mDHHHX4.ttf) format('truetype');
}

* {
  margin 0
  padding 0
}

.Texts {
  padding 1rem
}

.convert {
  display block
  width 100%
  height auto
  margin-bottom 1rem
  background-color transparent //#eee
  overflow visible
  
  &:last-child {
    margin-bottom 0
  }
}

#hey {
  position absolute
  overflow hidden
  height 0
  width 0
  opacity 0
}

#hey path,
#hey2 text {
  transform-origin top left
}

              
            
!

JS

              
                console.clear()

opentype.load('//fonts.gstatic.com/s/sourcesanspro/v10/toadOcfmlt9b38dHJxOBGBPPOa1q11iOmmM9mDHHHX4.ttf', function (err, font) {
  if (err) {
    return console.log('Font could not be loaded: ' + err);
  }
  
  function reverse (val) {
    return (-1 * val) + 'px'
  }
  
  $('.convert').each(function (index, el) {
    const $el = $(el)
    const text = $el.text().toUpperCase()

    const path = font.getPath(text, 0, 0, 72)
    const svgPath = path.toSVG()
    
    const $tmp = $('#hey')
    $tmp.html(svgPath)
    const bbox = $tmp.find('path').get(0).getBBox()
    
    $el.html('<text font-family="Source Sans Pro" font-weight="900" font-size="72" x="0" y="0">' + text + '</text>')
    
    const w = $el.width()
  
    const scale = w / bbox.width

    $el.attr('width', bbox.width)
    $el.attr('height', bbox.height)
    //$el.attr('transform', `scale(${scale}) translate(${reverse(bbox.x)} ${reverse(bbox.y)})`)

    $el.find('text').css('transform', `scale(${scale}) translate(${reverse(bbox.x)}, ${reverse(bbox.y)})`)
  })
});

              
            
!
999px

Console