src/Font.js
function( buffer, enFamilyName, noMerge) {
			//cancelling in browser merge
			clearTimeout(this.mergeTimeout);

			if ( !enFamilyName ) {
				enFamilyName = this.ot.getEnglishName('fontFamily');
			}

			if ( this.fontMap[ enFamilyName ] ) {
				document.fonts.delete( this.fontMap[ enFamilyName ] );
			}

			var fontface = this.fontMap[ enFamilyName ] = (
				new window.FontFace(
					enFamilyName,
					buffer || this.toArrayBuffer()
				)
			);

			if ( fontface.status === 'error' ) {
				throw new Error('Fontface is invalid and cannot be displayed');
			}

			document.fonts.add( fontface );

			//we merge font that haven't been merge
			if ( !noMerge ) {
				var timeoutRef = this.mergeTimeout = setTimeout(function() {
				mergeFont(
					'https://merge.prototypo.io',
					{
						style: 'forbrowserdisplay',
						template: 'noidea',
						family: 'forbrowserdisplay'
					},
					'plumin',
					buffer,
					true,
					function(mergedBuffer) {
						if (timeoutRef === this.mergeTimeout) {
							this.addToFonts(mergedBuffer, enFamilyName, true);
						}
					}.bind(this)
				);
				}.bind(this), 300);
			}

			return this;
		}
function( buffer, enFamilyName, noMerge) {
			//cancelling in browser merge
			clearTimeout(this.mergeTimeout);

			if ( !enFamilyName ) {
				enFamilyName = this.ot.getEnglishName('fontFamily');
			}

			if ( this.fontMap[ enFamilyName ] ) {
				document.fonts.delete( this.fontMap[ enFamilyName ] );
			}

			var fontface = this.fontMap[ enFamilyName ] = (
				new window.FontFace(
					enFamilyName,
					buffer || this.toArrayBuffer()
				)
			);

			if ( fontface.status === 'error' ) {
				throw new Error('Fontface is invalid and cannot be displayed');
			}

			document.fonts.add( fontface );

			//we merge font that haven't been merge
			if ( !noMerge ) {
				var timeoutRef = this.mergeTimeout = setTimeout(function() {
				mergeFont(
					'https://merge.prototypo.io',
					{
						style: 'forbrowserdisplay',
						template: 'noidea',
						family: 'forbrowserdisplay'
					},
					'plumin',
					buffer,
					true,
					function(mergedBuffer) {
						if (timeoutRef === this.mergeTimeout) {
							this.addToFonts(mergedBuffer, enFamilyName, true);
						}
					}.bind(this)
				);
				}.bind(this), 300);
			}

			return this;
		}
function ( buffer , enFamilyName , noMerge ) { //cancelling in browser merge clearTimeout ( this . mergeTimeout ) ; if ( ! enFamilyName ) { enFamilyName = this . ot . getEnglishName ( 'fontFamily' ) ; } if ( this . fontMap [ enFamilyName ] ) { document . fonts . delete ( this . fontMap [ enFamilyName ] ) ; } var fontface = this . fontMap [ enFamilyName ] = ( new window . FontFace ( enFamilyName , buffer || this . toArrayBuffer ( ) ) ) ; if ( fontface . status === 'error' ) { throw new Error ( 'Fontface is invalid and cannot be displayed' ) ; } document . fonts . add ( fontface ) ; //we merge font that haven't been merge if ( ! noMerge ) { var timeoutRef = this . mergeTimeout = setTimeout ( function ( ) { mergeFont ( 'https://merge.prototypo.io' , { style : 'forbrowserdisplay' , template : 'noidea' , family : 'forbrowserdisplay' } , 'plumin' , buffer , true , function ( mergedBuffer ) { if ( timeoutRef === this . mergeTimeout ) { this . addToFonts ( mergedBuffer , enFamilyName , true ) ; } } . bind ( this ) ) ; } . bind ( this ) , 300 ) ; } return this ; }
CSS font loading, lightning fast
CSS font loading lightning fast