Path: blob/master/thirdparty/harfbuzz/src/hb-buffer.h
9902 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 position 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_SAFE_TO_INSERT_TATWEEL: In scripts that use elongation (Arabic,145Mongolian, Syriac, etc.), this flag signifies146that it is safe to insert a U+0640 TATWEEL147character before this cluster for elongation.148This flag does not determine the149script-specific elongation places, but only150when it is safe to do the elongation without151interrupting text shaping.152Since: 5.1.0153* @HB_GLYPH_FLAG_DEFINED: All the currently defined flags.154*155* Flags for #hb_glyph_info_t.156*157* Since: 1.5.0158*/159typedef enum { /*< flags >*/160HB_GLYPH_FLAG_UNSAFE_TO_BREAK = 0x00000001,161HB_GLYPH_FLAG_UNSAFE_TO_CONCAT = 0x00000002,162HB_GLYPH_FLAG_SAFE_TO_INSERT_TATWEEL = 0x00000004,163164HB_GLYPH_FLAG_DEFINED = 0x00000007 /* OR of all defined flags */165} hb_glyph_flags_t;166167HB_EXTERN hb_glyph_flags_t168hb_glyph_info_get_glyph_flags (const hb_glyph_info_t *info);169170#define hb_glyph_info_get_glyph_flags(info) \171((hb_glyph_flags_t) ((unsigned int) (info)->mask & HB_GLYPH_FLAG_DEFINED))172173174/**175* hb_glyph_position_t:176* @x_advance: how much the line advances after drawing this glyph when setting177* text in horizontal direction.178* @y_advance: how much the line advances after drawing this glyph when setting179* text in vertical direction.180* @x_offset: how much the glyph moves on the X-axis before drawing it, this181* should not affect how much the line advances.182* @y_offset: how much the glyph moves on the Y-axis before drawing it, this183* should not affect how much the line advances.184*185* The #hb_glyph_position_t is the structure that holds the positions of the186* glyph in both horizontal and vertical directions. All positions in187* #hb_glyph_position_t are relative to the current point.188*189*/190typedef struct hb_glyph_position_t {191hb_position_t x_advance;192hb_position_t y_advance;193hb_position_t x_offset;194hb_position_t y_offset;195196/*< private >*/197hb_var_int_t var;198} hb_glyph_position_t;199200/**201* hb_segment_properties_t:202* @direction: the #hb_direction_t of the buffer, see hb_buffer_set_direction().203* @script: the #hb_script_t of the buffer, see hb_buffer_set_script().204* @language: the #hb_language_t of the buffer, see hb_buffer_set_language().205*206* The structure that holds various text properties of an #hb_buffer_t. Can be207* set and retrieved using hb_buffer_set_segment_properties() and208* hb_buffer_get_segment_properties(), respectively.209*/210typedef struct hb_segment_properties_t {211hb_direction_t direction;212hb_script_t script;213hb_language_t language;214/*< private >*/215void *reserved1;216void *reserved2;217} hb_segment_properties_t;218219/**220* HB_SEGMENT_PROPERTIES_DEFAULT:221*222* The default #hb_segment_properties_t of of freshly created #hb_buffer_t.223*/224#define HB_SEGMENT_PROPERTIES_DEFAULT {HB_DIRECTION_INVALID, \225HB_SCRIPT_INVALID, \226HB_LANGUAGE_INVALID, \227(void *) 0, \228(void *) 0}229230HB_EXTERN hb_bool_t231hb_segment_properties_equal (const hb_segment_properties_t *a,232const hb_segment_properties_t *b);233234HB_EXTERN unsigned int235hb_segment_properties_hash (const hb_segment_properties_t *p);236237HB_EXTERN void238hb_segment_properties_overlay (hb_segment_properties_t *p,239const hb_segment_properties_t *src);240241242/**243* hb_buffer_t:244*245* The main structure holding the input text and its properties before shaping,246* and output glyphs and their information after shaping.247*/248249typedef struct hb_buffer_t hb_buffer_t;250251HB_EXTERN hb_buffer_t *252hb_buffer_create (void);253254HB_EXTERN hb_buffer_t *255hb_buffer_create_similar (const hb_buffer_t *src);256257HB_EXTERN void258hb_buffer_reset (hb_buffer_t *buffer);259260261HB_EXTERN hb_buffer_t *262hb_buffer_get_empty (void);263264HB_EXTERN hb_buffer_t *265hb_buffer_reference (hb_buffer_t *buffer);266267HB_EXTERN void268hb_buffer_destroy (hb_buffer_t *buffer);269270HB_EXTERN hb_bool_t271hb_buffer_set_user_data (hb_buffer_t *buffer,272hb_user_data_key_t *key,273void * data,274hb_destroy_func_t destroy,275hb_bool_t replace);276277HB_EXTERN void *278hb_buffer_get_user_data (const hb_buffer_t *buffer,279hb_user_data_key_t *key);280281282/**283* hb_buffer_content_type_t:284* @HB_BUFFER_CONTENT_TYPE_INVALID: Initial value for new buffer.285* @HB_BUFFER_CONTENT_TYPE_UNICODE: The buffer contains input characters (before shaping).286* @HB_BUFFER_CONTENT_TYPE_GLYPHS: The buffer contains output glyphs (after shaping).287*288* The type of #hb_buffer_t contents.289*/290typedef enum {291HB_BUFFER_CONTENT_TYPE_INVALID = 0,292HB_BUFFER_CONTENT_TYPE_UNICODE,293HB_BUFFER_CONTENT_TYPE_GLYPHS294} hb_buffer_content_type_t;295296HB_EXTERN void297hb_buffer_set_content_type (hb_buffer_t *buffer,298hb_buffer_content_type_t content_type);299300HB_EXTERN hb_buffer_content_type_t301hb_buffer_get_content_type (const hb_buffer_t *buffer);302303304HB_EXTERN void305hb_buffer_set_unicode_funcs (hb_buffer_t *buffer,306hb_unicode_funcs_t *unicode_funcs);307308HB_EXTERN hb_unicode_funcs_t *309hb_buffer_get_unicode_funcs (const hb_buffer_t *buffer);310311HB_EXTERN void312hb_buffer_set_direction (hb_buffer_t *buffer,313hb_direction_t direction);314315HB_EXTERN hb_direction_t316hb_buffer_get_direction (const hb_buffer_t *buffer);317318HB_EXTERN void319hb_buffer_set_script (hb_buffer_t *buffer,320hb_script_t script);321322HB_EXTERN hb_script_t323hb_buffer_get_script (const hb_buffer_t *buffer);324325HB_EXTERN void326hb_buffer_set_language (hb_buffer_t *buffer,327hb_language_t language);328329330HB_EXTERN hb_language_t331hb_buffer_get_language (const hb_buffer_t *buffer);332333HB_EXTERN void334hb_buffer_set_segment_properties (hb_buffer_t *buffer,335const hb_segment_properties_t *props);336337HB_EXTERN void338hb_buffer_get_segment_properties (const hb_buffer_t *buffer,339hb_segment_properties_t *props);340341HB_EXTERN void342hb_buffer_guess_segment_properties (hb_buffer_t *buffer);343344345/**346* hb_buffer_flags_t:347* @HB_BUFFER_FLAG_DEFAULT: the default buffer flag.348* @HB_BUFFER_FLAG_BOT: flag indicating that special handling of the beginning349* of text paragraph can be applied to this buffer. Should usually350* be set, unless you are passing to the buffer only part351* of the text without the full context.352* @HB_BUFFER_FLAG_EOT: flag indicating that special handling of the end of text353* paragraph can be applied to this buffer, similar to354* @HB_BUFFER_FLAG_BOT.355* @HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES:356* flag indication that character with Default_Ignorable357* Unicode property should use the corresponding glyph358* from the font, instead of hiding them (done by359* replacing them with the space glyph and zeroing the360* advance width.) This flag takes precedence over361* @HB_BUFFER_FLAG_REMOVE_DEFAULT_IGNORABLES.362* @HB_BUFFER_FLAG_REMOVE_DEFAULT_IGNORABLES:363* flag indication that character with Default_Ignorable364* Unicode property should be removed from glyph string365* instead of hiding them (done by replacing them with the366* space glyph and zeroing the advance width.)367* @HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES takes368* precedence over this flag. Since: 1.8.0369* @HB_BUFFER_FLAG_DO_NOT_INSERT_DOTTED_CIRCLE:370* flag indicating that a dotted circle should371* not be inserted in the rendering of incorrect372* character sequences (such at <0905 093E>). Since: 2.4.0373* @HB_BUFFER_FLAG_VERIFY:374* flag indicating that the hb_shape() call and its variants375* should perform various verification processes on the results376* of the shaping operation on the buffer. If the verification377* fails, then either a buffer message is sent, if a message378* handler is installed on the buffer, or a message is written379* to standard error. In either case, the shaping result might380* be modified to show the failed output. Since: 3.4.0381* @HB_BUFFER_FLAG_PRODUCE_UNSAFE_TO_CONCAT:382* flag indicating that the @HB_GLYPH_FLAG_UNSAFE_TO_CONCAT383* glyph-flag should be produced by the shaper. By default384* it will not be produced since it incurs a cost. Since: 4.0.0385* @HB_BUFFER_FLAG_PRODUCE_SAFE_TO_INSERT_TATWEEL:386* flag indicating that the @HB_GLYPH_FLAG_SAFE_TO_INSERT_TATWEEL387* glyph-flag should be produced by the shaper. By default388* it will not be produced. Since: 5.1.0389* @HB_BUFFER_FLAG_DEFINED: All currently defined flags: Since: 4.4.0390*391* Flags for #hb_buffer_t.392*393* Since: 0.9.20394*/395typedef enum { /*< flags >*/396HB_BUFFER_FLAG_DEFAULT = 0x00000000u,397HB_BUFFER_FLAG_BOT = 0x00000001u, /* Beginning-of-text */398HB_BUFFER_FLAG_EOT = 0x00000002u, /* End-of-text */399HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES = 0x00000004u,400HB_BUFFER_FLAG_REMOVE_DEFAULT_IGNORABLES = 0x00000008u,401HB_BUFFER_FLAG_DO_NOT_INSERT_DOTTED_CIRCLE = 0x00000010u,402HB_BUFFER_FLAG_VERIFY = 0x00000020u,403HB_BUFFER_FLAG_PRODUCE_UNSAFE_TO_CONCAT = 0x00000040u,404HB_BUFFER_FLAG_PRODUCE_SAFE_TO_INSERT_TATWEEL = 0x00000080u,405406HB_BUFFER_FLAG_DEFINED = 0x000000FFu407} hb_buffer_flags_t;408409HB_EXTERN void410hb_buffer_set_flags (hb_buffer_t *buffer,411hb_buffer_flags_t flags);412413HB_EXTERN hb_buffer_flags_t414hb_buffer_get_flags (const hb_buffer_t *buffer);415416/**417* hb_buffer_cluster_level_t:418* @HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES: Return cluster values grouped by graphemes into419* monotone order.420* @HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS: Return cluster values grouped into monotone order.421* @HB_BUFFER_CLUSTER_LEVEL_CHARACTERS: Don't group cluster values.422* @HB_BUFFER_CLUSTER_LEVEL_DEFAULT: Default cluster level,423* equal to @HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES.424* @HB_BUFFER_CLUSTER_LEVEL_GRAPHEMES: Only group clusters, but don't enforce monotone order.425*426* Data type for holding HarfBuzz's clustering behavior options. The cluster level427* dictates one aspect of how HarfBuzz will treat non-base characters428* during shaping.429*430* In @HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES, non-base431* characters are merged into the cluster of the base character that precedes them.432* There is also cluster merging every time the clusters will otherwise become non-monotone.433*434* In @HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS, non-base characters are initially435* assigned their own cluster values, which are not merged into preceding base436* clusters. This allows HarfBuzz to perform additional operations like reorder437* sequences of adjacent marks. The output is still monotone, but the cluster438* values are more granular.439*440* In @HB_BUFFER_CLUSTER_LEVEL_CHARACTERS, non-base characters are assigned their441* own cluster values, which are not merged into preceding base clusters. Moreover,442* the cluster values are not merged into monotone order. This is the most granular443* cluster level, and it is useful for clients that need to know the exact cluster444* values of each character, but is harder to use for clients, since clusters445* might appear in any order.446*447* In @HB_BUFFER_CLUSTER_LEVEL_GRAPHEMES, non-base characters are merged into the448* cluster of the base character that precedes them. This is similar to the Unicode449* Grapheme Cluster algorithm, but it is not exactly the same. The output is450* not forced to be monotone. This is useful for clients that want to use HarfBuzz451* as a cheap implementation of the Unicode Grapheme Cluster algorithm.452*453* @HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES is the default, because it maintains454* backward compatibility with older versions of HarfBuzz. New client programs that455* do not need to maintain such backward compatibility are recommended to use456* @HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS instead of the default.457*458* Since: 0.9.42459*/460typedef enum {461HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES = 0,462HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS = 1,463HB_BUFFER_CLUSTER_LEVEL_CHARACTERS = 2,464HB_BUFFER_CLUSTER_LEVEL_GRAPHEMES = 3,465HB_BUFFER_CLUSTER_LEVEL_DEFAULT = HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES466} hb_buffer_cluster_level_t;467468/**469* HB_BUFFER_CLUSTER_LEVEL_IS_MONOTONE:470* @level: #hb_buffer_cluster_level_t to test471*472* Tests whether a cluster level groups cluster values into monotone order.473* Requires that the level be valid.474*475* Since: 11.0.0476*/477#define HB_BUFFER_CLUSTER_LEVEL_IS_MONOTONE(level) \478((bool) ((1u << (unsigned) (level)) & \479((1u << HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES) | \480(1u << HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS))))481482/**483* HB_BUFFER_CLUSTER_LEVEL_IS_GRAPHEMES:484* @level: #hb_buffer_cluster_level_t to test485*486* Tests whether a cluster level groups cluster values by graphemes. Requires487* that the level be valid.488*489* Since: 11.0.0490*/491#define HB_BUFFER_CLUSTER_LEVEL_IS_GRAPHEMES(level) \492((bool) ((1u << (unsigned) (level)) & \493((1u << HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES) | \494(1u << HB_BUFFER_CLUSTER_LEVEL_GRAPHEMES))))495496/**497* HB_BUFFER_CLUSTER_LEVEL_IS_CHARACTERS498* @level: #hb_buffer_cluster_level_t to test499*500* Tests whether a cluster level does not group cluster values by graphemes.501* Requires that the level be valid.502*503* Since: 11.0.0504*/505#define HB_BUFFER_CLUSTER_LEVEL_IS_CHARACTERS(level) \506((bool) ((1u << (unsigned) (level)) & \507((1u << HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARCATERS) | \508(1u << HB_BUFFER_CLUSTER_LEVEL_CHARACTERS))))509510HB_EXTERN void511hb_buffer_set_cluster_level (hb_buffer_t *buffer,512hb_buffer_cluster_level_t cluster_level);513514HB_EXTERN hb_buffer_cluster_level_t515hb_buffer_get_cluster_level (const hb_buffer_t *buffer);516517/**518* HB_BUFFER_REPLACEMENT_CODEPOINT_DEFAULT:519*520* The default code point for replacing invalid characters in a given encoding.521* Set to U+FFFD REPLACEMENT CHARACTER.522*523* Since: 0.9.31524*/525#define HB_BUFFER_REPLACEMENT_CODEPOINT_DEFAULT 0xFFFDu526527HB_EXTERN void528hb_buffer_set_replacement_codepoint (hb_buffer_t *buffer,529hb_codepoint_t replacement);530531HB_EXTERN hb_codepoint_t532hb_buffer_get_replacement_codepoint (const hb_buffer_t *buffer);533534HB_EXTERN void535hb_buffer_set_invisible_glyph (hb_buffer_t *buffer,536hb_codepoint_t invisible);537538HB_EXTERN hb_codepoint_t539hb_buffer_get_invisible_glyph (const hb_buffer_t *buffer);540541HB_EXTERN void542hb_buffer_set_not_found_glyph (hb_buffer_t *buffer,543hb_codepoint_t not_found);544545HB_EXTERN hb_codepoint_t546hb_buffer_get_not_found_glyph (const hb_buffer_t *buffer);547548HB_EXTERN void549hb_buffer_set_not_found_variation_selector_glyph (hb_buffer_t *buffer,550hb_codepoint_t not_found_variation_selector);551552HB_EXTERN hb_codepoint_t553hb_buffer_get_not_found_variation_selector_glyph (const hb_buffer_t *buffer);554555HB_EXTERN void556hb_buffer_set_random_state (hb_buffer_t *buffer,557unsigned state);558559HB_EXTERN unsigned560hb_buffer_get_random_state (const hb_buffer_t *buffer);561562/*563* Content API.564*/565566HB_EXTERN void567hb_buffer_clear_contents (hb_buffer_t *buffer);568569HB_EXTERN hb_bool_t570hb_buffer_pre_allocate (hb_buffer_t *buffer,571unsigned int size);572573574HB_EXTERN hb_bool_t575hb_buffer_allocation_successful (hb_buffer_t *buffer);576577HB_EXTERN void578hb_buffer_reverse (hb_buffer_t *buffer);579580HB_EXTERN void581hb_buffer_reverse_range (hb_buffer_t *buffer,582unsigned int start, unsigned int end);583584HB_EXTERN void585hb_buffer_reverse_clusters (hb_buffer_t *buffer);586587588/* Filling the buffer in */589590HB_EXTERN void591hb_buffer_add (hb_buffer_t *buffer,592hb_codepoint_t codepoint,593unsigned int cluster);594595HB_EXTERN void596hb_buffer_add_utf8 (hb_buffer_t *buffer,597const char *text,598int text_length,599unsigned int item_offset,600int item_length);601602HB_EXTERN void603hb_buffer_add_utf16 (hb_buffer_t *buffer,604const uint16_t *text,605int text_length,606unsigned int item_offset,607int item_length);608609HB_EXTERN void610hb_buffer_add_utf32 (hb_buffer_t *buffer,611const uint32_t *text,612int text_length,613unsigned int item_offset,614int item_length);615616HB_EXTERN void617hb_buffer_add_latin1 (hb_buffer_t *buffer,618const uint8_t *text,619int text_length,620unsigned int item_offset,621int item_length);622623HB_EXTERN void624hb_buffer_add_codepoints (hb_buffer_t *buffer,625const hb_codepoint_t *text,626int text_length,627unsigned int item_offset,628int item_length);629630HB_EXTERN void631hb_buffer_append (hb_buffer_t *buffer,632const hb_buffer_t *source,633unsigned int start,634unsigned int end);635636HB_EXTERN hb_bool_t637hb_buffer_set_length (hb_buffer_t *buffer,638unsigned int length);639640HB_EXTERN unsigned int641hb_buffer_get_length (const hb_buffer_t *buffer);642643/* Getting glyphs out of the buffer */644645HB_EXTERN hb_glyph_info_t *646hb_buffer_get_glyph_infos (hb_buffer_t *buffer,647unsigned int *length);648649HB_EXTERN hb_glyph_position_t *650hb_buffer_get_glyph_positions (hb_buffer_t *buffer,651unsigned int *length);652653HB_EXTERN hb_bool_t654hb_buffer_has_positions (hb_buffer_t *buffer);655656657HB_EXTERN void658hb_buffer_normalize_glyphs (hb_buffer_t *buffer);659660661/*662* Serialize663*/664665/**666* hb_buffer_serialize_flags_t:667* @HB_BUFFER_SERIALIZE_FLAG_DEFAULT: serialize glyph names, clusters and positions.668* @HB_BUFFER_SERIALIZE_FLAG_NO_CLUSTERS: do not serialize glyph cluster.669* @HB_BUFFER_SERIALIZE_FLAG_NO_POSITIONS: do not serialize glyph position information.670* @HB_BUFFER_SERIALIZE_FLAG_NO_GLYPH_NAMES: do no serialize glyph name.671* @HB_BUFFER_SERIALIZE_FLAG_GLYPH_EXTENTS: serialize glyph extents.672* @HB_BUFFER_SERIALIZE_FLAG_GLYPH_FLAGS: serialize glyph flags. Since: 1.5.0673* @HB_BUFFER_SERIALIZE_FLAG_NO_ADVANCES: do not serialize glyph advances,674* glyph offsets will reflect absolute glyph positions. Since: 1.8.0675* @HB_BUFFER_SERIALIZE_FLAG_DEFINED: All currently defined flags. Since: 4.4.0676*677* Flags that control what glyph information are serialized in hb_buffer_serialize_glyphs().678*679* Since: 0.9.20680*/681typedef enum { /*< flags >*/682HB_BUFFER_SERIALIZE_FLAG_DEFAULT = 0x00000000u,683HB_BUFFER_SERIALIZE_FLAG_NO_CLUSTERS = 0x00000001u,684HB_BUFFER_SERIALIZE_FLAG_NO_POSITIONS = 0x00000002u,685HB_BUFFER_SERIALIZE_FLAG_NO_GLYPH_NAMES = 0x00000004u,686HB_BUFFER_SERIALIZE_FLAG_GLYPH_EXTENTS = 0x00000008u,687HB_BUFFER_SERIALIZE_FLAG_GLYPH_FLAGS = 0x00000010u,688HB_BUFFER_SERIALIZE_FLAG_NO_ADVANCES = 0x00000020u,689690HB_BUFFER_SERIALIZE_FLAG_DEFINED = 0x0000003Fu691} hb_buffer_serialize_flags_t;692693/**694* hb_buffer_serialize_format_t:695* @HB_BUFFER_SERIALIZE_FORMAT_TEXT: a human-readable, plain text format.696* @HB_BUFFER_SERIALIZE_FORMAT_JSON: a machine-readable JSON format.697* @HB_BUFFER_SERIALIZE_FORMAT_INVALID: invalid format.698*699* The buffer serialization and de-serialization format used in700* hb_buffer_serialize_glyphs() and hb_buffer_deserialize_glyphs().701*702* Since: 0.9.2703*/704typedef enum {705HB_BUFFER_SERIALIZE_FORMAT_TEXT = HB_TAG('T','E','X','T'),706HB_BUFFER_SERIALIZE_FORMAT_JSON = HB_TAG('J','S','O','N'),707HB_BUFFER_SERIALIZE_FORMAT_INVALID = HB_TAG_NONE708} hb_buffer_serialize_format_t;709710HB_EXTERN hb_buffer_serialize_format_t711hb_buffer_serialize_format_from_string (const char *str, int len);712713HB_EXTERN const char *714hb_buffer_serialize_format_to_string (hb_buffer_serialize_format_t format);715716HB_EXTERN const char **717hb_buffer_serialize_list_formats (void);718719HB_EXTERN unsigned int720hb_buffer_serialize_glyphs (hb_buffer_t *buffer,721unsigned int start,722unsigned int end,723char *buf,724unsigned int buf_size,725unsigned int *buf_consumed,726hb_font_t *font,727hb_buffer_serialize_format_t format,728hb_buffer_serialize_flags_t flags);729730HB_EXTERN unsigned int731hb_buffer_serialize_unicode (hb_buffer_t *buffer,732unsigned int start,733unsigned int end,734char *buf,735unsigned int buf_size,736unsigned int *buf_consumed,737hb_buffer_serialize_format_t format,738hb_buffer_serialize_flags_t flags);739740HB_EXTERN unsigned int741hb_buffer_serialize (hb_buffer_t *buffer,742unsigned int start,743unsigned int end,744char *buf,745unsigned int buf_size,746unsigned int *buf_consumed,747hb_font_t *font,748hb_buffer_serialize_format_t format,749hb_buffer_serialize_flags_t flags);750751HB_EXTERN hb_bool_t752hb_buffer_deserialize_glyphs (hb_buffer_t *buffer,753const char *buf,754int buf_len,755const char **end_ptr,756hb_font_t *font,757hb_buffer_serialize_format_t format);758759HB_EXTERN hb_bool_t760hb_buffer_deserialize_unicode (hb_buffer_t *buffer,761const char *buf,762int buf_len,763const char **end_ptr,764hb_buffer_serialize_format_t format);765766767768/*769* Compare buffers770*/771772/**773* hb_buffer_diff_flags_t:774* @HB_BUFFER_DIFF_FLAG_EQUAL: equal buffers.775* @HB_BUFFER_DIFF_FLAG_CONTENT_TYPE_MISMATCH: buffers with different776* #hb_buffer_content_type_t.777* @HB_BUFFER_DIFF_FLAG_LENGTH_MISMATCH: buffers with differing length.778* @HB_BUFFER_DIFF_FLAG_NOTDEF_PRESENT: `.notdef` glyph is present in the779* reference buffer.780* @HB_BUFFER_DIFF_FLAG_DOTTED_CIRCLE_PRESENT: dotted circle glyph is present781* in the reference buffer.782* @HB_BUFFER_DIFF_FLAG_CODEPOINT_MISMATCH: difference in #hb_glyph_info_t.codepoint783* @HB_BUFFER_DIFF_FLAG_CLUSTER_MISMATCH: difference in #hb_glyph_info_t.cluster784* @HB_BUFFER_DIFF_FLAG_GLYPH_FLAGS_MISMATCH: difference in #hb_glyph_flags_t.785* @HB_BUFFER_DIFF_FLAG_POSITION_MISMATCH: difference in #hb_glyph_position_t.786*787* Flags from comparing two #hb_buffer_t's.788*789* Buffer with different #hb_buffer_content_type_t cannot be meaningfully790* compared in any further detail.791*792* For buffers with differing length, the per-glyph comparison is not793* attempted, though we do still scan reference buffer for dotted circle and794* `.notdef` glyphs.795*796* If the buffers have the same length, we compare them glyph-by-glyph and797* report which aspect(s) of the glyph info/position are different.798*799* Since: 1.5.0800*/801typedef enum { /*< flags >*/802HB_BUFFER_DIFF_FLAG_EQUAL = 0x0000,803804/* Buffers with different content_type cannot be meaningfully compared805* in any further detail. */806HB_BUFFER_DIFF_FLAG_CONTENT_TYPE_MISMATCH = 0x0001,807808/* For buffers with differing length, the per-glyph comparison is not809* attempted, though we do still scan reference for dottedcircle / .notdef810* glyphs. */811HB_BUFFER_DIFF_FLAG_LENGTH_MISMATCH = 0x0002,812813/* We want to know if dottedcircle / .notdef glyphs are present in the814* reference, as we may not care so much about other differences in this815* case. */816HB_BUFFER_DIFF_FLAG_NOTDEF_PRESENT = 0x0004,817HB_BUFFER_DIFF_FLAG_DOTTED_CIRCLE_PRESENT = 0x0008,818819/* If the buffers have the same length, we compare them glyph-by-glyph820* and report which aspect(s) of the glyph info/position are different. */821HB_BUFFER_DIFF_FLAG_CODEPOINT_MISMATCH = 0x0010,822HB_BUFFER_DIFF_FLAG_CLUSTER_MISMATCH = 0x0020,823HB_BUFFER_DIFF_FLAG_GLYPH_FLAGS_MISMATCH = 0x0040,824HB_BUFFER_DIFF_FLAG_POSITION_MISMATCH = 0x0080825826} hb_buffer_diff_flags_t;827828/* Compare the contents of two buffers, report types of differences. */829HB_EXTERN hb_buffer_diff_flags_t830hb_buffer_diff (hb_buffer_t *buffer,831hb_buffer_t *reference,832hb_codepoint_t dottedcircle_glyph,833unsigned int position_fuzz);834835836/*837* Tracing.838*/839840/**841* hb_buffer_message_func_t:842* @buffer: An #hb_buffer_t to work upon843* @font: The #hb_font_t the @buffer is shaped with844* @message: `NULL`-terminated message passed to the function845* @user_data: User data pointer passed by the caller846*847* A callback method for #hb_buffer_t. The method gets called with the848* #hb_buffer_t it was set on, the #hb_font_t the buffer is shaped with and a849* message describing what step of the shaping process will be performed.850* Returning `false` from this method will skip this shaping step and move to851* the next one.852*853* Return value: `true` to perform the shaping step, `false` to skip it.854*855* Since: 1.1.3856*/857typedef hb_bool_t (*hb_buffer_message_func_t) (hb_buffer_t *buffer,858hb_font_t *font,859const char *message,860void *user_data);861862HB_EXTERN void863hb_buffer_set_message_func (hb_buffer_t *buffer,864hb_buffer_message_func_t func,865void *user_data, hb_destroy_func_t destroy);866867868HB_END_DECLS869870#endif /* HB_BUFFER_H */871872873