Capítulo 208 de 859

Chapter 208: TTFLoader

Core Idea

A loader for the TTF format.

Loads TTF files and converts them into typeface JSON that can be used directly to create THREE.Font objects.

Key Concepts

  • reversed : boolean: Whether the TTF commands should be reversed or not.

Code Examples

const loader = new TTFLoader();
const json = await loader.loadAsync( 'fonts/ttf/kenpixel.ttf' );
const font = new Font( json );
  • What it demonstrates: Typical usage of TTFLoader.

Reference Tables

Constructor

Signature
new TTFLoader( manager : LoadingManager )

Properties

PropertyDescription
.reversed : booleanWhether the TTF commands should be reversed or not.

Methods

MethodDescription
.load( url : string, onLoad : function, onProgress : onProgressCallback, onError : onErrorCallback )Starts loading from the given URL and passes the loaded TTF asset to the onLoad() callback.
.parse( arraybuffer : ArrayBuffer ) : ObjectParses the given TTF data and returns a JSON for creating a font.

Key Takeaways

  1. TTFLoader extends: Loader
  2. Most relevant properties: reversed.
  3. Key methods: load, parse.

Connects To