Browse Source

FontLoader: Added parse(). See #8817.

Mr.doob 9 years ago
parent
commit
df758b8a2c
1 changed files with 11 additions and 1 deletions
  1. 11 1
      src/loaders/FontLoader.js

+ 11 - 1
src/loaders/FontLoader.js

@@ -14,13 +14,23 @@ THREE.FontLoader.prototype = {
 
 	load: function ( url, onLoad, onProgress, onError ) {
 
+		var scope = this;
+
 		var loader = new THREE.XHRLoader( this.manager );
 		loader.load( url, function ( text ) {
 
-			onLoad( new THREE.Font( JSON.parse( text.substring( 65, text.length - 2 ) ) ) );
+			var font = scope.parse( JSON.parse( text.substring( 65, text.length - 2 ) ) );
+
+			if ( onLoad ) onLoad( font );
 
 		}, onProgress, onError );
 
+	},
+
+	parse: function ( json ) {
+
+		return new THREE.Font( json );
+
 	}
 
 };