1.0.1 • Published 8 years ago

opentype-geometry v1.0.1

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

opentype-geometry

Convert opentype to geometry. Based on the opentype-layout module.

You can convert ttf files to threejs geometry to be made into a mesh like so.

  let typeLayout = new OpenTypeGeometry();

  typeLayout.loadOpenType({
    fontFace: './demo/fonts/Pacifico.ttf',
    fontSizePx: 16,
    lineHeight: 2,
    width: 100,
    letterSpacing: 1.1,
    callback: function() {
      typeLayout.setText('Some text');
      typeLayout.currentText.forEach((glyph) => {
      let mesh = new THREE.Mesh(
        glyph.geometry.geometry, 
        new THREE.MeshPhongMaterial( { color: textColor, wireframe: false }) 
      );
      mesh.position.x = glyph.position[0];
      mesh.position.y = glyph.position[1];
      scene.add(mesh);
    });
  })

Install

npm install opentype-geometry --save

Demo

Live Demo