Path: blob/master/src/java.desktop/share/native/libharfbuzz/hb-buffer.h
66644 views
/*1* Copyright © 1998-2004 David Turner and Werner Lemberg2* Copyright © 2004,2007,2009 Red Hat, Inc.3* Copyright © 2011,2012 Google, Inc.4*5* This is part of HarfBuzz, a text shaping library.6*7* Permission is hereby granted, without written agreement and without8* license or royalty fees, to use, copy, modify, and distribute this9* software and its documentation for any purpose, provided that the10* above copyright notice and the following two paragraphs appear in11* all copies of this software.12*13* IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR14* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES15* ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN16* IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH17* DAMAGE.18*19* THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,20* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND21* FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS22* ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO23* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.24*25* Red Hat Author(s): Owen Taylor, Behdad Esfahbod26* Google Author(s): Behdad Esfahbod27*/2829#if !defined(HB_H_IN) && !defined(HB_NO_SINGLE_HEADER_ERROR)30#error "Include <hb.h> instead."31#endif3233#ifndef HB_BUFFER_H34#define HB_BUFFER_H3536#include "hb-common.h"37#include "hb-unicode.h"38#include "hb-font.h"3940HB_BEGIN_DECLS4142/**43* hb_glyph_info_t:44* @codepoint: either a Unicode code point (before shaping) or a glyph index45* (after shaping).46* @cluster: the index of the character in the original text that corresponds47* to this #hb_glyph_info_t, or whatever the client passes to48* hb_buffer_add(). More than one #hb_glyph_info_t can have the same49* @cluster value, if they resulted from the same character (e.g. one50* to many glyph substitution), and when more than one character gets51* merged in the same glyph (e.g. many to one glyph substitution) the52* #hb_glyph_info_t will have the smallest cluster value of them.53* By default some characters are merged into the same cluster54* (e.g. combining marks have the same cluster as their bases)55* even if they are separate glyphs, hb_buffer_set_cluster_level()56* allow selecting more fine-grained cluster handling.57*58* The #hb_glyph_info_t is the structure that holds information about the59* glyphs and their relation to input text.60*/61typedef struct hb_glyph_info_t {62hb_codepoint_t codepoint;63/*< private >*/64hb_mask_t mask;65/*< public >*/66uint32_t cluster;6768/*< private >*/69hb_var_int_t var1;70hb_var_int_t var2;71} hb_glyph_info_t;7273/**74* hb_glyph_flags_t:75* @HB_GLYPH_FLAG_UNSAFE_TO_BREAK: Indicates that if input text is broken at the76* beginning of the cluster this glyph is part of,77* then both sides need to be re-shaped, as the78* result might be different.79* On the flip side, it means that when this80* flag is not present, then it is safe to break81* the glyph-run at the beginning of this82* cluster, and the two sides will represent the83* exact same result one would get if breaking84* input text at the beginning of this cluster85* and shaping the two sides separately.86* This can be used to optimize paragraph87* layout, by avoiding re-shaping of each line88* after line-breaking.89* @HB_GLYPH_FLAG_UNSAFE_TO_CONCAT: Indicates that if input text is changed on one90* side of the beginning of the cluster this glyph91* is part of, then the shaping results for the92* other side might change.93* Note that the absence of this flag will NOT by94* itself mean that it IS safe to concat text.95* Only two pieces of text both of which clear of96* this flag can be concatenated safely.97* This can be used to optimize paragraph98* layout, by avoiding re-shaping of each line99* after line-breaking, by limiting the100* reshaping to a small piece around the101* breaking positin only, even if the breaking102* position carries the103* #HB_GLYPH_FLAG_UNSAFE_TO_BREAK or when104* hyphenation or other text transformation105* happens at line-break position, in the following106* way:107* 1. Iterate back from the line-break position108* until the first cluster start position that is109* NOT unsafe-to-concat, 2. shape the segment from110* there till the end of line, 3. check whether the111* resulting glyph-run also is clear of the112* unsafe-to-concat at its start-of-text position;113* if it is, just splice it into place and the line114* is shaped; If not, move on to a position further115* back that is clear of unsafe-to-concat and retry116* from there, and repeat.117* At the start of next line a similar algorithm can118* be implemented. That is: 1. Iterate forward from119* the line-break position until the first cluster120* start position that is NOT unsafe-to-concat, 2.121* shape the segment from beginning of the line to122* that position, 3. check whether the resulting123* glyph-run also is clear of the unsafe-to-concat124* at its end-of-text position; if it is, just splice125* it into place and the beginning is shaped; If not,126* move on to a position further forward that is clear127* of unsafe-to-concat and retry up to there, and repeat.128* A slight complication will arise in the129* implementation of the algorithm above,130* because while our buffer API has a way to131* return flags for position corresponding to132* start-of-text, there is currently no position133* corresponding to end-of-text. This limitation134* can be alleviated by shaping more text than needed135* and looking for unsafe-to-concat flag within text136* clusters.137* The #HB_GLYPH_FLAG_UNSAFE_TO_BREAK flag will138* always imply this flag.139* To use this flag, you must enable the buffer flag140* @HB_BUFFER_FLAG_PRODUCE_UNSAFE_TO_CONCAT during141* shaping, otherwise the buffer flag will not be142* reliably produced.143* Since: 4.0.0144* @HB_GLYPH_FLAG_DEFINED: All the currently defined flags.145*146* Flags for #hb_glyph_info_t.147*148* Since: 1.5.0149*/150typedef enum { /*< flags >*/151HB_GLYPH_FLAG_UNSAFE_TO_BREAK = 0x00000001,152HB_GLYPH_FLAG_UNSAFE_TO_CONCAT = 0x00000002,153154HB_GLYPH_FLAG_DEFINED = 0x00000003 /* OR of all defined flags */155} hb_glyph_flags_t;156157HB_EXTERN hb_glyph_flags_t158hb_glyph_info_get_glyph_flags (const hb_glyph_info_t *info);159160#define hb_glyph_info_get_glyph_flags(info) \161((hb_glyph_flags_t) ((unsigned int) (info)->mask & HB_GLYPH_FLAG_DEFINED))162163164/**165* hb_glyph_position_t:166* @x_advance: how much the line advances after drawing this glyph when setting167* text in horizontal direction.168* @y_advance: how much the line advances after drawing this glyph when setting169* text in vertical direction.170* @x_offset: how much the glyph moves on the X-axis before drawing it, this171* should not affect how much the line advances.172* @y_offset: how much the glyph moves on the Y-axis before drawing it, this173* should not affect how much the line advances.174*175* The #hb_glyph_position_t is the structure that holds the positions of the176* glyph in both horizontal and vertical directions. All positions in177* #hb_glyph_position_t are relative to the current point.178*179*/180typedef struct hb_glyph_position_t {181hb_position_t x_advance;182hb_position_t y_advance;183hb_position_t x_offset;184hb_position_t y_offset;185186/*< private >*/187hb_var_int_t var;188} hb_glyph_position_t;189190/**191* hb_segment_properties_t:192* @direction: the #hb_direction_t of the buffer, see hb_buffer_set_direction().193* @script: the #hb_script_t of the buffer, see hb_buffer_set_script().194* @language: the #hb_language_t of the buffer, see hb_buffer_set_language().195*196* The structure that holds various text properties of an #hb_buffer_t. Can be197* set and retrieved using hb_buffer_set_segment_properties() and198* hb_buffer_get_segment_properties(), respectively.199*/200typedef struct hb_segment_properties_t {201hb_direction_t direction;202hb_script_t script;203hb_language_t language;204/*< private >*/205void *reserved1;206void *reserved2;207} hb_segment_properties_t;208209/**210* HB_SEGMENT_PROPERTIES_DEFAULT:211*212* The default #hb_segment_properties_t of of freshly created #hb_buffer_t.213*/214#define HB_SEGMENT_PROPERTIES_DEFAULT {HB_DIRECTION_INVALID, \215HB_SCRIPT_INVALID, \216HB_LANGUAGE_INVALID, \217(void *) 0, \218(void *) 0}219220HB_EXTERN hb_bool_t221hb_segment_properties_equal (const hb_segment_properties_t *a,222const hb_segment_properties_t *b);223224HB_EXTERN unsigned int225hb_segment_properties_hash (const hb_segment_properties_t *p);226227HB_EXTERN void228hb_segment_properties_overlay (hb_segment_properties_t *p,229const hb_segment_properties_t *src);230231232/**233* hb_buffer_t:234*235* The main structure holding the input text and its properties before shaping,236* and output glyphs and their information after shaping.237*/238239typedef struct hb_buffer_t hb_buffer_t;240241HB_EXTERN hb_buffer_t *242hb_buffer_create (void);243244HB_EXTERN hb_buffer_t *245hb_buffer_create_similar (const hb_buffer_t *src);246247HB_EXTERN void248hb_buffer_reset (hb_buffer_t *buffer);249250251HB_EXTERN hb_buffer_t *252hb_buffer_get_empty (void);253254HB_EXTERN hb_buffer_t *255hb_buffer_reference (hb_buffer_t *buffer);256257HB_EXTERN void258hb_buffer_destroy (hb_buffer_t *buffer);259260HB_EXTERN hb_bool_t261hb_buffer_set_user_data (hb_buffer_t *buffer,262hb_user_data_key_t *key,263void * data,264hb_destroy_func_t destroy,265hb_bool_t replace);266267HB_EXTERN void *268hb_buffer_get_user_data (hb_buffer_t *buffer,269hb_user_data_key_t *key);270271272/**273* hb_buffer_content_type_t:274* @HB_BUFFER_CONTENT_TYPE_INVALID: Initial value for new buffer.275* @HB_BUFFER_CONTENT_TYPE_UNICODE: The buffer contains input characters (before shaping).276* @HB_BUFFER_CONTENT_TYPE_GLYPHS: The buffer contains output glyphs (after shaping).277*278* The type of #hb_buffer_t contents.279*/280typedef enum {281HB_BUFFER_CONTENT_TYPE_INVALID = 0,282HB_BUFFER_CONTENT_TYPE_UNICODE,283HB_BUFFER_CONTENT_TYPE_GLYPHS284} hb_buffer_content_type_t;285286HB_EXTERN void287hb_buffer_set_content_type (hb_buffer_t *buffer,288hb_buffer_content_type_t content_type);289290HB_EXTERN hb_buffer_content_type_t291hb_buffer_get_content_type (const hb_buffer_t *buffer);292293294HB_EXTERN void295hb_buffer_set_unicode_funcs (hb_buffer_t *buffer,296hb_unicode_funcs_t *unicode_funcs);297298HB_EXTERN hb_unicode_funcs_t *299hb_buffer_get_unicode_funcs (const hb_buffer_t *buffer);300301HB_EXTERN void302hb_buffer_set_direction (hb_buffer_t *buffer,303hb_direction_t direction);304305HB_EXTERN hb_direction_t306hb_buffer_get_direction (const hb_buffer_t *buffer);307308HB_EXTERN void309hb_buffer_set_script (hb_buffer_t *buffer,310hb_script_t script);311312HB_EXTERN hb_script_t313hb_buffer_get_script (const hb_buffer_t *buffer);314315HB_EXTERN void316hb_buffer_set_language (hb_buffer_t *buffer,317hb_language_t language);318319320HB_EXTERN hb_language_t321hb_buffer_get_language (const hb_buffer_t *buffer);322323HB_EXTERN void324hb_buffer_set_segment_properties (hb_buffer_t *buffer,325const hb_segment_properties_t *props);326327HB_EXTERN void328hb_buffer_get_segment_properties (const hb_buffer_t *buffer,329hb_segment_properties_t *props);330331HB_EXTERN void332hb_buffer_guess_segment_properties (hb_buffer_t *buffer);333334335/**336* hb_buffer_flags_t:337* @HB_BUFFER_FLAG_DEFAULT: the default buffer flag.338* @HB_BUFFER_FLAG_BOT: flag indicating that special handling of the beginning339* of text paragraph can be applied to this buffer. Should usually340* be set, unless you are passing to the buffer only part341* of the text without the full context.342* @HB_BUFFER_FLAG_EOT: flag indicating that special handling of the end of text343* paragraph can be applied to this buffer, similar to344* @HB_BUFFER_FLAG_BOT.345* @HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES:346* flag indication that character with Default_Ignorable347* Unicode property should use the corresponding glyph348* from the font, instead of hiding them (done by349* replacing them with the space glyph and zeroing the350* advance width.) This flag takes precedence over351* @HB_BUFFER_FLAG_REMOVE_DEFAULT_IGNORABLES.352* @HB_BUFFER_FLAG_REMOVE_DEFAULT_IGNORABLES:353* flag indication that character with Default_Ignorable354* Unicode property should be removed from glyph string355* instead of hiding them (done by replacing them with the356* space glyph and zeroing the advance width.)357* @HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES takes358* precedence over this flag. Since: 1.8.0359* @HB_BUFFER_FLAG_DO_NOT_INSERT_DOTTED_CIRCLE:360* flag indicating that a dotted circle should361* not be inserted in the rendering of incorrect362* character sequences (such at <0905 093E>). Since: 2.4.0363* @HB_BUFFER_FLAG_VERIFY:364* flag indicating that the hb_shape() call and its variants365* should perform various verification processes on the results366* of the shaping operation on the buffer. If the verification367* fails, then either a buffer message is sent, if a message368* handler is installed on the buffer, or a message is written369* to standard error. In either case, the shaping result might370* be modified to show the failed output. Since: 3.4.0371* @HB_BUFFER_FLAG_PRODUCE_UNSAFE_TO_CONCAT:372* flag indicating that the @HB_GLYPH_FLAG_UNSAFE_TO_CONCAT373* glyph-flag should be produced by the shaper. By default374* it will not be produced since it incurs a cost. Since: 4.0.0375* @HB_BUFFER_FLAG_DEFINED: All currently defined flags: Since: 4.4.0376*377* Flags for #hb_buffer_t.378*379* Since: 0.9.20380*/381typedef enum { /*< flags >*/382HB_BUFFER_FLAG_DEFAULT = 0x00000000u,383HB_BUFFER_FLAG_BOT = 0x00000001u, /* Beginning-of-text */384HB_BUFFER_FLAG_EOT = 0x00000002u, /* End-of-text */385HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES = 0x00000004u,386HB_BUFFER_FLAG_REMOVE_DEFAULT_IGNORABLES = 0x00000008u,387HB_BUFFER_FLAG_DO_NOT_INSERT_DOTTED_CIRCLE = 0x00000010u,388HB_BUFFER_FLAG_VERIFY = 0x00000020u,389HB_BUFFER_FLAG_PRODUCE_UNSAFE_TO_CONCAT = 0x00000040u,390391HB_BUFFER_FLAG_DEFINED = 0x0000007Fu392} hb_buffer_flags_t;393394HB_EXTERN void395hb_buffer_set_flags (hb_buffer_t *buffer,396hb_buffer_flags_t flags);397398HB_EXTERN hb_buffer_flags_t399hb_buffer_get_flags (const hb_buffer_t *buffer);400401/**402* hb_buffer_cluster_level_t:403* @HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES: Return cluster values grouped by graphemes into404* monotone order.405* @HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS: Return cluster values grouped into monotone order.406* @HB_BUFFER_CLUSTER_LEVEL_CHARACTERS: Don't group cluster values.407* @HB_BUFFER_CLUSTER_LEVEL_DEFAULT: Default cluster level,408* equal to @HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES.409*410* Data type for holding HarfBuzz's clustering behavior options. The cluster level411* dictates one aspect of how HarfBuzz will treat non-base characters412* during shaping.413*414* In @HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES, non-base415* characters are merged into the cluster of the base character that precedes them.416*417* In @HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS, non-base characters are initially418* assigned their own cluster values, which are not merged into preceding base419* clusters. This allows HarfBuzz to perform additional operations like reorder420* sequences of adjacent marks.421*422* @HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES is the default, because it maintains423* backward compatibility with older versions of HarfBuzz. New client programs that424* do not need to maintain such backward compatibility are recommended to use425* @HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS instead of the default.426*427* Since: 0.9.42428*/429typedef enum {430HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES = 0,431HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS = 1,432HB_BUFFER_CLUSTER_LEVEL_CHARACTERS = 2,433HB_BUFFER_CLUSTER_LEVEL_DEFAULT = HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES434} hb_buffer_cluster_level_t;435436HB_EXTERN void437hb_buffer_set_cluster_level (hb_buffer_t *buffer,438hb_buffer_cluster_level_t cluster_level);439440HB_EXTERN hb_buffer_cluster_level_t441hb_buffer_get_cluster_level (const hb_buffer_t *buffer);442443/**444* HB_BUFFER_REPLACEMENT_CODEPOINT_DEFAULT:445*446* The default code point for replacing invalid characters in a given encoding.447* Set to U+FFFD REPLACEMENT CHARACTER.448*449* Since: 0.9.31450*/451#define HB_BUFFER_REPLACEMENT_CODEPOINT_DEFAULT 0xFFFDu452453HB_EXTERN void454hb_buffer_set_replacement_codepoint (hb_buffer_t *buffer,455hb_codepoint_t replacement);456457HB_EXTERN hb_codepoint_t458hb_buffer_get_replacement_codepoint (const hb_buffer_t *buffer);459460HB_EXTERN void461hb_buffer_set_invisible_glyph (hb_buffer_t *buffer,462hb_codepoint_t invisible);463464HB_EXTERN hb_codepoint_t465hb_buffer_get_invisible_glyph (const hb_buffer_t *buffer);466467HB_EXTERN void468hb_buffer_set_not_found_glyph (hb_buffer_t *buffer,469hb_codepoint_t not_found);470471HB_EXTERN hb_codepoint_t472hb_buffer_get_not_found_glyph (const hb_buffer_t *buffer);473474475/*476* Content API.477*/478479HB_EXTERN void480hb_buffer_clear_contents (hb_buffer_t *buffer);481482HB_EXTERN hb_bool_t483hb_buffer_pre_allocate (hb_buffer_t *buffer,484unsigned int size);485486487HB_EXTERN hb_bool_t488hb_buffer_allocation_successful (hb_buffer_t *buffer);489490HB_EXTERN void491hb_buffer_reverse (hb_buffer_t *buffer);492493HB_EXTERN void494hb_buffer_reverse_range (hb_buffer_t *buffer,495unsigned int start, unsigned int end);496497HB_EXTERN void498hb_buffer_reverse_clusters (hb_buffer_t *buffer);499500501/* Filling the buffer in */502503HB_EXTERN void504hb_buffer_add (hb_buffer_t *buffer,505hb_codepoint_t codepoint,506unsigned int cluster);507508HB_EXTERN void509hb_buffer_add_utf8 (hb_buffer_t *buffer,510const char *text,511int text_length,512unsigned int item_offset,513int item_length);514515HB_EXTERN void516hb_buffer_add_utf16 (hb_buffer_t *buffer,517const uint16_t *text,518int text_length,519unsigned int item_offset,520int item_length);521522HB_EXTERN void523hb_buffer_add_utf32 (hb_buffer_t *buffer,524const uint32_t *text,525int text_length,526unsigned int item_offset,527int item_length);528529HB_EXTERN void530hb_buffer_add_latin1 (hb_buffer_t *buffer,531const uint8_t *text,532int text_length,533unsigned int item_offset,534int item_length);535536HB_EXTERN void537hb_buffer_add_codepoints (hb_buffer_t *buffer,538const hb_codepoint_t *text,539int text_length,540unsigned int item_offset,541int item_length);542543HB_EXTERN void544hb_buffer_append (hb_buffer_t *buffer,545const hb_buffer_t *source,546unsigned int start,547unsigned int end);548549HB_EXTERN hb_bool_t550hb_buffer_set_length (hb_buffer_t *buffer,551unsigned int length);552553HB_EXTERN unsigned int554hb_buffer_get_length (const hb_buffer_t *buffer);555556/* Getting glyphs out of the buffer */557558HB_EXTERN hb_glyph_info_t *559hb_buffer_get_glyph_infos (hb_buffer_t *buffer,560unsigned int *length);561562HB_EXTERN hb_glyph_position_t *563hb_buffer_get_glyph_positions (hb_buffer_t *buffer,564unsigned int *length);565566HB_EXTERN hb_bool_t567hb_buffer_has_positions (hb_buffer_t *buffer);568569570HB_EXTERN void571hb_buffer_normalize_glyphs (hb_buffer_t *buffer);572573574/*575* Serialize576*/577578/**579* hb_buffer_serialize_flags_t:580* @HB_BUFFER_SERIALIZE_FLAG_DEFAULT: serialize glyph names, clusters and positions.581* @HB_BUFFER_SERIALIZE_FLAG_NO_CLUSTERS: do not serialize glyph cluster.582* @HB_BUFFER_SERIALIZE_FLAG_NO_POSITIONS: do not serialize glyph position information.583* @HB_BUFFER_SERIALIZE_FLAG_NO_GLYPH_NAMES: do no serialize glyph name.584* @HB_BUFFER_SERIALIZE_FLAG_GLYPH_EXTENTS: serialize glyph extents.585* @HB_BUFFER_SERIALIZE_FLAG_GLYPH_FLAGS: serialize glyph flags. Since: 1.5.0586* @HB_BUFFER_SERIALIZE_FLAG_NO_ADVANCES: do not serialize glyph advances,587* glyph offsets will reflect absolute glyph positions. Since: 1.8.0588* @HB_BUFFER_SERIALIZE_FLAG_DEFINED: All currently defined flags. Since: 4.4.0589*590* Flags that control what glyph information are serialized in hb_buffer_serialize_glyphs().591*592* Since: 0.9.20593*/594typedef enum { /*< flags >*/595HB_BUFFER_SERIALIZE_FLAG_DEFAULT = 0x00000000u,596HB_BUFFER_SERIALIZE_FLAG_NO_CLUSTERS = 0x00000001u,597HB_BUFFER_SERIALIZE_FLAG_NO_POSITIONS = 0x00000002u,598HB_BUFFER_SERIALIZE_FLAG_NO_GLYPH_NAMES = 0x00000004u,599HB_BUFFER_SERIALIZE_FLAG_GLYPH_EXTENTS = 0x00000008u,600HB_BUFFER_SERIALIZE_FLAG_GLYPH_FLAGS = 0x00000010u,601HB_BUFFER_SERIALIZE_FLAG_NO_ADVANCES = 0x00000020u,602603HB_BUFFER_SERIALIZE_FLAG_DEFINED = 0x0000003Fu604} hb_buffer_serialize_flags_t;605606/**607* hb_buffer_serialize_format_t:608* @HB_BUFFER_SERIALIZE_FORMAT_TEXT: a human-readable, plain text format.609* @HB_BUFFER_SERIALIZE_FORMAT_JSON: a machine-readable JSON format.610* @HB_BUFFER_SERIALIZE_FORMAT_INVALID: invalid format.611*612* The buffer serialization and de-serialization format used in613* hb_buffer_serialize_glyphs() and hb_buffer_deserialize_glyphs().614*615* Since: 0.9.2616*/617typedef enum {618HB_BUFFER_SERIALIZE_FORMAT_TEXT = HB_TAG('T','E','X','T'),619HB_BUFFER_SERIALIZE_FORMAT_JSON = HB_TAG('J','S','O','N'),620HB_BUFFER_SERIALIZE_FORMAT_INVALID = HB_TAG_NONE621} hb_buffer_serialize_format_t;622623HB_EXTERN hb_buffer_serialize_format_t624hb_buffer_serialize_format_from_string (const char *str, int len);625626HB_EXTERN const char *627hb_buffer_serialize_format_to_string (hb_buffer_serialize_format_t format);628629HB_EXTERN const char **630hb_buffer_serialize_list_formats (void);631632HB_EXTERN unsigned int633hb_buffer_serialize_glyphs (hb_buffer_t *buffer,634unsigned int start,635unsigned int end,636char *buf,637unsigned int buf_size,638unsigned int *buf_consumed,639hb_font_t *font,640hb_buffer_serialize_format_t format,641hb_buffer_serialize_flags_t flags);642643HB_EXTERN unsigned int644hb_buffer_serialize_unicode (hb_buffer_t *buffer,645unsigned int start,646unsigned int end,647char *buf,648unsigned int buf_size,649unsigned int *buf_consumed,650hb_buffer_serialize_format_t format,651hb_buffer_serialize_flags_t flags);652653HB_EXTERN unsigned int654hb_buffer_serialize (hb_buffer_t *buffer,655unsigned int start,656unsigned int end,657char *buf,658unsigned int buf_size,659unsigned int *buf_consumed,660hb_font_t *font,661hb_buffer_serialize_format_t format,662hb_buffer_serialize_flags_t flags);663664HB_EXTERN hb_bool_t665hb_buffer_deserialize_glyphs (hb_buffer_t *buffer,666const char *buf,667int buf_len,668const char **end_ptr,669hb_font_t *font,670hb_buffer_serialize_format_t format);671672HB_EXTERN hb_bool_t673hb_buffer_deserialize_unicode (hb_buffer_t *buffer,674const char *buf,675int buf_len,676const char **end_ptr,677hb_buffer_serialize_format_t format);678679680681/*682* Compare buffers683*/684685/**686* hb_buffer_diff_flags_t:687* @HB_BUFFER_DIFF_FLAG_EQUAL: equal buffers.688* @HB_BUFFER_DIFF_FLAG_CONTENT_TYPE_MISMATCH: buffers with different689* #hb_buffer_content_type_t.690* @HB_BUFFER_DIFF_FLAG_LENGTH_MISMATCH: buffers with differing length.691* @HB_BUFFER_DIFF_FLAG_NOTDEF_PRESENT: `.notdef` glyph is present in the692* reference buffer.693* @HB_BUFFER_DIFF_FLAG_DOTTED_CIRCLE_PRESENT: dotted circle glyph is present694* in the reference buffer.695* @HB_BUFFER_DIFF_FLAG_CODEPOINT_MISMATCH: difference in #hb_glyph_info_t.codepoint696* @HB_BUFFER_DIFF_FLAG_CLUSTER_MISMATCH: difference in #hb_glyph_info_t.cluster697* @HB_BUFFER_DIFF_FLAG_GLYPH_FLAGS_MISMATCH: difference in #hb_glyph_flags_t.698* @HB_BUFFER_DIFF_FLAG_POSITION_MISMATCH: difference in #hb_glyph_position_t.699*700* Flags from comparing two #hb_buffer_t's.701*702* Buffer with different #hb_buffer_content_type_t cannot be meaningfully703* compared in any further detail.704*705* For buffers with differing length, the per-glyph comparison is not706* attempted, though we do still scan reference buffer for dotted circle and707* `.notdef` glyphs.708*709* If the buffers have the same length, we compare them glyph-by-glyph and710* report which aspect(s) of the glyph info/position are different.711*712* Since: 1.5.0713*/714typedef enum { /*< flags >*/715HB_BUFFER_DIFF_FLAG_EQUAL = 0x0000,716717/* Buffers with different content_type cannot be meaningfully compared718* in any further detail. */719HB_BUFFER_DIFF_FLAG_CONTENT_TYPE_MISMATCH = 0x0001,720721/* For buffers with differing length, the per-glyph comparison is not722* attempted, though we do still scan reference for dottedcircle / .notdef723* glyphs. */724HB_BUFFER_DIFF_FLAG_LENGTH_MISMATCH = 0x0002,725726/* We want to know if dottedcircle / .notdef glyphs are present in the727* reference, as we may not care so much about other differences in this728* case. */729HB_BUFFER_DIFF_FLAG_NOTDEF_PRESENT = 0x0004,730HB_BUFFER_DIFF_FLAG_DOTTED_CIRCLE_PRESENT = 0x0008,731732/* If the buffers have the same length, we compare them glyph-by-glyph733* and report which aspect(s) of the glyph info/position are different. */734HB_BUFFER_DIFF_FLAG_CODEPOINT_MISMATCH = 0x0010,735HB_BUFFER_DIFF_FLAG_CLUSTER_MISMATCH = 0x0020,736HB_BUFFER_DIFF_FLAG_GLYPH_FLAGS_MISMATCH = 0x0040,737HB_BUFFER_DIFF_FLAG_POSITION_MISMATCH = 0x0080738739} hb_buffer_diff_flags_t;740741/* Compare the contents of two buffers, report types of differences. */742HB_EXTERN hb_buffer_diff_flags_t743hb_buffer_diff (hb_buffer_t *buffer,744hb_buffer_t *reference,745hb_codepoint_t dottedcircle_glyph,746unsigned int position_fuzz);747748749/*750* Debugging.751*/752753/**754* hb_buffer_message_func_t:755* @buffer: An #hb_buffer_t to work upon756* @font: The #hb_font_t the @buffer is shaped with757* @message: %NULL-terminated message passed to the function758* @user_data: User data pointer passed by the caller759*760* A callback method for #hb_buffer_t. The method gets called with the761* #hb_buffer_t it was set on, the #hb_font_t the buffer is shaped with and a762* message describing what step of the shaping process will be performed.763* Returning %false from this method will skip this shaping step and move to764* the next one.765*766* Return value: %true to perform the shaping step, %false to skip it.767*768* Since: 1.1.3769*/770typedef hb_bool_t (*hb_buffer_message_func_t) (hb_buffer_t *buffer,771hb_font_t *font,772const char *message,773void *user_data);774775HB_EXTERN void776hb_buffer_set_message_func (hb_buffer_t *buffer,777hb_buffer_message_func_t func,778void *user_data, hb_destroy_func_t destroy);779780781HB_END_DECLS782783#endif /* HB_BUFFER_H */784785786