library/detector.js
function fontDetect(content, fallback_font_type, options = {}){
  if (!content) {
    if (!globalOptions.isSilentMode()) console.warn('Content must be specified on knayi.fontDetect.');
    return fallback_font_type || 'en';
  }

	if (content === '')
		return content;

	if (!mmCharacterRange.test(content))
		return fallback_font_type || 'en';

	content = content.trim().replace(/\u200B/g, '');
	fallback_font_type = fallback_font_type || 'zawgyi';

  options = globalOptions.detector(options);

  if (options.use_myanmartools) {
    var myanmartools_zg_probability = myanmartoolZawgyiDetector.getZawgyiProbability(content);

    if (myanmartools_zg_probability < options.myanmartools_zg_threshold[0]) {
  		return 'unicode';
  	} else if (myanmartools_zg_probability > options.myanmartools_zg_threshold[1]) {
  		return 'zawgyi';
  	} else {
  		return fallback_font_type;
  	}

  } else {
    var match = {};

    for (var type in library.detect) {
  		match[type] = 0;

  		for (var i = 0; i < library.detect[type].length; i++) {
  			var rule = library.detect[type][i]
  			var m = content.match(rule);
  			match[type] += (m && m.length) || 0;
  		}
  	}

    if (match.unicode > match.zawgyi) {
  		return 'unicode';
  	} else if (match.unicode < match.zawgyi) {
  		return 'zawgyi';
  	} else {
  		return fallback_font_type;
  	}

  }
}
function fontDetect(content, fallback_font_type, options = {}){
  if (!content) {
    if (!globalOptions.isSilentMode()) console.warn('Content must be specified on knayi.fontDetect.');
    return fallback_font_type || 'en';
  }

	if (content === '')
		return content;

	if (!mmCharacterRange.test(content))
		return fallback_font_type || 'en';

	content = content.trim().replace(/\u200B/g, '');
	fallback_font_type = fallback_font_type || 'zawgyi';

  options = globalOptions.detector(options);

  if (options.use_myanmartools) {
    var myanmartools_zg_probability = myanmartoolZawgyiDetector.getZawgyiProbability(content);

    if (myanmartools_zg_probability < options.myanmartools_zg_threshold[0]) {
  		return 'unicode';
  	} else if (myanmartools_zg_probability > options.myanmartools_zg_threshold[1]) {
  		return 'zawgyi';
  	} else {
  		return fallback_font_type;
  	}

  } else {
    var match = {};

    for (var type in library.detect) {
  		match[type] = 0;

  		for (var i = 0; i < library.detect[type].length; i++) {
  			var rule = library.detect[type][i]
  			var m = content.match(rule);
  			match[type] += (m && m.length) || 0;
  		}
  	}

    if (match.unicode > match.zawgyi) {
  		return 'unicode';
  	} else if (match.unicode < match.zawgyi) {
  		return 'zawgyi';
  	} else {
  		return fallback_font_type;
  	}

  }
}
function fontDetect ( content , fallback_font_type , options = { } ) { if ( ! content ) { if ( ! globalOptions . isSilentMode ( ) ) console . warn ( 'Content must be specified on knayi.fontDetect.' ) ; return fallback_font_type || 'en' ; } if ( content === '' ) return content ; if ( ! mmCharacterRange . test ( content ) ) return fallback_font_type || 'en' ; content = content . trim ( ) . replace ( / \u200B / g , '' ) ; fallback_font_type = fallback_font_type || 'zawgyi' ; options = globalOptions . detector ( options ) ; if ( options . use_myanmartools ) { var myanmartools_zg_probability = myanmartoolZawgyiDetector . getZawgyiProbability ( content ) ; if ( myanmartools_zg_probability < options . myanmartools_zg_threshold [ 0 ] ) { return 'unicode' ; } else if ( myanmartools_zg_probability > options . myanmartools_zg_threshold [ 1 ] ) { return 'zawgyi' ; } else { return fallback_font_type ; } } else { var match = { } ; for ( var type in library . detect ) { match [ type ] = 0 ; for ( var i = 0 ; i < library . detect [ type ] . length ; i ++ ) { var rule = library . detect [ type ] [ i ] var m = content . match ( rule ) ; match [ type ] += ( m && m . length ) || 0 ; } } if ( match . unicode > match . zawgyi ) { return 'unicode' ; } else if ( match . unicode < match . zawgyi ) { return 'zawgyi' ; } else { return fallback_font_type ; } } }
Font Type Detector agent
@param content Text to make a detection
@param def Default return format;
@return unicode ? zawgyi
Font Type Detector agent