2008-01-15 23:46:32 +01:00
|
|
|
/*
|
2011-04-21 23:14:28 +02:00
|
|
|
* Copyright © 1998-2004 David Turner and Werner Lemberg
|
|
|
|
* Copyright © 2004,2007,2009 Red Hat, Inc.
|
2012-09-25 23:44:53 +02:00
|
|
|
* Copyright © 2011,2012 Google, Inc.
|
2006-03-31 14:28:09 +02:00
|
|
|
*
|
2011-04-16 00:59:56 +02:00
|
|
|
* This is part of HarfBuzz, a text shaping library.
|
2006-03-31 14:28:09 +02:00
|
|
|
*
|
2008-01-15 23:46:32 +01:00
|
|
|
* Permission is hereby granted, without written agreement and without
|
|
|
|
* license or royalty fees, to use, copy, modify, and distribute this
|
|
|
|
* software and its documentation for any purpose, provided that the
|
|
|
|
* above copyright notice and the following two paragraphs appear in
|
|
|
|
* all copies of this software.
|
2006-03-31 14:28:09 +02:00
|
|
|
*
|
2008-01-15 23:46:32 +01:00
|
|
|
* IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
|
|
|
|
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
|
|
|
|
* ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
|
|
|
|
* IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
|
|
|
* DAMAGE.
|
|
|
|
*
|
|
|
|
* THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
|
|
|
|
* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
|
|
|
|
* ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
|
|
|
|
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
|
|
|
|
*
|
|
|
|
* Red Hat Author(s): Owen Taylor, Behdad Esfahbod
|
2011-04-13 21:49:06 +02:00
|
|
|
* Google Author(s): Behdad Esfahbod
|
2006-03-31 14:28:09 +02:00
|
|
|
*/
|
2008-01-15 23:46:32 +01:00
|
|
|
|
2012-04-12 19:17:44 +02:00
|
|
|
#ifndef HB_H_IN
|
|
|
|
#error "Include <hb.h> instead."
|
|
|
|
#endif
|
|
|
|
|
2009-05-20 11:42:12 +02:00
|
|
|
#ifndef HB_BUFFER_H
|
|
|
|
#define HB_BUFFER_H
|
2006-03-31 14:28:09 +02:00
|
|
|
|
2009-05-20 11:35:14 +02:00
|
|
|
#include "hb-common.h"
|
2009-11-03 21:15:07 +01:00
|
|
|
#include "hb-unicode.h"
|
2012-11-15 21:14:09 +01:00
|
|
|
#include "hb-font.h"
|
2006-03-31 14:28:09 +02:00
|
|
|
|
2009-05-24 21:01:16 +02:00
|
|
|
HB_BEGIN_DECLS
|
2006-03-31 14:28:09 +02:00
|
|
|
|
2010-07-23 21:11:18 +02:00
|
|
|
|
2012-06-16 21:21:55 +02:00
|
|
|
typedef struct hb_buffer_t hb_buffer_t;
|
2009-08-02 04:19:06 +02:00
|
|
|
|
2012-06-16 21:21:55 +02:00
|
|
|
typedef struct hb_glyph_info_t {
|
2009-08-02 04:53:04 +02:00
|
|
|
hb_codepoint_t codepoint;
|
2009-08-08 22:53:23 +02:00
|
|
|
hb_mask_t mask;
|
2009-08-02 04:53:04 +02:00
|
|
|
uint32_t cluster;
|
2011-04-16 01:12:01 +02:00
|
|
|
|
|
|
|
/*< private >*/
|
2010-10-27 20:27:03 +02:00
|
|
|
hb_var_int_t var1;
|
|
|
|
hb_var_int_t var2;
|
2009-05-25 10:04:24 +02:00
|
|
|
} hb_glyph_info_t;
|
2006-03-31 14:28:09 +02:00
|
|
|
|
2012-06-16 21:21:55 +02:00
|
|
|
typedef struct hb_glyph_position_t {
|
2009-05-20 11:35:14 +02:00
|
|
|
hb_position_t x_advance;
|
|
|
|
hb_position_t y_advance;
|
2009-11-05 18:20:11 +01:00
|
|
|
hb_position_t x_offset;
|
|
|
|
hb_position_t y_offset;
|
2011-04-16 01:12:01 +02:00
|
|
|
|
|
|
|
/*< private >*/
|
2010-10-27 20:42:15 +02:00
|
|
|
hb_var_int_t var;
|
2009-05-25 10:04:24 +02:00
|
|
|
} hb_glyph_position_t;
|
2006-03-31 14:28:09 +02:00
|
|
|
|
|
|
|
|
2009-08-02 04:19:06 +02:00
|
|
|
hb_buffer_t *
|
2011-08-17 19:07:59 +02:00
|
|
|
hb_buffer_create (void);
|
2006-03-31 14:28:09 +02:00
|
|
|
|
2011-05-12 00:14:44 +02:00
|
|
|
hb_buffer_t *
|
|
|
|
hb_buffer_get_empty (void);
|
|
|
|
|
2009-08-02 04:19:06 +02:00
|
|
|
hb_buffer_t *
|
|
|
|
hb_buffer_reference (hb_buffer_t *buffer);
|
2009-05-20 11:42:12 +02:00
|
|
|
|
2009-08-02 04:19:06 +02:00
|
|
|
void
|
|
|
|
hb_buffer_destroy (hb_buffer_t *buffer);
|
2006-03-31 14:28:09 +02:00
|
|
|
|
2011-04-28 03:46:01 +02:00
|
|
|
hb_bool_t
|
|
|
|
hb_buffer_set_user_data (hb_buffer_t *buffer,
|
|
|
|
hb_user_data_key_t *key,
|
|
|
|
void * data,
|
2011-08-09 00:43:24 +02:00
|
|
|
hb_destroy_func_t destroy,
|
|
|
|
hb_bool_t replace);
|
2011-04-28 03:46:01 +02:00
|
|
|
|
|
|
|
void *
|
|
|
|
hb_buffer_get_user_data (hb_buffer_t *buffer,
|
|
|
|
hb_user_data_key_t *key);
|
|
|
|
|
2006-03-31 14:28:09 +02:00
|
|
|
|
2012-11-14 01:50:45 +01:00
|
|
|
typedef enum {
|
|
|
|
HB_BUFFER_CONTENT_TYPE_INVALID = 0,
|
|
|
|
HB_BUFFER_CONTENT_TYPE_UNICODE,
|
|
|
|
HB_BUFFER_CONTENT_TYPE_GLYPHS
|
|
|
|
} hb_buffer_content_type_t;
|
|
|
|
|
2012-09-07 04:26:16 +02:00
|
|
|
void
|
|
|
|
hb_buffer_set_content_type (hb_buffer_t *buffer,
|
|
|
|
hb_buffer_content_type_t content_type);
|
|
|
|
|
|
|
|
hb_buffer_content_type_t
|
|
|
|
hb_buffer_get_content_type (hb_buffer_t *buffer);
|
|
|
|
|
|
|
|
|
2009-11-03 21:15:07 +01:00
|
|
|
void
|
|
|
|
hb_buffer_set_unicode_funcs (hb_buffer_t *buffer,
|
|
|
|
hb_unicode_funcs_t *unicode_funcs);
|
|
|
|
|
|
|
|
hb_unicode_funcs_t *
|
|
|
|
hb_buffer_get_unicode_funcs (hb_buffer_t *buffer);
|
|
|
|
|
2007-10-11 02:07:58 +02:00
|
|
|
void
|
2009-08-02 04:19:06 +02:00
|
|
|
hb_buffer_set_direction (hb_buffer_t *buffer,
|
|
|
|
hb_direction_t direction);
|
|
|
|
|
|
|
|
hb_direction_t
|
|
|
|
hb_buffer_get_direction (hb_buffer_t *buffer);
|
|
|
|
|
2009-11-05 02:29:54 +01:00
|
|
|
void
|
|
|
|
hb_buffer_set_script (hb_buffer_t *buffer,
|
|
|
|
hb_script_t script);
|
|
|
|
|
|
|
|
hb_script_t
|
|
|
|
hb_buffer_get_script (hb_buffer_t *buffer);
|
|
|
|
|
|
|
|
void
|
|
|
|
hb_buffer_set_language (hb_buffer_t *buffer,
|
|
|
|
hb_language_t language);
|
|
|
|
|
|
|
|
hb_language_t
|
|
|
|
hb_buffer_get_language (hb_buffer_t *buffer);
|
2006-03-31 14:28:09 +02:00
|
|
|
|
2012-11-14 01:50:45 +01:00
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
HB_BUFFER_FLAGS_DEFAULT = 0x00000000,
|
|
|
|
HB_BUFFER_FLAG_BOT = 0x00000001, /* Beginning-of-text */
|
|
|
|
HB_BUFFER_FLAG_EOT = 0x00000002, /* End-of-text */
|
|
|
|
HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES = 0x00000004
|
|
|
|
} hb_buffer_flags_t;
|
|
|
|
|
2012-11-13 23:42:35 +01:00
|
|
|
void
|
|
|
|
hb_buffer_set_flags (hb_buffer_t *buffer,
|
|
|
|
hb_buffer_flags_t flags);
|
|
|
|
|
|
|
|
hb_buffer_flags_t
|
|
|
|
hb_buffer_get_flags (hb_buffer_t *buffer);
|
|
|
|
|
2009-11-03 21:15:07 +01:00
|
|
|
|
2011-04-13 21:49:06 +02:00
|
|
|
/* Resets the buffer. Afterwards it's as if it was just created,
|
|
|
|
* except that it has a larger buffer allocated perhaps... */
|
|
|
|
void
|
|
|
|
hb_buffer_reset (hb_buffer_t *buffer);
|
|
|
|
|
2012-11-13 22:57:52 +01:00
|
|
|
/* Like reset, but does NOT clear unicode_funcs. */
|
|
|
|
void
|
|
|
|
hb_buffer_clear (hb_buffer_t *buffer);
|
|
|
|
|
2012-06-06 02:35:40 +02:00
|
|
|
/* Returns false if allocation failed */
|
2010-05-15 05:20:16 +02:00
|
|
|
hb_bool_t
|
2011-04-16 00:34:45 +02:00
|
|
|
hb_buffer_pre_allocate (hb_buffer_t *buffer,
|
|
|
|
unsigned int size);
|
2009-07-28 21:43:34 +02:00
|
|
|
|
2011-04-19 06:32:19 +02:00
|
|
|
|
2012-06-06 02:35:40 +02:00
|
|
|
/* Returns false if allocation has failed before */
|
2011-04-19 06:32:19 +02:00
|
|
|
hb_bool_t
|
|
|
|
hb_buffer_allocation_successful (hb_buffer_t *buffer);
|
|
|
|
|
2009-08-11 02:59:25 +02:00
|
|
|
void
|
|
|
|
hb_buffer_reverse (hb_buffer_t *buffer);
|
|
|
|
|
2009-11-07 01:48:16 +01:00
|
|
|
void
|
|
|
|
hb_buffer_reverse_clusters (hb_buffer_t *buffer);
|
|
|
|
|
2011-08-05 04:31:05 +02:00
|
|
|
void
|
|
|
|
hb_buffer_guess_properties (hb_buffer_t *buffer);
|
|
|
|
|
2009-08-11 02:59:25 +02:00
|
|
|
|
|
|
|
/* Filling the buffer in */
|
2009-08-02 04:19:06 +02:00
|
|
|
|
2009-05-20 11:35:14 +02:00
|
|
|
void
|
2011-04-19 06:38:01 +02:00
|
|
|
hb_buffer_add (hb_buffer_t *buffer,
|
|
|
|
hb_codepoint_t codepoint,
|
|
|
|
unsigned int cluster);
|
2006-03-31 14:28:09 +02:00
|
|
|
|
2009-08-11 03:10:37 +02:00
|
|
|
void
|
|
|
|
hb_buffer_add_utf8 (hb_buffer_t *buffer,
|
|
|
|
const char *text,
|
2011-08-09 00:23:58 +02:00
|
|
|
int text_length,
|
2009-08-11 03:10:37 +02:00
|
|
|
unsigned int item_offset,
|
2011-08-09 00:23:58 +02:00
|
|
|
int item_length);
|
2009-08-11 03:10:37 +02:00
|
|
|
|
|
|
|
void
|
|
|
|
hb_buffer_add_utf16 (hb_buffer_t *buffer,
|
|
|
|
const uint16_t *text,
|
2011-08-09 00:23:58 +02:00
|
|
|
int text_length,
|
2009-08-11 03:10:37 +02:00
|
|
|
unsigned int item_offset,
|
2011-08-09 00:23:58 +02:00
|
|
|
int item_length);
|
2009-08-11 03:10:37 +02:00
|
|
|
|
|
|
|
void
|
|
|
|
hb_buffer_add_utf32 (hb_buffer_t *buffer,
|
|
|
|
const uint32_t *text,
|
2011-08-09 00:23:58 +02:00
|
|
|
int text_length,
|
2009-08-11 03:10:37 +02:00
|
|
|
unsigned int item_offset,
|
2011-08-09 00:23:58 +02:00
|
|
|
int item_length);
|
2009-08-11 03:10:37 +02:00
|
|
|
|
2009-08-02 04:19:06 +02:00
|
|
|
|
2011-04-13 21:49:06 +02:00
|
|
|
/* Clears any new items added at the end */
|
|
|
|
hb_bool_t
|
|
|
|
hb_buffer_set_length (hb_buffer_t *buffer,
|
|
|
|
unsigned int length);
|
2009-08-11 02:59:25 +02:00
|
|
|
|
2009-08-02 04:19:06 +02:00
|
|
|
/* Return value valid as long as buffer not modified */
|
|
|
|
unsigned int
|
2009-11-06 21:13:17 +01:00
|
|
|
hb_buffer_get_length (hb_buffer_t *buffer);
|
2009-08-02 04:19:06 +02:00
|
|
|
|
2011-04-13 21:49:06 +02:00
|
|
|
/* Getting glyphs out of the buffer */
|
|
|
|
|
2009-08-02 04:19:06 +02:00
|
|
|
/* Return value valid as long as buffer not modified */
|
|
|
|
hb_glyph_info_t *
|
2011-04-16 00:32:36 +02:00
|
|
|
hb_buffer_get_glyph_infos (hb_buffer_t *buffer,
|
|
|
|
unsigned int *length);
|
2009-08-02 04:19:06 +02:00
|
|
|
|
|
|
|
/* Return value valid as long as buffer not modified */
|
|
|
|
hb_glyph_position_t *
|
2011-04-16 00:32:36 +02:00
|
|
|
hb_buffer_get_glyph_positions (hb_buffer_t *buffer,
|
|
|
|
unsigned int *length);
|
2009-07-30 00:41:25 +02:00
|
|
|
|
|
|
|
|
2012-07-17 23:09:29 +02:00
|
|
|
/* Reorders a glyph buffer to have canonical in-cluster glyph order / position.
|
|
|
|
* The resulting clusters should behave identical to pre-reordering clusters.
|
|
|
|
* NOTE: This has nothing to do with Unicode normalization. */
|
|
|
|
void
|
|
|
|
hb_buffer_normalize_glyphs (hb_buffer_t *buffer);
|
|
|
|
|
|
|
|
|
2012-11-16 01:14:23 +01:00
|
|
|
/*
|
|
|
|
* Serialize
|
|
|
|
*/
|
2012-07-17 23:09:29 +02:00
|
|
|
|
2012-11-15 21:14:09 +01:00
|
|
|
typedef enum {
|
|
|
|
HB_BUFFER_SERIALIZE_FLAGS_DEFAULT = 0x00000000,
|
|
|
|
HB_BUFFER_SERIALIZE_FLAG_NO_CLUSTERS = 0x00000001,
|
|
|
|
HB_BUFFER_SERIALIZE_FLAG_NO_POSITIONS = 0x00000002,
|
|
|
|
HB_BUFFER_SERIALIZE_FLAG_NO_GLYPH_NAMES = 0x00000004
|
|
|
|
} hb_buffer_serialize_flags_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;
|
|
|
|
|
|
|
|
/* len=-1 means str is NUL-terminated. */
|
|
|
|
hb_buffer_serialize_format_t
|
|
|
|
hb_buffer_serialize_format_from_string (const char *str, int len);
|
|
|
|
|
|
|
|
const char *
|
|
|
|
hb_buffer_serialize_format_to_string (hb_buffer_serialize_format_t format);
|
|
|
|
|
2012-11-15 22:14:12 +01:00
|
|
|
const char **
|
|
|
|
hb_buffer_serialize_list_formats (void);
|
|
|
|
|
2012-11-15 21:14:09 +01:00
|
|
|
/* Returns number of items, starting at start, that were serialized. */
|
|
|
|
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, /* May be NULL */
|
|
|
|
hb_buffer_serialize_format_t format,
|
|
|
|
hb_buffer_serialize_flags_t flags);
|
|
|
|
|
|
|
|
hb_bool_t
|
|
|
|
hb_buffer_deserialize_glyphs (hb_buffer_t *buffer,
|
|
|
|
const char *buf,
|
|
|
|
unsigned int buf_len,
|
|
|
|
unsigned int *buf_consumed,
|
|
|
|
hb_font_t *font, /* May be NULL */
|
|
|
|
hb_buffer_serialize_format_t format);
|
|
|
|
|
|
|
|
|
2009-05-24 21:01:16 +02:00
|
|
|
HB_END_DECLS
|
2006-03-31 14:28:09 +02:00
|
|
|
|
2009-05-20 11:42:12 +02:00
|
|
|
#endif /* HB_BUFFER_H */
|