function createBuffer() {
    var ptr = exports.hb_buffer_create();
    return {
      ptr: ptr,
      /**
      * Add text to the buffer.
      * @param {string} text Text to be added to the buffer.
      **/
      addText: function (text) {
        const str = createJsString(text);
        exports.hb_buffer_add_utf16(ptr, str.ptr, str.length, 0, str.length);
        str.free();
      },
      /**
      * Set buffer script, language and direction.
      *
      * This needs to be done before shaping.
      **/
      guessSegmentProperties: function () {
        return exports.hb_buffer_guess_segment_properties(ptr);
      },
      /**
      * Set buffer direction explicitly.
      * @param {string} direction: One of "ltr", "rtl", "ttb" or "btt"
      */
      setDirection: function (dir) {
        exports.hb_buffer_set_direction(ptr, {
          ltr: 4,
          rtl: 5,
          ttb: 6,
          btt: 7
        }[dir] || 0);
      },
      /**
      * Set buffer flags explicitly.
      * @param {string[]} flags: A list of strings which may be either:
      * "BOT"
      * "EOT"
      * "PRESERVE_DEFAULT_IGNORABLES"
      * "REMOVE_DEFAULT_IGNORABLES"
      * "DO_NOT_INSERT_DOTTED_CIRCLE"
      */
      setFlags: function (flags) {
        var flagValue = 0
        flags.forEach(function (s) {
          flagValue |= _buffer_flag(s);
        })

        exports.hb_buffer_set_flags(ptr,flagValue);
      },
      /**
      * Set buffer language explicitly.
      * @param {string} language: The buffer language
      */
      setLanguage: function (language) {
        var str = createCString(language);
        exports.hb_buffer_set_language(ptr, exports.hb_language_from_string(str.ptr,-1));
        str.free();
      },
      /**
      * Set buffer script explicitly.
      * @param {string} script: The buffer script
      */
      setScript: function (script) {
        var str = createCString(script);
        exports.hb_buffer_set_script(ptr, exports.hb_script_from_string(str.ptr,-1));
        str.free();
      },

      /**
      * Set the Harfbuzz clustering level.
      *
      * Affects the cluster values returned from shaping.
      * @param {number} level: Clustering level. See the Harfbuzz manual chapter
      * on Clusters.
      **/
      setClusterLevel: function (level) {
        exports.hb_buffer_set_cluster_level(ptr, level)
      },
      /**
      * Return the buffer contents as a JSON object.
      *
      * After shaping, this function will return an array of glyph information
      * objects. Each object will have the following attributes:
      *
      *   - g: The glyph ID
      *   - cl: The cluster ID
      *   - ax: Advance width (width to advance after this glyph is painted)
      *   - ay: Advance height (height to advance after this glyph is painted)
      *   - dx: X displacement (adjustment in X dimension when painting this glyph)
      *   - d5: Y displacement (adjustment in Y dimension when painting this glyph)
      **/
      json: function (font) {
        var length = exports.hb_buffer_get_length(ptr);
        var result = [];
        var infosPtr32 = exports.hb_buffer_get_glyph_infos(ptr, 0) / 4;
        var positionsPtr32 = exports.hb_buffer_get_glyph_positions(ptr, 0) / 4;
        var infos = heapu32.subarray(infosPtr32, infosPtr32 + 5 * length);
        var positions = heapi32.subarray(positionsPtr32, positionsPtr32 + 5 * length);
        for (var i = 0; i < length; ++i) {
          result.push({
            g: infos[i * 5 + 0],
            cl: infos[i * 5 + 2],
            ax: positions[i * 5 + 0],
            ay: positions[i * 5 + 1],
            dx: positions[i * 5 + 2],
            dy: positions[i * 5 + 3]
          });
        }
        return result;
      },
      /**
      * Free the object.
      */
      destroy: function () { exports.hb_buffer_destroy(ptr); }
    };
  }
/**
  * Create an object representing a Harfbuzz buffer.
  **/
Create an object representing a Harfbuzz buffer.
Create an object representing a Harfbuzz buffer .
function createBuffer() {
    var ptr = exports.hb_buffer_create();
    return {
      ptr: ptr,
      addText: function (text) {
        const str = createJsString(text);
        exports.hb_buffer_add_utf16(ptr, str.ptr, str.length, 0, str.length);
        str.free();
      },
      guessSegmentProperties: function () {
        return exports.hb_buffer_guess_segment_properties(ptr);
      },
      setDirection: function (dir) {
        exports.hb_buffer_set_direction(ptr, {
          ltr: 4,
          rtl: 5,
          ttb: 6,
          btt: 7
        }[dir] || 0);
      },
      setFlags: function (flags) {
        var flagValue = 0
        flags.forEach(function (s) {
          flagValue |= _buffer_flag(s);
        })
        exports.hb_buffer_set_flags(ptr,flagValue);
      },
      setLanguage: function (language) {
        var str = createCString(language);
        exports.hb_buffer_set_language(ptr, exports.hb_language_from_string(str.ptr,-1));
        str.free();
      },
      setScript: function (script) {
        var str = createCString(script);
        exports.hb_buffer_set_script(ptr, exports.hb_script_from_string(str.ptr,-1));
        str.free();
      },
      setClusterLevel: function (level) {
        exports.hb_buffer_set_cluster_level(ptr, level)
      },
      json: function (font) {
        var length = exports.hb_buffer_get_length(ptr);
        var result = [];
        var infosPtr32 = exports.hb_buffer_get_glyph_infos(ptr, 0) / 4;
        var positionsPtr32 = exports.hb_buffer_get_glyph_positions(ptr, 0) / 4;
        var infos = heapu32.subarray(infosPtr32, infosPtr32 + 5 * length);
        var positions = heapi32.subarray(positionsPtr32, positionsPtr32 + 5 * length);
        for (var i = 0; i < length; ++i) {
          result.push({
            g: infos[i * 5 + 0],
            cl: infos[i * 5 + 2],
            ax: positions[i * 5 + 0],
            ay: positions[i * 5 + 1],
            dx: positions[i * 5 + 2],
            dy: positions[i * 5 + 3]
          });
        }
        return result;
      },
      destroy: function () { exports.hb_buffer_destroy(ptr); }
    };
  }
function createBuffer ( ) { var ptr = exports . hb_buffer_create ( ) ; return { ptr : ptr , addText : function ( text ) { const str = createJsString ( text ) ; exports . hb_buffer_add_utf16 ( ptr , str . ptr , str . length , 0 , str . length ) ; str . free ( ) ; } , guessSegmentProperties : function ( ) { return exports . hb_buffer_guess_segment_properties ( ptr ) ; } , setDirection : function ( dir ) { exports . hb_buffer_set_direction ( ptr , { ltr : 4 , rtl : 5 , ttb : 6 , btt : 7 } [ dir ] || 0 ) ; } , setFlags : function ( flags ) { var flagValue = 0 flags . forEach ( function ( s ) { flagValue |= _buffer_flag ( s ) ; } ) exports . hb_buffer_set_flags ( ptr , flagValue ) ; } , setLanguage : function ( language ) { var str = createCString ( language ) ; exports . hb_buffer_set_language ( ptr , exports . hb_language_from_string ( str . ptr , - 1 ) ) ; str . free ( ) ; } , setScript : function ( script ) { var str = createCString ( script ) ; exports . hb_buffer_set_script ( ptr , exports . hb_script_from_string ( str . ptr , - 1 ) ) ; str . free ( ) ; } , setClusterLevel : function ( level ) { exports . hb_buffer_set_cluster_level ( ptr , level ) } , json : function ( font ) { var length = exports . hb_buffer_get_length ( ptr ) ; var result = [ ] ; var infosPtr32 = exports . hb_buffer_get_glyph_infos ( ptr , 0 ) / 4 ; var positionsPtr32 = exports . hb_buffer_get_glyph_positions ( ptr , 0 ) / 4 ; var infos = heapu32 . subarray ( infosPtr32 , infosPtr32 + 5 * length ) ; var positions = heapi32 . subarray ( positionsPtr32 , positionsPtr32 + 5 * length ) ; for ( var i = 0 ; i < length ; ++ i ) { result . push ( { g : infos [ i * 5 + 0 ] , cl : infos [ i * 5 + 2 ] , ax : positions [ i * 5 + 0 ] , ay : positions [ i * 5 + 1 ] , dx : positions [ i * 5 + 2 ] , dy : positions [ i * 5 + 3 ] } ) ; } return result ; } , destroy : function ( ) { exports . hb_buffer_destroy ( ptr ) ; } } ; }
Create an object representing a Harfbuzz buffer.
Create an object representing a Harfbuzz buffer .
/**
      * Add text to the buffer.
      * @param {string} text Text to be added to the buffer.
      **/ /**
      * Set buffer script, language and direction.
      *
      * This needs to be done before shaping.
      **/ /**
      * Set buffer direction explicitly.
      * @param {string} direction: One of "ltr", "rtl", "ttb" or "btt"
      */ /**
      * Set buffer flags explicitly.
      * @param {string[]} flags: A list of strings which may be either:
      * "BOT"
      * "EOT"
      * "PRESERVE_DEFAULT_IGNORABLES"
      * "REMOVE_DEFAULT_IGNORABLES"
      * "DO_NOT_INSERT_DOTTED_CIRCLE"
      */ /**
      * Set buffer language explicitly.
      * @param {string} language: The buffer language
      */ /**
      * Set buffer script explicitly.
      * @param {string} script: The buffer script
      */ /**
      * Set the Harfbuzz clustering level.
      *
      * Affects the cluster values returned from shaping.
      * @param {number} level: Clustering level. See the Harfbuzz manual chapter
      * on Clusters.
      **/ /**
      * Return the buffer contents as a JSON object.
      *
      * After shaping, this function will return an array of glyph information
      * objects. Each object will have the following attributes:
      *
      *   - g: The glyph ID
      *   - cl: The cluster ID
      *   - ax: Advance width (width to advance after this glyph is painted)
      *   - ay: Advance height (height to advance after this glyph is painted)
      *   - dx: X displacement (adjustment in X dimension when painting this glyph)
      *   - d5: Y displacement (adjustment in Y dimension when painting this glyph)
      **/ /**
      * Free the object.
      */