jpayne@69: /* jpayne@69: * Copyright © 1998-2004 David Turner and Werner Lemberg jpayne@69: * Copyright © 2004,2007,2009 Red Hat, Inc. jpayne@69: * Copyright © 2011,2012 Google, Inc. jpayne@69: * jpayne@69: * This is part of HarfBuzz, a text shaping library. jpayne@69: * jpayne@69: * Permission is hereby granted, without written agreement and without jpayne@69: * license or royalty fees, to use, copy, modify, and distribute this jpayne@69: * software and its documentation for any purpose, provided that the jpayne@69: * above copyright notice and the following two paragraphs appear in jpayne@69: * all copies of this software. jpayne@69: * jpayne@69: * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR jpayne@69: * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES jpayne@69: * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN jpayne@69: * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH jpayne@69: * DAMAGE. jpayne@69: * jpayne@69: * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, jpayne@69: * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND jpayne@69: * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS jpayne@69: * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO jpayne@69: * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. jpayne@69: * jpayne@69: * Red Hat Author(s): Owen Taylor, Behdad Esfahbod jpayne@69: * Google Author(s): Behdad Esfahbod jpayne@69: */ jpayne@69: jpayne@69: #ifndef HB_H_IN jpayne@69: #error "Include instead." jpayne@69: #endif jpayne@69: jpayne@69: #ifndef HB_BUFFER_H jpayne@69: #define HB_BUFFER_H jpayne@69: jpayne@69: #include "hb-common.h" jpayne@69: #include "hb-unicode.h" jpayne@69: #include "hb-font.h" jpayne@69: jpayne@69: HB_BEGIN_DECLS jpayne@69: jpayne@69: /** jpayne@69: * hb_glyph_info_t: jpayne@69: * @codepoint: either a Unicode code point (before shaping) or a glyph index jpayne@69: * (after shaping). jpayne@69: * @cluster: the index of the character in the original text that corresponds jpayne@69: * to this #hb_glyph_info_t, or whatever the client passes to jpayne@69: * hb_buffer_add(). More than one #hb_glyph_info_t can have the same jpayne@69: * @cluster value, if they resulted from the same character (e.g. one jpayne@69: * to many glyph substitution), and when more than one character gets jpayne@69: * merged in the same glyph (e.g. many to one glyph substitution) the jpayne@69: * #hb_glyph_info_t will have the smallest cluster value of them. jpayne@69: * By default some characters are merged into the same cluster jpayne@69: * (e.g. combining marks have the same cluster as their bases) jpayne@69: * even if they are separate glyphs, hb_buffer_set_cluster_level() jpayne@69: * allow selecting more fine-grained cluster handling. jpayne@69: * jpayne@69: * The #hb_glyph_info_t is the structure that holds information about the jpayne@69: * glyphs and their relation to input text. jpayne@69: */ jpayne@69: typedef struct hb_glyph_info_t jpayne@69: { jpayne@69: hb_codepoint_t codepoint; jpayne@69: /*< private >*/ jpayne@69: hb_mask_t mask; jpayne@69: /*< public >*/ jpayne@69: uint32_t cluster; jpayne@69: jpayne@69: /*< private >*/ jpayne@69: hb_var_int_t var1; jpayne@69: hb_var_int_t var2; jpayne@69: } hb_glyph_info_t; jpayne@69: jpayne@69: /** jpayne@69: * hb_glyph_flags_t: jpayne@69: * @HB_GLYPH_FLAG_UNSAFE_TO_BREAK: Indicates that if input text is broken at the jpayne@69: * beginning of the cluster this glyph is part of, jpayne@69: * then both sides need to be re-shaped, as the jpayne@69: * result might be different. On the flip side, jpayne@69: * it means that when this flag is not present, jpayne@69: * then it's safe to break the glyph-run at the jpayne@69: * beginning of this cluster, and the two sides jpayne@69: * represent the exact same result one would get jpayne@69: * if breaking input text at the beginning of jpayne@69: * this cluster and shaping the two sides jpayne@69: * separately. This can be used to optimize jpayne@69: * paragraph layout, by avoiding re-shaping jpayne@69: * of each line after line-breaking, or limiting jpayne@69: * the reshaping to a small piece around the jpayne@69: * breaking point only. jpayne@69: * @HB_GLYPH_FLAG_DEFINED: All the currently defined flags. jpayne@69: * jpayne@69: * Since: 1.5.0 jpayne@69: */ jpayne@69: typedef enum { /*< flags >*/ jpayne@69: HB_GLYPH_FLAG_UNSAFE_TO_BREAK = 0x00000001, jpayne@69: jpayne@69: HB_GLYPH_FLAG_DEFINED = 0x00000001 /* OR of all defined flags */ jpayne@69: } hb_glyph_flags_t; jpayne@69: jpayne@69: HB_EXTERN hb_glyph_flags_t jpayne@69: hb_glyph_info_get_glyph_flags (const hb_glyph_info_t *info); jpayne@69: jpayne@69: #define hb_glyph_info_get_glyph_flags(info) \ jpayne@69: ((hb_glyph_flags_t) ((unsigned int) (info)->mask & HB_GLYPH_FLAG_DEFINED)) jpayne@69: jpayne@69: jpayne@69: /** jpayne@69: * hb_glyph_position_t: jpayne@69: * @x_advance: how much the line advances after drawing this glyph when setting jpayne@69: * text in horizontal direction. jpayne@69: * @y_advance: how much the line advances after drawing this glyph when setting jpayne@69: * text in vertical direction. jpayne@69: * @x_offset: how much the glyph moves on the X-axis before drawing it, this jpayne@69: * should not affect how much the line advances. jpayne@69: * @y_offset: how much the glyph moves on the Y-axis before drawing it, this jpayne@69: * should not affect how much the line advances. jpayne@69: * jpayne@69: * The #hb_glyph_position_t is the structure that holds the positions of the jpayne@69: * glyph in both horizontal and vertical directions. All positions in jpayne@69: * #hb_glyph_position_t are relative to the current point. jpayne@69: * jpayne@69: */ jpayne@69: typedef struct hb_glyph_position_t { jpayne@69: hb_position_t x_advance; jpayne@69: hb_position_t y_advance; jpayne@69: hb_position_t x_offset; jpayne@69: hb_position_t y_offset; jpayne@69: jpayne@69: /*< private >*/ jpayne@69: hb_var_int_t var; jpayne@69: } hb_glyph_position_t; jpayne@69: jpayne@69: /** jpayne@69: * hb_segment_properties_t: jpayne@69: * @direction: the #hb_direction_t of the buffer, see hb_buffer_set_direction(). jpayne@69: * @script: the #hb_script_t of the buffer, see hb_buffer_set_script(). jpayne@69: * @language: the #hb_language_t of the buffer, see hb_buffer_set_language(). jpayne@69: * jpayne@69: * The structure that holds various text properties of an #hb_buffer_t. Can be jpayne@69: * set and retrieved using hb_buffer_set_segment_properties() and jpayne@69: * hb_buffer_get_segment_properties(), respectively. jpayne@69: */ jpayne@69: typedef struct hb_segment_properties_t { jpayne@69: hb_direction_t direction; jpayne@69: hb_script_t script; jpayne@69: hb_language_t language; jpayne@69: /*< private >*/ jpayne@69: void *reserved1; jpayne@69: void *reserved2; jpayne@69: } hb_segment_properties_t; jpayne@69: jpayne@69: #define HB_SEGMENT_PROPERTIES_DEFAULT {HB_DIRECTION_INVALID, \ jpayne@69: HB_SCRIPT_INVALID, \ jpayne@69: HB_LANGUAGE_INVALID, \ jpayne@69: (void *) 0, \ jpayne@69: (void *) 0} jpayne@69: jpayne@69: HB_EXTERN hb_bool_t jpayne@69: hb_segment_properties_equal (const hb_segment_properties_t *a, jpayne@69: const hb_segment_properties_t *b); jpayne@69: jpayne@69: HB_EXTERN unsigned int jpayne@69: hb_segment_properties_hash (const hb_segment_properties_t *p); jpayne@69: jpayne@69: jpayne@69: jpayne@69: /** jpayne@69: * hb_buffer_t: jpayne@69: * jpayne@69: * The main structure holding the input text and its properties before shaping, jpayne@69: * and output glyphs and their information after shaping. jpayne@69: */ jpayne@69: jpayne@69: typedef struct hb_buffer_t hb_buffer_t; jpayne@69: jpayne@69: HB_EXTERN hb_buffer_t * jpayne@69: hb_buffer_create (void); jpayne@69: jpayne@69: HB_EXTERN hb_buffer_t * jpayne@69: hb_buffer_get_empty (void); jpayne@69: jpayne@69: HB_EXTERN hb_buffer_t * jpayne@69: hb_buffer_reference (hb_buffer_t *buffer); jpayne@69: jpayne@69: HB_EXTERN void jpayne@69: hb_buffer_destroy (hb_buffer_t *buffer); jpayne@69: jpayne@69: HB_EXTERN hb_bool_t jpayne@69: hb_buffer_set_user_data (hb_buffer_t *buffer, jpayne@69: hb_user_data_key_t *key, jpayne@69: void * data, jpayne@69: hb_destroy_func_t destroy, jpayne@69: hb_bool_t replace); jpayne@69: jpayne@69: HB_EXTERN void * jpayne@69: hb_buffer_get_user_data (hb_buffer_t *buffer, jpayne@69: hb_user_data_key_t *key); jpayne@69: jpayne@69: jpayne@69: /** jpayne@69: * hb_buffer_content_type_t: jpayne@69: * @HB_BUFFER_CONTENT_TYPE_INVALID: Initial value for new buffer. jpayne@69: * @HB_BUFFER_CONTENT_TYPE_UNICODE: The buffer contains input characters (before shaping). jpayne@69: * @HB_BUFFER_CONTENT_TYPE_GLYPHS: The buffer contains output glyphs (after shaping). jpayne@69: */ jpayne@69: typedef enum { jpayne@69: HB_BUFFER_CONTENT_TYPE_INVALID = 0, jpayne@69: HB_BUFFER_CONTENT_TYPE_UNICODE, jpayne@69: HB_BUFFER_CONTENT_TYPE_GLYPHS jpayne@69: } hb_buffer_content_type_t; jpayne@69: jpayne@69: HB_EXTERN void jpayne@69: hb_buffer_set_content_type (hb_buffer_t *buffer, jpayne@69: hb_buffer_content_type_t content_type); jpayne@69: jpayne@69: HB_EXTERN hb_buffer_content_type_t jpayne@69: hb_buffer_get_content_type (hb_buffer_t *buffer); jpayne@69: jpayne@69: jpayne@69: HB_EXTERN void jpayne@69: hb_buffer_set_unicode_funcs (hb_buffer_t *buffer, jpayne@69: hb_unicode_funcs_t *unicode_funcs); jpayne@69: jpayne@69: HB_EXTERN hb_unicode_funcs_t * jpayne@69: hb_buffer_get_unicode_funcs (hb_buffer_t *buffer); jpayne@69: jpayne@69: HB_EXTERN void jpayne@69: hb_buffer_set_direction (hb_buffer_t *buffer, jpayne@69: hb_direction_t direction); jpayne@69: jpayne@69: HB_EXTERN hb_direction_t jpayne@69: hb_buffer_get_direction (hb_buffer_t *buffer); jpayne@69: jpayne@69: HB_EXTERN void jpayne@69: hb_buffer_set_script (hb_buffer_t *buffer, jpayne@69: hb_script_t script); jpayne@69: jpayne@69: HB_EXTERN hb_script_t jpayne@69: hb_buffer_get_script (hb_buffer_t *buffer); jpayne@69: jpayne@69: HB_EXTERN void jpayne@69: hb_buffer_set_language (hb_buffer_t *buffer, jpayne@69: hb_language_t language); jpayne@69: jpayne@69: jpayne@69: HB_EXTERN hb_language_t jpayne@69: hb_buffer_get_language (hb_buffer_t *buffer); jpayne@69: jpayne@69: HB_EXTERN void jpayne@69: hb_buffer_set_segment_properties (hb_buffer_t *buffer, jpayne@69: const hb_segment_properties_t *props); jpayne@69: jpayne@69: HB_EXTERN void jpayne@69: hb_buffer_get_segment_properties (hb_buffer_t *buffer, jpayne@69: hb_segment_properties_t *props); jpayne@69: jpayne@69: HB_EXTERN void jpayne@69: hb_buffer_guess_segment_properties (hb_buffer_t *buffer); jpayne@69: jpayne@69: jpayne@69: /** jpayne@69: * hb_buffer_flags_t: jpayne@69: * @HB_BUFFER_FLAG_DEFAULT: the default buffer flag. jpayne@69: * @HB_BUFFER_FLAG_BOT: flag indicating that special handling of the beginning jpayne@69: * of text paragraph can be applied to this buffer. Should usually jpayne@69: * be set, unless you are passing to the buffer only part jpayne@69: * of the text without the full context. jpayne@69: * @HB_BUFFER_FLAG_EOT: flag indicating that special handling of the end of text jpayne@69: * paragraph can be applied to this buffer, similar to jpayne@69: * @HB_BUFFER_FLAG_BOT. jpayne@69: * @HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES: jpayne@69: * flag indication that character with Default_Ignorable jpayne@69: * Unicode property should use the corresponding glyph jpayne@69: * from the font, instead of hiding them (done by jpayne@69: * replacing them with the space glyph and zeroing the jpayne@69: * advance width.) This flag takes precedence over jpayne@69: * @HB_BUFFER_FLAG_REMOVE_DEFAULT_IGNORABLES. jpayne@69: * @HB_BUFFER_FLAG_REMOVE_DEFAULT_IGNORABLES: jpayne@69: * flag indication that character with Default_Ignorable jpayne@69: * Unicode property should be removed from glyph string jpayne@69: * instead of hiding them (done by replacing them with the jpayne@69: * space glyph and zeroing the advance width.) jpayne@69: * @HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES takes jpayne@69: * precedence over this flag. Since: 1.8.0 jpayne@69: * @HB_BUFFER_FLAG_DO_NOT_INSERT_DOTTED_CIRCLE: jpayne@69: * flag indicating that a dotted circle should jpayne@69: * not be inserted in the rendering of incorrect jpayne@69: * character sequences (such at <0905 093E>). Since: 2.4 jpayne@69: * jpayne@69: * Since: 0.9.20 jpayne@69: */ jpayne@69: typedef enum { /*< flags >*/ jpayne@69: HB_BUFFER_FLAG_DEFAULT = 0x00000000u, jpayne@69: HB_BUFFER_FLAG_BOT = 0x00000001u, /* Beginning-of-text */ jpayne@69: HB_BUFFER_FLAG_EOT = 0x00000002u, /* End-of-text */ jpayne@69: HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES = 0x00000004u, jpayne@69: HB_BUFFER_FLAG_REMOVE_DEFAULT_IGNORABLES = 0x00000008u, jpayne@69: HB_BUFFER_FLAG_DO_NOT_INSERT_DOTTED_CIRCLE = 0x00000010u jpayne@69: } hb_buffer_flags_t; jpayne@69: jpayne@69: HB_EXTERN void jpayne@69: hb_buffer_set_flags (hb_buffer_t *buffer, jpayne@69: hb_buffer_flags_t flags); jpayne@69: jpayne@69: HB_EXTERN hb_buffer_flags_t jpayne@69: hb_buffer_get_flags (hb_buffer_t *buffer); jpayne@69: jpayne@69: /** jpayne@69: * hb_buffer_cluster_level_t: jpayne@69: * @HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES: Return cluster values grouped by graphemes into jpayne@69: * monotone order. jpayne@69: * @HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS: Return cluster values grouped into monotone order. jpayne@69: * @HB_BUFFER_CLUSTER_LEVEL_CHARACTERS: Don't group cluster values. jpayne@69: * @HB_BUFFER_CLUSTER_LEVEL_DEFAULT: Default cluster level, jpayne@69: * equal to @HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES. jpayne@69: * jpayne@69: * Since: 0.9.42 jpayne@69: */ jpayne@69: typedef enum { jpayne@69: HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES = 0, jpayne@69: HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS = 1, jpayne@69: HB_BUFFER_CLUSTER_LEVEL_CHARACTERS = 2, jpayne@69: HB_BUFFER_CLUSTER_LEVEL_DEFAULT = HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES jpayne@69: } hb_buffer_cluster_level_t; jpayne@69: jpayne@69: HB_EXTERN void jpayne@69: hb_buffer_set_cluster_level (hb_buffer_t *buffer, jpayne@69: hb_buffer_cluster_level_t cluster_level); jpayne@69: jpayne@69: HB_EXTERN hb_buffer_cluster_level_t jpayne@69: hb_buffer_get_cluster_level (hb_buffer_t *buffer); jpayne@69: jpayne@69: /** jpayne@69: * HB_BUFFER_REPLACEMENT_CODEPOINT_DEFAULT: jpayne@69: * jpayne@69: * The default code point for replacing invalid characters in a given encoding. jpayne@69: * Set to U+FFFD REPLACEMENT CHARACTER. jpayne@69: * jpayne@69: * Since: 0.9.31 jpayne@69: */ jpayne@69: #define HB_BUFFER_REPLACEMENT_CODEPOINT_DEFAULT 0xFFFDu jpayne@69: jpayne@69: HB_EXTERN void jpayne@69: hb_buffer_set_replacement_codepoint (hb_buffer_t *buffer, jpayne@69: hb_codepoint_t replacement); jpayne@69: jpayne@69: HB_EXTERN hb_codepoint_t jpayne@69: hb_buffer_get_replacement_codepoint (hb_buffer_t *buffer); jpayne@69: jpayne@69: HB_EXTERN void jpayne@69: hb_buffer_set_invisible_glyph (hb_buffer_t *buffer, jpayne@69: hb_codepoint_t invisible); jpayne@69: jpayne@69: HB_EXTERN hb_codepoint_t jpayne@69: hb_buffer_get_invisible_glyph (hb_buffer_t *buffer); jpayne@69: jpayne@69: jpayne@69: HB_EXTERN void jpayne@69: hb_buffer_reset (hb_buffer_t *buffer); jpayne@69: jpayne@69: HB_EXTERN void jpayne@69: hb_buffer_clear_contents (hb_buffer_t *buffer); jpayne@69: jpayne@69: HB_EXTERN hb_bool_t jpayne@69: hb_buffer_pre_allocate (hb_buffer_t *buffer, jpayne@69: unsigned int size); jpayne@69: jpayne@69: jpayne@69: HB_EXTERN hb_bool_t jpayne@69: hb_buffer_allocation_successful (hb_buffer_t *buffer); jpayne@69: jpayne@69: HB_EXTERN void jpayne@69: hb_buffer_reverse (hb_buffer_t *buffer); jpayne@69: jpayne@69: HB_EXTERN void jpayne@69: hb_buffer_reverse_range (hb_buffer_t *buffer, jpayne@69: unsigned int start, unsigned int end); jpayne@69: jpayne@69: HB_EXTERN void jpayne@69: hb_buffer_reverse_clusters (hb_buffer_t *buffer); jpayne@69: jpayne@69: jpayne@69: /* Filling the buffer in */ jpayne@69: jpayne@69: HB_EXTERN void jpayne@69: hb_buffer_add (hb_buffer_t *buffer, jpayne@69: hb_codepoint_t codepoint, jpayne@69: unsigned int cluster); jpayne@69: jpayne@69: HB_EXTERN void jpayne@69: hb_buffer_add_utf8 (hb_buffer_t *buffer, jpayne@69: const char *text, jpayne@69: int text_length, jpayne@69: unsigned int item_offset, jpayne@69: int item_length); jpayne@69: jpayne@69: HB_EXTERN void jpayne@69: hb_buffer_add_utf16 (hb_buffer_t *buffer, jpayne@69: const uint16_t *text, jpayne@69: int text_length, jpayne@69: unsigned int item_offset, jpayne@69: int item_length); jpayne@69: jpayne@69: HB_EXTERN void jpayne@69: hb_buffer_add_utf32 (hb_buffer_t *buffer, jpayne@69: const uint32_t *text, jpayne@69: int text_length, jpayne@69: unsigned int item_offset, jpayne@69: int item_length); jpayne@69: jpayne@69: HB_EXTERN void jpayne@69: hb_buffer_add_latin1 (hb_buffer_t *buffer, jpayne@69: const uint8_t *text, jpayne@69: int text_length, jpayne@69: unsigned int item_offset, jpayne@69: int item_length); jpayne@69: jpayne@69: HB_EXTERN void jpayne@69: hb_buffer_add_codepoints (hb_buffer_t *buffer, jpayne@69: const hb_codepoint_t *text, jpayne@69: int text_length, jpayne@69: unsigned int item_offset, jpayne@69: int item_length); jpayne@69: jpayne@69: HB_EXTERN void jpayne@69: hb_buffer_append (hb_buffer_t *buffer, jpayne@69: hb_buffer_t *source, jpayne@69: unsigned int start, jpayne@69: unsigned int end); jpayne@69: jpayne@69: HB_EXTERN hb_bool_t jpayne@69: hb_buffer_set_length (hb_buffer_t *buffer, jpayne@69: unsigned int length); jpayne@69: jpayne@69: HB_EXTERN unsigned int jpayne@69: hb_buffer_get_length (hb_buffer_t *buffer); jpayne@69: jpayne@69: /* Getting glyphs out of the buffer */ jpayne@69: jpayne@69: HB_EXTERN hb_glyph_info_t * jpayne@69: hb_buffer_get_glyph_infos (hb_buffer_t *buffer, jpayne@69: unsigned int *length); jpayne@69: jpayne@69: HB_EXTERN hb_glyph_position_t * jpayne@69: hb_buffer_get_glyph_positions (hb_buffer_t *buffer, jpayne@69: unsigned int *length); jpayne@69: jpayne@69: jpayne@69: HB_EXTERN void jpayne@69: hb_buffer_normalize_glyphs (hb_buffer_t *buffer); jpayne@69: jpayne@69: jpayne@69: /* jpayne@69: * Serialize jpayne@69: */ jpayne@69: jpayne@69: /** jpayne@69: * hb_buffer_serialize_flags_t: jpayne@69: * @HB_BUFFER_SERIALIZE_FLAG_DEFAULT: serialize glyph names, clusters and positions. jpayne@69: * @HB_BUFFER_SERIALIZE_FLAG_NO_CLUSTERS: do not serialize glyph cluster. jpayne@69: * @HB_BUFFER_SERIALIZE_FLAG_NO_POSITIONS: do not serialize glyph position information. jpayne@69: * @HB_BUFFER_SERIALIZE_FLAG_NO_GLYPH_NAMES: do no serialize glyph name. jpayne@69: * @HB_BUFFER_SERIALIZE_FLAG_GLYPH_EXTENTS: serialize glyph extents. jpayne@69: * @HB_BUFFER_SERIALIZE_FLAG_GLYPH_FLAGS: serialize glyph flags. Since: 1.5.0 jpayne@69: * @HB_BUFFER_SERIALIZE_FLAG_NO_ADVANCES: do not serialize glyph advances, jpayne@69: * glyph offsets will reflect absolute glyph positions. Since: 1.8.0 jpayne@69: * jpayne@69: * Flags that control what glyph information are serialized in hb_buffer_serialize_glyphs(). jpayne@69: * jpayne@69: * Since: 0.9.20 jpayne@69: */ jpayne@69: typedef enum { /*< flags >*/ jpayne@69: HB_BUFFER_SERIALIZE_FLAG_DEFAULT = 0x00000000u, jpayne@69: HB_BUFFER_SERIALIZE_FLAG_NO_CLUSTERS = 0x00000001u, jpayne@69: HB_BUFFER_SERIALIZE_FLAG_NO_POSITIONS = 0x00000002u, jpayne@69: HB_BUFFER_SERIALIZE_FLAG_NO_GLYPH_NAMES = 0x00000004u, jpayne@69: HB_BUFFER_SERIALIZE_FLAG_GLYPH_EXTENTS = 0x00000008u, jpayne@69: HB_BUFFER_SERIALIZE_FLAG_GLYPH_FLAGS = 0x00000010u, jpayne@69: HB_BUFFER_SERIALIZE_FLAG_NO_ADVANCES = 0x00000020u jpayne@69: } hb_buffer_serialize_flags_t; jpayne@69: jpayne@69: /** jpayne@69: * hb_buffer_serialize_format_t: jpayne@69: * @HB_BUFFER_SERIALIZE_FORMAT_TEXT: a human-readable, plain text format. jpayne@69: * @HB_BUFFER_SERIALIZE_FORMAT_JSON: a machine-readable JSON format. jpayne@69: * @HB_BUFFER_SERIALIZE_FORMAT_INVALID: invalid format. jpayne@69: * jpayne@69: * The buffer serialization and de-serialization format used in jpayne@69: * hb_buffer_serialize_glyphs() and hb_buffer_deserialize_glyphs(). jpayne@69: * jpayne@69: * Since: 0.9.2 jpayne@69: */ jpayne@69: typedef enum { jpayne@69: HB_BUFFER_SERIALIZE_FORMAT_TEXT = HB_TAG('T','E','X','T'), jpayne@69: HB_BUFFER_SERIALIZE_FORMAT_JSON = HB_TAG('J','S','O','N'), jpayne@69: HB_BUFFER_SERIALIZE_FORMAT_INVALID = HB_TAG_NONE jpayne@69: } hb_buffer_serialize_format_t; jpayne@69: jpayne@69: HB_EXTERN hb_buffer_serialize_format_t jpayne@69: hb_buffer_serialize_format_from_string (const char *str, int len); jpayne@69: jpayne@69: HB_EXTERN const char * jpayne@69: hb_buffer_serialize_format_to_string (hb_buffer_serialize_format_t format); jpayne@69: jpayne@69: HB_EXTERN const char ** jpayne@69: hb_buffer_serialize_list_formats (void); jpayne@69: jpayne@69: HB_EXTERN unsigned int jpayne@69: hb_buffer_serialize_glyphs (hb_buffer_t *buffer, jpayne@69: unsigned int start, jpayne@69: unsigned int end, jpayne@69: char *buf, jpayne@69: unsigned int buf_size, jpayne@69: unsigned int *buf_consumed, jpayne@69: hb_font_t *font, jpayne@69: hb_buffer_serialize_format_t format, jpayne@69: hb_buffer_serialize_flags_t flags); jpayne@69: jpayne@69: HB_EXTERN hb_bool_t jpayne@69: hb_buffer_deserialize_glyphs (hb_buffer_t *buffer, jpayne@69: const char *buf, jpayne@69: int buf_len, jpayne@69: const char **end_ptr, jpayne@69: hb_font_t *font, jpayne@69: hb_buffer_serialize_format_t format); jpayne@69: jpayne@69: jpayne@69: /* jpayne@69: * Compare buffers jpayne@69: */ jpayne@69: jpayne@69: typedef enum { /*< flags >*/ jpayne@69: HB_BUFFER_DIFF_FLAG_EQUAL = 0x0000, jpayne@69: jpayne@69: /* Buffers with different content_type cannot be meaningfully compared jpayne@69: * in any further detail. */ jpayne@69: HB_BUFFER_DIFF_FLAG_CONTENT_TYPE_MISMATCH = 0x0001, jpayne@69: jpayne@69: /* For buffers with differing length, the per-glyph comparison is not jpayne@69: * attempted, though we do still scan reference for dottedcircle / .notdef jpayne@69: * glyphs. */ jpayne@69: HB_BUFFER_DIFF_FLAG_LENGTH_MISMATCH = 0x0002, jpayne@69: jpayne@69: /* We want to know if dottedcircle / .notdef glyphs are present in the jpayne@69: * reference, as we may not care so much about other differences in this jpayne@69: * case. */ jpayne@69: HB_BUFFER_DIFF_FLAG_NOTDEF_PRESENT = 0x0004, jpayne@69: HB_BUFFER_DIFF_FLAG_DOTTED_CIRCLE_PRESENT = 0x0008, jpayne@69: jpayne@69: /* If the buffers have the same length, we compare them glyph-by-glyph jpayne@69: * and report which aspect(s) of the glyph info/position are different. */ jpayne@69: HB_BUFFER_DIFF_FLAG_CODEPOINT_MISMATCH = 0x0010, jpayne@69: HB_BUFFER_DIFF_FLAG_CLUSTER_MISMATCH = 0x0020, jpayne@69: HB_BUFFER_DIFF_FLAG_GLYPH_FLAGS_MISMATCH = 0x0040, jpayne@69: HB_BUFFER_DIFF_FLAG_POSITION_MISMATCH = 0x0080 jpayne@69: jpayne@69: } hb_buffer_diff_flags_t; jpayne@69: jpayne@69: /* Compare the contents of two buffers, report types of differences. */ jpayne@69: HB_EXTERN hb_buffer_diff_flags_t jpayne@69: hb_buffer_diff (hb_buffer_t *buffer, jpayne@69: hb_buffer_t *reference, jpayne@69: hb_codepoint_t dottedcircle_glyph, jpayne@69: unsigned int position_fuzz); jpayne@69: jpayne@69: jpayne@69: /* jpayne@69: * Debugging. jpayne@69: */ jpayne@69: jpayne@69: typedef hb_bool_t (*hb_buffer_message_func_t) (hb_buffer_t *buffer, jpayne@69: hb_font_t *font, jpayne@69: const char *message, jpayne@69: void *user_data); jpayne@69: jpayne@69: HB_EXTERN void jpayne@69: hb_buffer_set_message_func (hb_buffer_t *buffer, jpayne@69: hb_buffer_message_func_t func, jpayne@69: void *user_data, hb_destroy_func_t destroy); jpayne@69: jpayne@69: jpayne@69: HB_END_DECLS jpayne@69: jpayne@69: #endif /* HB_BUFFER_H */