hb-buffer.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586
  1. /*
  2. * Copyright © 1998-2004 David Turner and Werner Lemberg
  3. * Copyright © 2004,2007,2009 Red Hat, Inc.
  4. * Copyright © 2011,2012 Google, Inc.
  5. *
  6. * This is part of HarfBuzz, a text shaping library.
  7. *
  8. * Permission is hereby granted, without written agreement and without
  9. * license or royalty fees, to use, copy, modify, and distribute this
  10. * software and its documentation for any purpose, provided that the
  11. * above copyright notice and the following two paragraphs appear in
  12. * all copies of this software.
  13. *
  14. * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
  15. * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
  16. * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
  17. * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
  18. * DAMAGE.
  19. *
  20. * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
  21. * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  22. * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
  23. * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
  24. * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  25. *
  26. * Red Hat Author(s): Owen Taylor, Behdad Esfahbod
  27. * Google Author(s): Behdad Esfahbod
  28. */
  29. #ifndef HB_H_IN
  30. #error "Include <hb.h> instead."
  31. #endif
  32. #ifndef HB_BUFFER_H
  33. #define HB_BUFFER_H
  34. #include "hb-common.h"
  35. #include "hb-unicode.h"
  36. #include "hb-font.h"
  37. HB_BEGIN_DECLS
  38. /**
  39. * hb_glyph_info_t:
  40. * @codepoint: either a Unicode code point (before shaping) or a glyph index
  41. * (after shaping).
  42. * @cluster: the index of the character in the original text that corresponds
  43. * to this #hb_glyph_info_t, or whatever the client passes to
  44. * hb_buffer_add(). More than one #hb_glyph_info_t can have the same
  45. * @cluster value, if they resulted from the same character (e.g. one
  46. * to many glyph substitution), and when more than one character gets
  47. * merged in the same glyph (e.g. many to one glyph substitution) the
  48. * #hb_glyph_info_t will have the smallest cluster value of them.
  49. * By default some characters are merged into the same cluster
  50. * (e.g. combining marks have the same cluster as their bases)
  51. * even if they are separate glyphs, hb_buffer_set_cluster_level()
  52. * allow selecting more fine-grained cluster handling.
  53. *
  54. * The #hb_glyph_info_t is the structure that holds information about the
  55. * glyphs and their relation to input text.
  56. */
  57. typedef struct hb_glyph_info_t
  58. {
  59. hb_codepoint_t codepoint;
  60. /*< private >*/
  61. hb_mask_t mask;
  62. /*< public >*/
  63. uint32_t cluster;
  64. /*< private >*/
  65. hb_var_int_t var1;
  66. hb_var_int_t var2;
  67. } hb_glyph_info_t;
  68. /**
  69. * hb_glyph_flags_t:
  70. * @HB_GLYPH_FLAG_UNSAFE_TO_BREAK: Indicates that if input text is broken at the
  71. * beginning of the cluster this glyph is part of,
  72. * then both sides need to be re-shaped, as the
  73. * result might be different. On the flip side,
  74. * it means that when this flag is not present,
  75. * then it's safe to break the glyph-run at the
  76. * beginning of this cluster, and the two sides
  77. * represent the exact same result one would get
  78. * if breaking input text at the beginning of
  79. * this cluster and shaping the two sides
  80. * separately. This can be used to optimize
  81. * paragraph layout, by avoiding re-shaping
  82. * of each line after line-breaking, or limiting
  83. * the reshaping to a small piece around the
  84. * breaking point only.
  85. * @HB_GLYPH_FLAG_DEFINED: All the currently defined flags.
  86. *
  87. * Since: 1.5.0
  88. */
  89. typedef enum { /*< flags >*/
  90. HB_GLYPH_FLAG_UNSAFE_TO_BREAK = 0x00000001,
  91. HB_GLYPH_FLAG_DEFINED = 0x00000001 /* OR of all defined flags */
  92. } hb_glyph_flags_t;
  93. HB_EXTERN hb_glyph_flags_t
  94. hb_glyph_info_get_glyph_flags (const hb_glyph_info_t *info);
  95. #define hb_glyph_info_get_glyph_flags(info) \
  96. ((hb_glyph_flags_t) ((unsigned int) (info)->mask & HB_GLYPH_FLAG_DEFINED))
  97. /**
  98. * hb_glyph_position_t:
  99. * @x_advance: how much the line advances after drawing this glyph when setting
  100. * text in horizontal direction.
  101. * @y_advance: how much the line advances after drawing this glyph when setting
  102. * text in vertical direction.
  103. * @x_offset: how much the glyph moves on the X-axis before drawing it, this
  104. * should not affect how much the line advances.
  105. * @y_offset: how much the glyph moves on the Y-axis before drawing it, this
  106. * should not affect how much the line advances.
  107. *
  108. * The #hb_glyph_position_t is the structure that holds the positions of the
  109. * glyph in both horizontal and vertical directions. All positions in
  110. * #hb_glyph_position_t are relative to the current point.
  111. *
  112. */
  113. typedef struct hb_glyph_position_t {
  114. hb_position_t x_advance;
  115. hb_position_t y_advance;
  116. hb_position_t x_offset;
  117. hb_position_t y_offset;
  118. /*< private >*/
  119. hb_var_int_t var;
  120. } hb_glyph_position_t;
  121. /**
  122. * hb_segment_properties_t:
  123. * @direction: the #hb_direction_t of the buffer, see hb_buffer_set_direction().
  124. * @script: the #hb_script_t of the buffer, see hb_buffer_set_script().
  125. * @language: the #hb_language_t of the buffer, see hb_buffer_set_language().
  126. *
  127. * The structure that holds various text properties of an #hb_buffer_t. Can be
  128. * set and retrieved using hb_buffer_set_segment_properties() and
  129. * hb_buffer_get_segment_properties(), respectively.
  130. */
  131. typedef struct hb_segment_properties_t {
  132. hb_direction_t direction;
  133. hb_script_t script;
  134. hb_language_t language;
  135. /*< private >*/
  136. void *reserved1;
  137. void *reserved2;
  138. } hb_segment_properties_t;
  139. #define HB_SEGMENT_PROPERTIES_DEFAULT {HB_DIRECTION_INVALID, \
  140. HB_SCRIPT_INVALID, \
  141. HB_LANGUAGE_INVALID, \
  142. (void *) 0, \
  143. (void *) 0}
  144. HB_EXTERN hb_bool_t
  145. hb_segment_properties_equal (const hb_segment_properties_t *a,
  146. const hb_segment_properties_t *b);
  147. HB_EXTERN unsigned int
  148. hb_segment_properties_hash (const hb_segment_properties_t *p);
  149. /**
  150. * hb_buffer_t:
  151. *
  152. * The main structure holding the input text and its properties before shaping,
  153. * and output glyphs and their information after shaping.
  154. */
  155. typedef struct hb_buffer_t hb_buffer_t;
  156. HB_EXTERN hb_buffer_t *
  157. hb_buffer_create (void);
  158. HB_EXTERN hb_buffer_t *
  159. hb_buffer_get_empty (void);
  160. HB_EXTERN hb_buffer_t *
  161. hb_buffer_reference (hb_buffer_t *buffer);
  162. HB_EXTERN void
  163. hb_buffer_destroy (hb_buffer_t *buffer);
  164. HB_EXTERN hb_bool_t
  165. hb_buffer_set_user_data (hb_buffer_t *buffer,
  166. hb_user_data_key_t *key,
  167. void * data,
  168. hb_destroy_func_t destroy,
  169. hb_bool_t replace);
  170. HB_EXTERN void *
  171. hb_buffer_get_user_data (hb_buffer_t *buffer,
  172. hb_user_data_key_t *key);
  173. /**
  174. * hb_buffer_content_type_t:
  175. * @HB_BUFFER_CONTENT_TYPE_INVALID: Initial value for new buffer.
  176. * @HB_BUFFER_CONTENT_TYPE_UNICODE: The buffer contains input characters (before shaping).
  177. * @HB_BUFFER_CONTENT_TYPE_GLYPHS: The buffer contains output glyphs (after shaping).
  178. */
  179. typedef enum {
  180. HB_BUFFER_CONTENT_TYPE_INVALID = 0,
  181. HB_BUFFER_CONTENT_TYPE_UNICODE,
  182. HB_BUFFER_CONTENT_TYPE_GLYPHS
  183. } hb_buffer_content_type_t;
  184. HB_EXTERN void
  185. hb_buffer_set_content_type (hb_buffer_t *buffer,
  186. hb_buffer_content_type_t content_type);
  187. HB_EXTERN hb_buffer_content_type_t
  188. hb_buffer_get_content_type (hb_buffer_t *buffer);
  189. HB_EXTERN void
  190. hb_buffer_set_unicode_funcs (hb_buffer_t *buffer,
  191. hb_unicode_funcs_t *unicode_funcs);
  192. HB_EXTERN hb_unicode_funcs_t *
  193. hb_buffer_get_unicode_funcs (hb_buffer_t *buffer);
  194. HB_EXTERN void
  195. hb_buffer_set_direction (hb_buffer_t *buffer,
  196. hb_direction_t direction);
  197. HB_EXTERN hb_direction_t
  198. hb_buffer_get_direction (hb_buffer_t *buffer);
  199. HB_EXTERN void
  200. hb_buffer_set_script (hb_buffer_t *buffer,
  201. hb_script_t script);
  202. HB_EXTERN hb_script_t
  203. hb_buffer_get_script (hb_buffer_t *buffer);
  204. HB_EXTERN void
  205. hb_buffer_set_language (hb_buffer_t *buffer,
  206. hb_language_t language);
  207. HB_EXTERN hb_language_t
  208. hb_buffer_get_language (hb_buffer_t *buffer);
  209. HB_EXTERN void
  210. hb_buffer_set_segment_properties (hb_buffer_t *buffer,
  211. const hb_segment_properties_t *props);
  212. HB_EXTERN void
  213. hb_buffer_get_segment_properties (hb_buffer_t *buffer,
  214. hb_segment_properties_t *props);
  215. HB_EXTERN void
  216. hb_buffer_guess_segment_properties (hb_buffer_t *buffer);
  217. /**
  218. * hb_buffer_flags_t:
  219. * @HB_BUFFER_FLAG_DEFAULT: the default buffer flag.
  220. * @HB_BUFFER_FLAG_BOT: flag indicating that special handling of the beginning
  221. * of text paragraph can be applied to this buffer. Should usually
  222. * be set, unless you are passing to the buffer only part
  223. * of the text without the full context.
  224. * @HB_BUFFER_FLAG_EOT: flag indicating that special handling of the end of text
  225. * paragraph can be applied to this buffer, similar to
  226. * @HB_BUFFER_FLAG_BOT.
  227. * @HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES:
  228. * flag indication that character with Default_Ignorable
  229. * Unicode property should use the corresponding glyph
  230. * from the font, instead of hiding them (done by
  231. * replacing them with the space glyph and zeroing the
  232. * advance width.) This flag takes precedence over
  233. * @HB_BUFFER_FLAG_REMOVE_DEFAULT_IGNORABLES.
  234. * @HB_BUFFER_FLAG_REMOVE_DEFAULT_IGNORABLES:
  235. * flag indication that character with Default_Ignorable
  236. * Unicode property should be removed from glyph string
  237. * instead of hiding them (done by replacing them with the
  238. * space glyph and zeroing the advance width.)
  239. * @HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES takes
  240. * precedence over this flag. Since: 1.8.0
  241. * @HB_BUFFER_FLAG_DO_NOT_INSERT_DOTTED_CIRCLE:
  242. * flag indicating that a dotted circle should
  243. * not be inserted in the rendering of incorrect
  244. * character sequences (such at <0905 093E>). Since: 2.4
  245. *
  246. * Since: 0.9.20
  247. */
  248. typedef enum { /*< flags >*/
  249. HB_BUFFER_FLAG_DEFAULT = 0x00000000u,
  250. HB_BUFFER_FLAG_BOT = 0x00000001u, /* Beginning-of-text */
  251. HB_BUFFER_FLAG_EOT = 0x00000002u, /* End-of-text */
  252. HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES = 0x00000004u,
  253. HB_BUFFER_FLAG_REMOVE_DEFAULT_IGNORABLES = 0x00000008u,
  254. HB_BUFFER_FLAG_DO_NOT_INSERT_DOTTED_CIRCLE = 0x00000010u
  255. } hb_buffer_flags_t;
  256. HB_EXTERN void
  257. hb_buffer_set_flags (hb_buffer_t *buffer,
  258. hb_buffer_flags_t flags);
  259. HB_EXTERN hb_buffer_flags_t
  260. hb_buffer_get_flags (hb_buffer_t *buffer);
  261. /**
  262. * hb_buffer_cluster_level_t:
  263. * @HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES: Return cluster values grouped by graphemes into
  264. * monotone order.
  265. * @HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS: Return cluster values grouped into monotone order.
  266. * @HB_BUFFER_CLUSTER_LEVEL_CHARACTERS: Don't group cluster values.
  267. * @HB_BUFFER_CLUSTER_LEVEL_DEFAULT: Default cluster level,
  268. * equal to @HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES.
  269. *
  270. * Since: 0.9.42
  271. */
  272. typedef enum {
  273. HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES = 0,
  274. HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS = 1,
  275. HB_BUFFER_CLUSTER_LEVEL_CHARACTERS = 2,
  276. HB_BUFFER_CLUSTER_LEVEL_DEFAULT = HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES
  277. } hb_buffer_cluster_level_t;
  278. HB_EXTERN void
  279. hb_buffer_set_cluster_level (hb_buffer_t *buffer,
  280. hb_buffer_cluster_level_t cluster_level);
  281. HB_EXTERN hb_buffer_cluster_level_t
  282. hb_buffer_get_cluster_level (hb_buffer_t *buffer);
  283. /**
  284. * HB_BUFFER_REPLACEMENT_CODEPOINT_DEFAULT:
  285. *
  286. * The default code point for replacing invalid characters in a given encoding.
  287. * Set to U+FFFD REPLACEMENT CHARACTER.
  288. *
  289. * Since: 0.9.31
  290. */
  291. #define HB_BUFFER_REPLACEMENT_CODEPOINT_DEFAULT 0xFFFDu
  292. HB_EXTERN void
  293. hb_buffer_set_replacement_codepoint (hb_buffer_t *buffer,
  294. hb_codepoint_t replacement);
  295. HB_EXTERN hb_codepoint_t
  296. hb_buffer_get_replacement_codepoint (hb_buffer_t *buffer);
  297. HB_EXTERN void
  298. hb_buffer_set_invisible_glyph (hb_buffer_t *buffer,
  299. hb_codepoint_t invisible);
  300. HB_EXTERN hb_codepoint_t
  301. hb_buffer_get_invisible_glyph (hb_buffer_t *buffer);
  302. HB_EXTERN void
  303. hb_buffer_reset (hb_buffer_t *buffer);
  304. HB_EXTERN void
  305. hb_buffer_clear_contents (hb_buffer_t *buffer);
  306. HB_EXTERN hb_bool_t
  307. hb_buffer_pre_allocate (hb_buffer_t *buffer,
  308. unsigned int size);
  309. HB_EXTERN hb_bool_t
  310. hb_buffer_allocation_successful (hb_buffer_t *buffer);
  311. HB_EXTERN void
  312. hb_buffer_reverse (hb_buffer_t *buffer);
  313. HB_EXTERN void
  314. hb_buffer_reverse_range (hb_buffer_t *buffer,
  315. unsigned int start, unsigned int end);
  316. HB_EXTERN void
  317. hb_buffer_reverse_clusters (hb_buffer_t *buffer);
  318. /* Filling the buffer in */
  319. HB_EXTERN void
  320. hb_buffer_add (hb_buffer_t *buffer,
  321. hb_codepoint_t codepoint,
  322. unsigned int cluster);
  323. HB_EXTERN void
  324. hb_buffer_add_utf8 (hb_buffer_t *buffer,
  325. const char *text,
  326. int text_length,
  327. unsigned int item_offset,
  328. int item_length);
  329. HB_EXTERN void
  330. hb_buffer_add_utf16 (hb_buffer_t *buffer,
  331. const uint16_t *text,
  332. int text_length,
  333. unsigned int item_offset,
  334. int item_length);
  335. HB_EXTERN void
  336. hb_buffer_add_utf32 (hb_buffer_t *buffer,
  337. const uint32_t *text,
  338. int text_length,
  339. unsigned int item_offset,
  340. int item_length);
  341. HB_EXTERN void
  342. hb_buffer_add_latin1 (hb_buffer_t *buffer,
  343. const uint8_t *text,
  344. int text_length,
  345. unsigned int item_offset,
  346. int item_length);
  347. HB_EXTERN void
  348. hb_buffer_add_codepoints (hb_buffer_t *buffer,
  349. const hb_codepoint_t *text,
  350. int text_length,
  351. unsigned int item_offset,
  352. int item_length);
  353. HB_EXTERN void
  354. hb_buffer_append (hb_buffer_t *buffer,
  355. hb_buffer_t *source,
  356. unsigned int start,
  357. unsigned int end);
  358. HB_EXTERN hb_bool_t
  359. hb_buffer_set_length (hb_buffer_t *buffer,
  360. unsigned int length);
  361. HB_EXTERN unsigned int
  362. hb_buffer_get_length (hb_buffer_t *buffer);
  363. /* Getting glyphs out of the buffer */
  364. HB_EXTERN hb_glyph_info_t *
  365. hb_buffer_get_glyph_infos (hb_buffer_t *buffer,
  366. unsigned int *length);
  367. HB_EXTERN hb_glyph_position_t *
  368. hb_buffer_get_glyph_positions (hb_buffer_t *buffer,
  369. unsigned int *length);
  370. HB_EXTERN void
  371. hb_buffer_normalize_glyphs (hb_buffer_t *buffer);
  372. /*
  373. * Serialize
  374. */
  375. /**
  376. * hb_buffer_serialize_flags_t:
  377. * @HB_BUFFER_SERIALIZE_FLAG_DEFAULT: serialize glyph names, clusters and positions.
  378. * @HB_BUFFER_SERIALIZE_FLAG_NO_CLUSTERS: do not serialize glyph cluster.
  379. * @HB_BUFFER_SERIALIZE_FLAG_NO_POSITIONS: do not serialize glyph position information.
  380. * @HB_BUFFER_SERIALIZE_FLAG_NO_GLYPH_NAMES: do no serialize glyph name.
  381. * @HB_BUFFER_SERIALIZE_FLAG_GLYPH_EXTENTS: serialize glyph extents.
  382. * @HB_BUFFER_SERIALIZE_FLAG_GLYPH_FLAGS: serialize glyph flags. Since: 1.5.0
  383. * @HB_BUFFER_SERIALIZE_FLAG_NO_ADVANCES: do not serialize glyph advances,
  384. * glyph offsets will reflect absolute glyph positions. Since: 1.8.0
  385. *
  386. * Flags that control what glyph information are serialized in hb_buffer_serialize_glyphs().
  387. *
  388. * Since: 0.9.20
  389. */
  390. typedef enum { /*< flags >*/
  391. HB_BUFFER_SERIALIZE_FLAG_DEFAULT = 0x00000000u,
  392. HB_BUFFER_SERIALIZE_FLAG_NO_CLUSTERS = 0x00000001u,
  393. HB_BUFFER_SERIALIZE_FLAG_NO_POSITIONS = 0x00000002u,
  394. HB_BUFFER_SERIALIZE_FLAG_NO_GLYPH_NAMES = 0x00000004u,
  395. HB_BUFFER_SERIALIZE_FLAG_GLYPH_EXTENTS = 0x00000008u,
  396. HB_BUFFER_SERIALIZE_FLAG_GLYPH_FLAGS = 0x00000010u,
  397. HB_BUFFER_SERIALIZE_FLAG_NO_ADVANCES = 0x00000020u
  398. } hb_buffer_serialize_flags_t;
  399. /**
  400. * hb_buffer_serialize_format_t:
  401. * @HB_BUFFER_SERIALIZE_FORMAT_TEXT: a human-readable, plain text format.
  402. * @HB_BUFFER_SERIALIZE_FORMAT_JSON: a machine-readable JSON format.
  403. * @HB_BUFFER_SERIALIZE_FORMAT_INVALID: invalid format.
  404. *
  405. * The buffer serialization and de-serialization format used in
  406. * hb_buffer_serialize_glyphs() and hb_buffer_deserialize_glyphs().
  407. *
  408. * Since: 0.9.2
  409. */
  410. typedef enum {
  411. HB_BUFFER_SERIALIZE_FORMAT_TEXT = HB_TAG('T','E','X','T'),
  412. HB_BUFFER_SERIALIZE_FORMAT_JSON = HB_TAG('J','S','O','N'),
  413. HB_BUFFER_SERIALIZE_FORMAT_INVALID = HB_TAG_NONE
  414. } hb_buffer_serialize_format_t;
  415. HB_EXTERN hb_buffer_serialize_format_t
  416. hb_buffer_serialize_format_from_string (const char *str, int len);
  417. HB_EXTERN const char *
  418. hb_buffer_serialize_format_to_string (hb_buffer_serialize_format_t format);
  419. HB_EXTERN const char **
  420. hb_buffer_serialize_list_formats (void);
  421. HB_EXTERN unsigned int
  422. hb_buffer_serialize_glyphs (hb_buffer_t *buffer,
  423. unsigned int start,
  424. unsigned int end,
  425. char *buf,
  426. unsigned int buf_size,
  427. unsigned int *buf_consumed,
  428. hb_font_t *font,
  429. hb_buffer_serialize_format_t format,
  430. hb_buffer_serialize_flags_t flags);
  431. HB_EXTERN hb_bool_t
  432. hb_buffer_deserialize_glyphs (hb_buffer_t *buffer,
  433. const char *buf,
  434. int buf_len,
  435. const char **end_ptr,
  436. hb_font_t *font,
  437. hb_buffer_serialize_format_t format);
  438. /*
  439. * Compare buffers
  440. */
  441. typedef enum { /*< flags >*/
  442. HB_BUFFER_DIFF_FLAG_EQUAL = 0x0000,
  443. /* Buffers with different content_type cannot be meaningfully compared
  444. * in any further detail. */
  445. HB_BUFFER_DIFF_FLAG_CONTENT_TYPE_MISMATCH = 0x0001,
  446. /* For buffers with differing length, the per-glyph comparison is not
  447. * attempted, though we do still scan reference for dottedcircle / .notdef
  448. * glyphs. */
  449. HB_BUFFER_DIFF_FLAG_LENGTH_MISMATCH = 0x0002,
  450. /* We want to know if dottedcircle / .notdef glyphs are present in the
  451. * reference, as we may not care so much about other differences in this
  452. * case. */
  453. HB_BUFFER_DIFF_FLAG_NOTDEF_PRESENT = 0x0004,
  454. HB_BUFFER_DIFF_FLAG_DOTTED_CIRCLE_PRESENT = 0x0008,
  455. /* If the buffers have the same length, we compare them glyph-by-glyph
  456. * and report which aspect(s) of the glyph info/position are different. */
  457. HB_BUFFER_DIFF_FLAG_CODEPOINT_MISMATCH = 0x0010,
  458. HB_BUFFER_DIFF_FLAG_CLUSTER_MISMATCH = 0x0020,
  459. HB_BUFFER_DIFF_FLAG_GLYPH_FLAGS_MISMATCH = 0x0040,
  460. HB_BUFFER_DIFF_FLAG_POSITION_MISMATCH = 0x0080
  461. } hb_buffer_diff_flags_t;
  462. /* Compare the contents of two buffers, report types of differences. */
  463. HB_EXTERN hb_buffer_diff_flags_t
  464. hb_buffer_diff (hb_buffer_t *buffer,
  465. hb_buffer_t *reference,
  466. hb_codepoint_t dottedcircle_glyph,
  467. unsigned int position_fuzz);
  468. /*
  469. * Debugging.
  470. */
  471. typedef hb_bool_t (*hb_buffer_message_func_t) (hb_buffer_t *buffer,
  472. hb_font_t *font,
  473. const char *message,
  474. void *user_data);
  475. HB_EXTERN void
  476. hb_buffer_set_message_func (hb_buffer_t *buffer,
  477. hb_buffer_message_func_t func,
  478. void *user_data, hb_destroy_func_t destroy);
  479. HB_END_DECLS
  480. #endif /* HB_BUFFER_H */