## hb-buffer hb-buffer |

## Synopsis

    #define             HB_SEGMENT_PROPERTIES_DEFAULT
    void                hb_buffer_add                       (hb_buffer_t *buffer,
                                                             hb_codepoint_t codepoint,
                                                             unsigned int cluster);
    void                hb_buffer_add_utf16                 (hb_buffer_t *buffer,
                                                             const uint16_t *text,
                                                             int text_length,
                                                             unsigned int item_offset,
                                                             int item_length);
    void                hb_buffer_add_utf32                 (hb_buffer_t *buffer,
                                                             const uint32_t *text,
                                                             int text_length,
                                                             unsigned int item_offset,
                                                             int item_length);
    void                hb_buffer_add_utf8                  (hb_buffer_t *buffer,
                                                             const char *text,
                                                             int text_length,
                                                             unsigned int item_offset,
                                                             int item_length);
    hb_bool_t           hb_buffer_allocation_successful     (hb_buffer_t *buffer);
    void                hb_buffer_clear_contents            (hb_buffer_t *buffer);
    enum                hb_buffer_content_type_t;
    hb_buffer_t *       hb_buffer_create                    (void);
    hb_bool_t           hb_buffer_deserialize_glyphs        (hb_buffer_t *buffer,
                                                             const char *buf,
                                                             int buf_len,
                                                             const char **end_ptr,
                                                             hb_font_t *font,
                                                             hb_buffer_serialize_format_t format);
    void                hb_buffer_destroy                   (hb_buffer_t *buffer);
    enum                hb_buffer_flags_t;
    hb_buffer_content_type_t hb_buffer_get_content_type     (hb_buffer_t *buffer);
    hb_direction_t      hb_buffer_get_direction             (hb_buffer_t *buffer);
    hb_buffer_t *       hb_buffer_get_empty                 (void);
    hb_buffer_flags_t   hb_buffer_get_flags                 (hb_buffer_t *buffer);
    hb_glyph_info_t *   hb_buffer_get_glyph_infos           (hb_buffer_t *buffer,
                                                             unsigned int *length);
    hb_glyph_position_t * hb_buffer_get_glyph_positions     (hb_buffer_t *buffer,
                                                             unsigned int *length);
    hb_language_t       hb_buffer_get_language              (hb_buffer_t *buffer);
    unsigned int        hb_buffer_get_length                (hb_buffer_t *buffer);
    hb_script_t         hb_buffer_get_script                (hb_buffer_t *buffer);
    void                hb_buffer_get_segment_properties    (hb_buffer_t *buffer,
                                                             hb_segment_properties_t *props);
    hb_unicode_funcs_t * hb_buffer_get_unicode_funcs        (hb_buffer_t *buffer);
    void *              hb_buffer_get_user_data             (hb_buffer_t *buffer,
                                                             hb_user_data_key_t *key);
    void                hb_buffer_guess_segment_properties  (hb_buffer_t *buffer);
    void                hb_buffer_normalize_glyphs          (hb_buffer_t *buffer);
    hb_bool_t           hb_buffer_pre_allocate              (hb_buffer_t *buffer,
                                                             unsigned int size);
    hb_buffer_t *       hb_buffer_reference                 (hb_buffer_t *buffer);
    void                hb_buffer_reset                     (hb_buffer_t *buffer);
    void                hb_buffer_reverse                   (hb_buffer_t *buffer);
    void                hb_buffer_reverse_clusters          (hb_buffer_t *buffer);
    enum                hb_buffer_serialize_flags_t;
    hb_buffer_serialize_format_t hb_buffer_serialize_format_from_string
                                                            (const char *str,
                                                             int len);
    enum                hb_buffer_serialize_format_t;
    const char *        hb_buffer_serialize_format_to_string
                                                            (hb_buffer_serialize_format_t format);
    unsigned int        hb_buffer_serialize_glyphs          (hb_buffer_t *buffer,
                                                             unsigned int start,
                                                             unsigned int end,
                                                             char *buf,
                                                             unsigned int buf_size,
                                                             unsigned int *buf_consumed,
                                                             hb_font_t *font,
                                                             hb_buffer_serialize_format_t format,
                                                             hb_buffer_serialize_flags_t flags);
    const char **       hb_buffer_serialize_list_formats    (void);
    void                hb_buffer_set_content_type          (hb_buffer_t *buffer,
                                                             hb_buffer_content_type_t content_type);
    void                hb_buffer_set_direction             (hb_buffer_t *buffer,
                                                             hb_direction_t direction);
    void                hb_buffer_set_flags                 (hb_buffer_t *buffer,
                                                             hb_buffer_flags_t flags);
    void                hb_buffer_set_language              (hb_buffer_t *buffer,
                                                             hb_language_t language);
    hb_bool_t           hb_buffer_set_length                (hb_buffer_t *buffer,
                                                             unsigned int length);
    void                hb_buffer_set_script                (hb_buffer_t *buffer,
                                                             hb_script_t script);
    void                hb_buffer_set_segment_properties    (hb_buffer_t *buffer,
                                                             const hb_segment_properties_t *props);
    void                hb_buffer_set_unicode_funcs         (hb_buffer_t *buffer,
                                                             hb_unicode_funcs_t *unicode_funcs);
    hb_bool_t           hb_buffer_set_user_data             (hb_buffer_t *buffer,
                                                             hb_user_data_key_t *key,
                                                             void *data,
                                                             hb_destroy_func_t destroy,
                                                             hb_bool_t replace);
    typedef             hb_buffer_t;
                        hb_glyph_info_t;
                        hb_glyph_position_t;
    hb_bool_t           hb_segment_properties_equal         (const hb_segment_properties_t *a,
                                                             const hb_segment_properties_t *b);
    unsigned int        hb_segment_properties_hash          (const hb_segment_properties_t *p);
                        hb_segment_properties_t;

## Description

## Details

### HB_SEGMENT_PROPERTIES_DEFAULT

    #define             HB_SEGMENT_PROPERTIES_DEFAULT

### hb_buffer_add ()

    void                hb_buffer_add                       (hb_buffer_t *buffer,
                                                             hb_codepoint_t codepoint,
                                                             unsigned int cluster);

`buffer` : | a buffer.

Since 1.0

### hb_buffer_add_utf16 ()

    void                hb_buffer_add_utf16                 (hb_buffer_t *buffer,
                                                             const uint16_t *text,
                                                             int text_length,
                                                             unsigned int item_offset,
                                                             int item_length);

`buffer` : | a buffer.
`text` : | . [array length=text_length]

Since 1.0

### hb_buffer_add_utf32 ()

    void                hb_buffer_add_utf32                 (hb_buffer_t *buffer,
                                                             const uint32_t *text,
                                                             int text_length,
                                                             unsigned int item_offset,
                                                             int item_length);

`buffer` : | a buffer.
`text` : | . [array length=text_length]

Since 1.0

### hb_buffer_add_utf8 ()

    void                hb_buffer_add_utf8                  (hb_buffer_t *buffer,
                                                             const char *text,
                                                             int text_length,
                                                             unsigned int item_offset,
                                                             int item_length);

`buffer` : | a buffer.
`text` : | . [array length=text_length]

Since 1.0

### hb_buffer_allocation_successful ()

    hb_bool_t           hb_buffer_allocation_successful     (hb_buffer_t *buffer);

`buffer` : | a buffer.

Since 1.0

### hb_buffer_clear_contents ()

    void                hb_buffer_clear_contents            (hb_buffer_t *buffer);

`buffer` : | a buffer.

Since 1.0

### enum hb_buffer_content_type_t

    typedef enum {
      HB_BUFFER_CONTENT_TYPE_INVALID = 0,
      HB_BUFFER_CONTENT_TYPE_UNICODE,
      HB_BUFFER_CONTENT_TYPE_GLYPHS
    } hb_buffer_content_type_t;

`HB_BUFFER_CONTENT_TYPE_INVALID` |
`HB_BUFFER_CONTENT_TYPE_UNICODE` |
`HB_BUFFER_CONTENT_TYPE_GLYPHS` |

### hb_buffer_create ()

    hb_buffer_t *       hb_buffer_create                    (void);

### hb_buffer_deserialize_glyphs ()

    hb_bool_t           hb_buffer_deserialize_glyphs        (hb_buffer_t *buffer,
                                                             const char *buf,
                                                             int buf_len,
                                                             const char **end_ptr,
                                                             hb_font_t *font,
                                                             hb_buffer_serialize_format_t format);

`buffer` : | a buffer.
`buf` : | . [array length=buf_len]
`end_ptr` : | . [out]

Since 1.0

### hb_buffer_destroy ()

    void                hb_buffer_destroy                   (hb_buffer_t *buffer);

`buffer` : | a buffer.

Since 1.0

### enum hb_buffer_flags_t

    typedef enum {
     /*< flags >*/
      HB_BUFFER_FLAG_DEFAULT			= 0x00000000u,
      HB_BUFFER_FLAG_BOT				= 0x00000001u, /* Beginning-of-text */
      HB_BUFFER_FLAG_EOT				= 0x00000002u, /* End-of-text */
      HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES = 0x00000004u
    } hb_buffer_flags_t;

`HB_BUFFER_FLAG_DEFAULT` |
`HB_BUFFER_FLAG_BOT` |
`HB_BUFFER_FLAG_EOT` |
`HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES` |

### hb_buffer_get_content_type ()

    hb_buffer_content_type_t hb_buffer_get_content_type     (hb_buffer_t *buffer);

`buffer` : | a buffer.

Since 1.0

### hb_buffer_get_direction ()

    hb_direction_t      hb_buffer_get_direction             (hb_buffer_t *buffer);

`buffer` : | a buffer.

Since 1.0

### hb_buffer_get_empty ()

    hb_buffer_t *       hb_buffer_get_empty                 (void);

Returns : | . [transfer full]

Since 1.0

### hb_buffer_get_flags ()

    hb_buffer_flags_t   hb_buffer_get_flags                 (hb_buffer_t *buffer);

`buffer` : | a buffer.

Since 1.0

### hb_buffer_get_glyph_infos ()

    hb_glyph_info_t *   hb_buffer_get_glyph_infos           (hb_buffer_t *buffer,
                                                             unsigned int *length);

Returns buffer glyph information array. Returned pointer is valid as long as buffer contents are not modified.

`buffer` : | a buffer.
`length` : | output array length. [out]
Returns : | buffer glyph information array. [transfer none][array length=length]

Since 1.0

### hb_buffer_get_glyph_positions ()

    hb_glyph_position_t * hb_buffer_get_glyph_positions     (hb_buffer_t *buffer,
                                                             unsigned int *length);

Returns buffer glyph position array. Returned pointer is valid as long as buffer contents are not modified.

`buffer` : | a buffer.
`length` : | output length. [out]
Returns : | buffer glyph position array. [transfer none][array length=length]

Since 1.0

### hb_buffer_get_language ()

    hb_language_t       hb_buffer_get_language              (hb_buffer_t *buffer);

`buffer` : | a buffer.

Since 1.0

### hb_buffer_get_length ()

    unsigned int        hb_buffer_get_length                (hb_buffer_t *buffer);

Returns the number of items in the buffer.

`buffer` : | a buffer.
Returns : | buffer length.

Since 1.0

### hb_buffer_get_script ()

    hb_script_t         hb_buffer_get_script                (hb_buffer_t *buffer);

`buffer` : | a buffer.

Since 1.0

### hb_buffer_get_segment_properties ()

    void                hb_buffer_get_segment_properties    (hb_buffer_t *buffer,
                                                             hb_segment_properties_t *props);

`buffer` : | a buffer.

Since 1.0

### hb_buffer_get_unicode_funcs ()

    hb_unicode_funcs_t * hb_buffer_get_unicode_funcs        (hb_buffer_t *buffer);

`buffer` : | a buffer.

Since 1.0

### hb_buffer_get_user_data ()

    void *              hb_buffer_get_user_data             (hb_buffer_t *buffer,
                                                             hb_user_data_key_t *key);

`buffer` : | a buffer.

Since 1.0

### hb_buffer_guess_segment_properties ()

    void                hb_buffer_guess_segment_properties  (hb_buffer_t *buffer);

Sets unset buffer segment properties based on buffer Unicode contents. If buffer is not empty, it must have content type `HB_BUFFER_CONTENT_TYPE_UNICODE`.

If buffer script is not set (ie. is `HB_SCRIPT_INVALID`), it will be set to the Unicode script of the first character in the buffer that has a script other than `HB_SCRIPT_COMMON`, `HB_SCRIPT_INHERITED`, and `HB_SCRIPT_UNKNOWN`.

Next, if buffer direction is not set (ie. is `HB_DIRECTION_INVALID`), it will be set to the natural horizontal direction of the buffer script as returned by `hb_script_get_horizontal_direction()`.

Finally, if buffer language is not set (ie. is `HB_LANGUAGE_INVALID`), it will be set to the process's default language as returned by `hb_language_get_default()`. This may change in the future by taking buffer script into consideration when choosing a language.

`buffer` : | a buffer.

Since 1.0

### hb_buffer_normalize_glyphs ()

    void                hb_buffer_normalize_glyphs          (hb_buffer_t *buffer);

`buffer` : | a buffer.

Since 1.0

### hb_buffer_pre_allocate ()

    hb_bool_t           hb_buffer_pre_allocate              (hb_buffer_t *buffer,
                                                             unsigned int size);

`buffer` : | a buffer.

Since 1.0

### hb_buffer_reference ()

    hb_buffer_t *       hb_buffer_reference                 (hb_buffer_t *buffer);

`buffer` : | a buffer.
Returns : | . [transfer full]

Since 1.0

### hb_buffer_reset ()

    void                hb_buffer_reset                     (hb_buffer_t *buffer);

`buffer` : | a buffer.

Since 1.0

### hb_buffer_reverse ()

    void                hb_buffer_reverse                   (hb_buffer_t *buffer);

Reverses buffer contents.

`buffer` : | a buffer.

Since 1.0

### hb_buffer_reverse_clusters ()

    void                hb_buffer_reverse_clusters          (hb_buffer_t *buffer);

Reverses buffer clusters. That is, the buffer contents are reversed, then each cluster (consecutive items having the same cluster number) are reversed again.

`buffer` : | a buffer.

Since 1.0

### enum hb_buffer_serialize_flags_t

    typedef enum {
     /*< flags >*/
      HB_BUFFER_SERIALIZE_FLAG_DEFAULT		= 0x00000000u,
      HB_BUFFER_SERIALIZE_FLAG_NO_CLUSTERS		= 0x00000001u,
      HB_BUFFER_SERIALIZE_FLAG_NO_POSITIONS		= 0x00000002u,
      HB_BUFFER_SERIALIZE_FLAG_NO_GLYPH_NAMES = 0x00000004u
    } hb_buffer_serialize_flags_t;

`HB_BUFFER_SERIALIZE_FLAG_DEFAULT` |
`HB_BUFFER_SERIALIZE_FLAG_NO_CLUSTERS` |
`HB_BUFFER_SERIALIZE_FLAG_NO_POSITIONS` |
`HB_BUFFER_SERIALIZE_FLAG_NO_GLYPH_NAMES` |

### hb_buffer_serialize_format_from_string ()

    hb_buffer_serialize_format_t hb_buffer_serialize_format_from_string
                                                            (const char *str,
                                                             int len);

Since 1.0

### enum hb_buffer_serialize_format_t

    typedef enum {
      HB_BUFFER_SERIALIZE_FORMAT_TEXT = HB_TAG('T','E','X','T'),
      HB_BUFFER_SERIALIZE_FORMAT_JSON = HB_TAG('J','S','O','N'),
      HB_BUFFER_SERIALIZE_FORMAT_INVALID = HB_TAG_NONE
    } hb_buffer_serialize_format_t;

`HB_BUFFER_SERIALIZE_FORMAT_TEXT` |
`HB_BUFFER_SERIALIZE_FORMAT_JSON` |
`HB_BUFFER_SERIALIZE_FORMAT_INVALID` |

### hb_buffer_serialize_format_to_string ()

    const char *        hb_buffer_serialize_format_to_string
                                                            (hb_buffer_serialize_format_t format);

Since 1.0

### hb_buffer_serialize_glyphs ()

    unsigned int        hb_buffer_serialize_glyphs          (hb_buffer_t *buffer,
                                                             unsigned int start,
                                                             unsigned int end,
                                                             char *buf,
                                                             unsigned int buf_size,
                                                             unsigned int *buf_consumed,
                                                             hb_font_t *font,
                                                             hb_buffer_serialize_format_t format,
                                                             hb_buffer_serialize_flags_t flags);

`buffer` : | a buffer.
`buf` : | . [array length=buf_size]
`buf_consumed` : | . [out]

Since 1.0

### hb_buffer_serialize_list_formats ()

    const char **       hb_buffer_serialize_list_formats    (void);

Returns : | . [transfer none]

Since 1.0

### hb_buffer_set_content_type ()

    void                hb_buffer_set_content_type          (hb_buffer_t *buffer,
                                                             hb_buffer_content_type_t content_type);

`buffer` : | a buffer.

Since 1.0

### hb_buffer_set_direction ()

    void                hb_buffer_set_direction             (hb_buffer_t *buffer,
                                                             hb_direction_t direction);

`buffer` : | a buffer.

Since 1.0

### hb_buffer_set_flags ()

    void                hb_buffer_set_flags                 (hb_buffer_t *buffer,
                                                             hb_buffer_flags_t flags);

`buffer` : | a buffer.

Since 1.0

### hb_buffer_set_language ()

    void                hb_buffer_set_language              (hb_buffer_t *buffer,
                                                             hb_language_t language);

`buffer` : | a buffer.

Since 1.0

### hb_buffer_set_length ()

    hb_bool_t           hb_buffer_set_length                (hb_buffer_t *buffer,
                                                             unsigned int length);

`buffer` : | a buffer.

Since 1.0

### hb_buffer_set_script ()

    void                hb_buffer_set_script                (hb_buffer_t *buffer,
                                                             hb_script_t script);

`buffer` : | a buffer.

Since 1.0

### hb_buffer_set_segment_properties ()

    void                hb_buffer_set_segment_properties    (hb_buffer_t *buffer,
                                                             const hb_segment_properties_t *props);

`buffer` : | a buffer.

Since 1.0

### hb_buffer_set_unicode_funcs ()

    void                hb_buffer_set_unicode_funcs         (hb_buffer_t *buffer,
                                                             hb_unicode_funcs_t *unicode_funcs);

`buffer` : | a buffer.

Since 1.0

### hb_buffer_set_user_data ()

    hb_bool_t           hb_buffer_set_user_data             (hb_buffer_t *buffer,
                                                             hb_user_data_key_t *key,
                                                             void *data,
                                                             hb_destroy_func_t destroy,
                                                             hb_bool_t replace);

`buffer` : | a buffer.

Since 1.0

### hb_buffer_t

    typedef struct hb_buffer_t hb_buffer_t;

### hb_glyph_info_t

    typedef struct {
      hb_codepoint_t codepoint;
      hb_mask_t      mask;
      uint32_t       cluster;
    } hb_glyph_info_t;

### hb_glyph_position_t

    typedef struct {
      hb_position_t  x_advance;
      hb_position_t  y_advance;
      hb_position_t  x_offset;
      hb_position_t  y_offset;
    } hb_glyph_position_t;

### hb_segment_properties_equal ()

    hb_bool_t           hb_segment_properties_equal         (const hb_segment_properties_t *a,
                                                             const hb_segment_properties_t *b);

### hb_segment_properties_hash ()

    unsigned int        hb_segment_properties_hash          (const hb_segment_properties_t *p);

### hb_segment_properties_t

    typedef struct {
      hb_direction_t  direction;
      hb_script_t     script;
      hb_language_t   language;
    } hb_segment_properties_t;