46 * (after shaping).
47 * @mask:
48 * @cluster: the index of the character in the original text that corresponds
49 * to this #hb_glyph_info_t, or whatever the client passes to
50 * hb_buffer_add(). More than one #hb_glyph_info_t can have the same
51 * @cluster value, if they resulted from the same character (e.g. one
52 * to many glyph substitution), and when more than one character gets
53 * merged in the same glyph (e.g. many to one glyph substitution) the
54 * #hb_glyph_info_t will have the smallest cluster value of them.
55 * By default some characters are merged into the same cluster
56 * (e.g. combining marks have the same cluster as their bases)
57 * even if they are separate glyphs, hb_buffer_set_cluster_level()
58 * allow selecting more fine-grained cluster handling.
59 *
60 * The #hb_glyph_info_t is the structure that holds information about the
61 * glyphs and their relation to input text.
62 *
63 */
64 typedef struct hb_glyph_info_t {
65 hb_codepoint_t codepoint;
66 hb_mask_t mask;
67 uint32_t cluster;
68
69 /*< private >*/
70 hb_var_int_t var1;
71 hb_var_int_t var2;
72 } hb_glyph_info_t;
73
74 /**
75 * hb_glyph_position_t:
76 * @x_advance: how much the line advances after drawing this glyph when setting
77 * text in horizontal direction.
78 * @y_advance: how much the line advances after drawing this glyph when setting
79 * text in vertical direction.
80 * @x_offset: how much the glyph moves on the X-axis before drawing it, this
81 * should not affect how much the line advances.
82 * @y_offset: how much the glyph moves on the Y-axis before drawing it, this
83 * should not affect how much the line advances.
84 *
85 * The #hb_glyph_position_t is the structure that holds the positions of the
86 * glyph in both horizontal and vertical directions. All positions in
87 * #hb_glyph_position_t are relative to the current point.
88 *
89 */
90 typedef struct hb_glyph_position_t {
91 hb_position_t x_advance;
92 hb_position_t y_advance;
93 hb_position_t x_offset;
102 * @direction: the #hb_direction_t of the buffer, see hb_buffer_set_direction().
103 * @script: the #hb_script_t of the buffer, see hb_buffer_set_script().
104 * @language: the #hb_language_t of the buffer, see hb_buffer_set_language().
105 *
106 * The structure that holds various text properties of an #hb_buffer_t. Can be
107 * set and retrieved using hb_buffer_set_segment_properties() and
108 * hb_buffer_get_segment_properties(), respectively.
109 */
110 typedef struct hb_segment_properties_t {
111 hb_direction_t direction;
112 hb_script_t script;
113 hb_language_t language;
114 /*< private >*/
115 void *reserved1;
116 void *reserved2;
117 } hb_segment_properties_t;
118
119 #define HB_SEGMENT_PROPERTIES_DEFAULT {HB_DIRECTION_INVALID, \
120 HB_SCRIPT_INVALID, \
121 HB_LANGUAGE_INVALID, \
122 NULL, \
123 NULL}
124
125 HB_EXTERN hb_bool_t
126 hb_segment_properties_equal (const hb_segment_properties_t *a,
127 const hb_segment_properties_t *b);
128
129 HB_EXTERN unsigned int
130 hb_segment_properties_hash (const hb_segment_properties_t *p);
131
132
133
134 /**
135 * hb_buffer_t:
136 *
137 * The main structure holding the input text and its properties before shaping,
138 * and output glyphs and their information after shaping.
139 */
140
141 typedef struct hb_buffer_t hb_buffer_t;
142
143 HB_EXTERN hb_buffer_t *
146 HB_EXTERN hb_buffer_t *
147 hb_buffer_get_empty (void);
148
149 HB_EXTERN hb_buffer_t *
150 hb_buffer_reference (hb_buffer_t *buffer);
151
152 HB_EXTERN void
153 hb_buffer_destroy (hb_buffer_t *buffer);
154
155 HB_EXTERN hb_bool_t
156 hb_buffer_set_user_data (hb_buffer_t *buffer,
157 hb_user_data_key_t *key,
158 void * data,
159 hb_destroy_func_t destroy,
160 hb_bool_t replace);
161
162 HB_EXTERN void *
163 hb_buffer_get_user_data (hb_buffer_t *buffer,
164 hb_user_data_key_t *key);
165
166 /**
167 * hb_buffer_content_type_t:
168 * @HB_BUFFER_CONTENT_TYPE_INVALID: Initial value for new buffer.
169 * @HB_BUFFER_CONTENT_TYPE_UNICODE: The buffer contains input characters (before shaping).
170 * @HB_BUFFER_CONTENT_TYPE_GLYPHS: The buffer contains output glyphs (after shaping).
171 */
172 typedef enum {
173 HB_BUFFER_CONTENT_TYPE_INVALID = 0,
174 HB_BUFFER_CONTENT_TYPE_UNICODE,
175 HB_BUFFER_CONTENT_TYPE_GLYPHS
176 } hb_buffer_content_type_t;
177
178 HB_EXTERN void
179 hb_buffer_set_content_type (hb_buffer_t *buffer,
180 hb_buffer_content_type_t content_type);
181
182 HB_EXTERN hb_buffer_content_type_t
183 hb_buffer_get_content_type (hb_buffer_t *buffer);
184
185
342 hb_buffer_add_utf32 (hb_buffer_t *buffer,
343 const uint32_t *text,
344 int text_length,
345 unsigned int item_offset,
346 int item_length);
347
348 HB_EXTERN void
349 hb_buffer_add_latin1 (hb_buffer_t *buffer,
350 const uint8_t *text,
351 int text_length,
352 unsigned int item_offset,
353 int item_length);
354
355 HB_EXTERN void
356 hb_buffer_add_codepoints (hb_buffer_t *buffer,
357 const hb_codepoint_t *text,
358 int text_length,
359 unsigned int item_offset,
360 int item_length);
361
362
363 HB_EXTERN hb_bool_t
364 hb_buffer_set_length (hb_buffer_t *buffer,
365 unsigned int length);
366
367 HB_EXTERN unsigned int
368 hb_buffer_get_length (hb_buffer_t *buffer);
369
370 /* Getting glyphs out of the buffer */
371
372 HB_EXTERN hb_glyph_info_t *
373 hb_buffer_get_glyph_infos (hb_buffer_t *buffer,
374 unsigned int *length);
375
376 HB_EXTERN hb_glyph_position_t *
377 hb_buffer_get_glyph_positions (hb_buffer_t *buffer,
378 unsigned int *length);
379
380
381 HB_EXTERN void
386 * Serialize
387 */
388
389 /**
390 * hb_buffer_serialize_flags_t:
391 * @HB_BUFFER_SERIALIZE_FLAG_DEFAULT: serialize glyph names, clusters and positions.
392 * @HB_BUFFER_SERIALIZE_FLAG_NO_CLUSTERS: do not serialize glyph cluster.
393 * @HB_BUFFER_SERIALIZE_FLAG_NO_POSITIONS: do not serialize glyph position information.
394 * @HB_BUFFER_SERIALIZE_FLAG_NO_GLYPH_NAMES: do no serialize glyph name.
395 * @HB_BUFFER_SERIALIZE_FLAG_GLYPH_EXTENTS: serialize glyph extents.
396 *
397 * Flags that control what glyph information are serialized in hb_buffer_serialize_glyphs().
398 *
399 * Since: 0.9.20
400 */
401 typedef enum { /*< flags >*/
402 HB_BUFFER_SERIALIZE_FLAG_DEFAULT = 0x00000000u,
403 HB_BUFFER_SERIALIZE_FLAG_NO_CLUSTERS = 0x00000001u,
404 HB_BUFFER_SERIALIZE_FLAG_NO_POSITIONS = 0x00000002u,
405 HB_BUFFER_SERIALIZE_FLAG_NO_GLYPH_NAMES = 0x00000004u,
406 HB_BUFFER_SERIALIZE_FLAG_GLYPH_EXTENTS = 0x00000008u
407 } hb_buffer_serialize_flags_t;
408
409 /**
410 * hb_buffer_serialize_format_t:
411 * @HB_BUFFER_SERIALIZE_FORMAT_TEXT: a human-readable, plain text format.
412 * @HB_BUFFER_SERIALIZE_FORMAT_JSON: a machine-readable JSON format.
413 * @HB_BUFFER_SERIALIZE_FORMAT_INVALID: invalid format.
414 *
415 * The buffer serialization and de-serialization format used in
416 * hb_buffer_serialize_glyphs() and hb_buffer_deserialize_glyphs().
417 *
418 * Since: 0.9.2
419 */
420 typedef enum {
421 HB_BUFFER_SERIALIZE_FORMAT_TEXT = HB_TAG('T','E','X','T'),
422 HB_BUFFER_SERIALIZE_FORMAT_JSON = HB_TAG('J','S','O','N'),
423 HB_BUFFER_SERIALIZE_FORMAT_INVALID = HB_TAG_NONE
424 } hb_buffer_serialize_format_t;
425
426 HB_EXTERN hb_buffer_serialize_format_t
433 hb_buffer_serialize_list_formats (void);
434
435 HB_EXTERN unsigned int
436 hb_buffer_serialize_glyphs (hb_buffer_t *buffer,
437 unsigned int start,
438 unsigned int end,
439 char *buf,
440 unsigned int buf_size,
441 unsigned int *buf_consumed,
442 hb_font_t *font,
443 hb_buffer_serialize_format_t format,
444 hb_buffer_serialize_flags_t flags);
445
446 HB_EXTERN hb_bool_t
447 hb_buffer_deserialize_glyphs (hb_buffer_t *buffer,
448 const char *buf,
449 int buf_len,
450 const char **end_ptr,
451 hb_font_t *font,
452 hb_buffer_serialize_format_t format);
453
454
455 /*
456 * Debugging.
457 */
458
459 typedef hb_bool_t (*hb_buffer_message_func_t) (hb_buffer_t *buffer,
460 hb_font_t *font,
461 const char *message,
462 void *user_data);
463
464 HB_EXTERN void
465 hb_buffer_set_message_func (hb_buffer_t *buffer,
466 hb_buffer_message_func_t func,
467 void *user_data, hb_destroy_func_t destroy);
468
469
470 HB_END_DECLS
471
472 #endif /* HB_BUFFER_H */
|
46 * (after shaping).
47 * @mask:
48 * @cluster: the index of the character in the original text that corresponds
49 * to this #hb_glyph_info_t, or whatever the client passes to
50 * hb_buffer_add(). More than one #hb_glyph_info_t can have the same
51 * @cluster value, if they resulted from the same character (e.g. one
52 * to many glyph substitution), and when more than one character gets
53 * merged in the same glyph (e.g. many to one glyph substitution) the
54 * #hb_glyph_info_t will have the smallest cluster value of them.
55 * By default some characters are merged into the same cluster
56 * (e.g. combining marks have the same cluster as their bases)
57 * even if they are separate glyphs, hb_buffer_set_cluster_level()
58 * allow selecting more fine-grained cluster handling.
59 *
60 * The #hb_glyph_info_t is the structure that holds information about the
61 * glyphs and their relation to input text.
62 *
63 */
64 typedef struct hb_glyph_info_t {
65 hb_codepoint_t codepoint;
66 hb_mask_t mask; /* Holds hb_glyph_flags_t after hb_shape(), plus other things. */
67 uint32_t cluster;
68
69 /*< private >*/
70 hb_var_int_t var1;
71 hb_var_int_t var2;
72 } hb_glyph_info_t;
73
74 typedef enum { /*< flags >*/
75 HB_GLYPH_FLAG_UNSAFE_TO_BREAK = 0x00000001,
76
77 HB_GLYPH_FLAG_DEFINED = 0x00000001 /* OR of all defined flags */
78 } hb_glyph_flags_t;
79
80 HB_EXTERN hb_glyph_flags_t
81 hb_glyph_info_get_glyph_flags (const hb_glyph_info_t *info);
82
83 #define hb_glyph_info_get_glyph_flags(info) \
84 ((hb_glyph_flags_t) ((unsigned int) (info)->mask & HB_GLYPH_FLAG_DEFINED))
85
86
87 /**
88 * hb_glyph_position_t:
89 * @x_advance: how much the line advances after drawing this glyph when setting
90 * text in horizontal direction.
91 * @y_advance: how much the line advances after drawing this glyph when setting
92 * text in vertical direction.
93 * @x_offset: how much the glyph moves on the X-axis before drawing it, this
94 * should not affect how much the line advances.
95 * @y_offset: how much the glyph moves on the Y-axis before drawing it, this
96 * should not affect how much the line advances.
97 *
98 * The #hb_glyph_position_t is the structure that holds the positions of the
99 * glyph in both horizontal and vertical directions. All positions in
100 * #hb_glyph_position_t are relative to the current point.
101 *
102 */
103 typedef struct hb_glyph_position_t {
104 hb_position_t x_advance;
105 hb_position_t y_advance;
106 hb_position_t x_offset;
115 * @direction: the #hb_direction_t of the buffer, see hb_buffer_set_direction().
116 * @script: the #hb_script_t of the buffer, see hb_buffer_set_script().
117 * @language: the #hb_language_t of the buffer, see hb_buffer_set_language().
118 *
119 * The structure that holds various text properties of an #hb_buffer_t. Can be
120 * set and retrieved using hb_buffer_set_segment_properties() and
121 * hb_buffer_get_segment_properties(), respectively.
122 */
123 typedef struct hb_segment_properties_t {
124 hb_direction_t direction;
125 hb_script_t script;
126 hb_language_t language;
127 /*< private >*/
128 void *reserved1;
129 void *reserved2;
130 } hb_segment_properties_t;
131
132 #define HB_SEGMENT_PROPERTIES_DEFAULT {HB_DIRECTION_INVALID, \
133 HB_SCRIPT_INVALID, \
134 HB_LANGUAGE_INVALID, \
135 (void *) 0, \
136 (void *) 0}
137
138 HB_EXTERN hb_bool_t
139 hb_segment_properties_equal (const hb_segment_properties_t *a,
140 const hb_segment_properties_t *b);
141
142 HB_EXTERN unsigned int
143 hb_segment_properties_hash (const hb_segment_properties_t *p);
144
145
146
147 /**
148 * hb_buffer_t:
149 *
150 * The main structure holding the input text and its properties before shaping,
151 * and output glyphs and their information after shaping.
152 */
153
154 typedef struct hb_buffer_t hb_buffer_t;
155
156 HB_EXTERN hb_buffer_t *
159 HB_EXTERN hb_buffer_t *
160 hb_buffer_get_empty (void);
161
162 HB_EXTERN hb_buffer_t *
163 hb_buffer_reference (hb_buffer_t *buffer);
164
165 HB_EXTERN void
166 hb_buffer_destroy (hb_buffer_t *buffer);
167
168 HB_EXTERN hb_bool_t
169 hb_buffer_set_user_data (hb_buffer_t *buffer,
170 hb_user_data_key_t *key,
171 void * data,
172 hb_destroy_func_t destroy,
173 hb_bool_t replace);
174
175 HB_EXTERN void *
176 hb_buffer_get_user_data (hb_buffer_t *buffer,
177 hb_user_data_key_t *key);
178
179
180 /**
181 * hb_buffer_content_type_t:
182 * @HB_BUFFER_CONTENT_TYPE_INVALID: Initial value for new buffer.
183 * @HB_BUFFER_CONTENT_TYPE_UNICODE: The buffer contains input characters (before shaping).
184 * @HB_BUFFER_CONTENT_TYPE_GLYPHS: The buffer contains output glyphs (after shaping).
185 */
186 typedef enum {
187 HB_BUFFER_CONTENT_TYPE_INVALID = 0,
188 HB_BUFFER_CONTENT_TYPE_UNICODE,
189 HB_BUFFER_CONTENT_TYPE_GLYPHS
190 } hb_buffer_content_type_t;
191
192 HB_EXTERN void
193 hb_buffer_set_content_type (hb_buffer_t *buffer,
194 hb_buffer_content_type_t content_type);
195
196 HB_EXTERN hb_buffer_content_type_t
197 hb_buffer_get_content_type (hb_buffer_t *buffer);
198
199
356 hb_buffer_add_utf32 (hb_buffer_t *buffer,
357 const uint32_t *text,
358 int text_length,
359 unsigned int item_offset,
360 int item_length);
361
362 HB_EXTERN void
363 hb_buffer_add_latin1 (hb_buffer_t *buffer,
364 const uint8_t *text,
365 int text_length,
366 unsigned int item_offset,
367 int item_length);
368
369 HB_EXTERN void
370 hb_buffer_add_codepoints (hb_buffer_t *buffer,
371 const hb_codepoint_t *text,
372 int text_length,
373 unsigned int item_offset,
374 int item_length);
375
376 HB_EXTERN void
377 hb_buffer_append (hb_buffer_t *buffer,
378 hb_buffer_t *source,
379 unsigned int start,
380 unsigned int end);
381
382 HB_EXTERN hb_bool_t
383 hb_buffer_set_length (hb_buffer_t *buffer,
384 unsigned int length);
385
386 HB_EXTERN unsigned int
387 hb_buffer_get_length (hb_buffer_t *buffer);
388
389 /* Getting glyphs out of the buffer */
390
391 HB_EXTERN hb_glyph_info_t *
392 hb_buffer_get_glyph_infos (hb_buffer_t *buffer,
393 unsigned int *length);
394
395 HB_EXTERN hb_glyph_position_t *
396 hb_buffer_get_glyph_positions (hb_buffer_t *buffer,
397 unsigned int *length);
398
399
400 HB_EXTERN void
405 * Serialize
406 */
407
408 /**
409 * hb_buffer_serialize_flags_t:
410 * @HB_BUFFER_SERIALIZE_FLAG_DEFAULT: serialize glyph names, clusters and positions.
411 * @HB_BUFFER_SERIALIZE_FLAG_NO_CLUSTERS: do not serialize glyph cluster.
412 * @HB_BUFFER_SERIALIZE_FLAG_NO_POSITIONS: do not serialize glyph position information.
413 * @HB_BUFFER_SERIALIZE_FLAG_NO_GLYPH_NAMES: do no serialize glyph name.
414 * @HB_BUFFER_SERIALIZE_FLAG_GLYPH_EXTENTS: serialize glyph extents.
415 *
416 * Flags that control what glyph information are serialized in hb_buffer_serialize_glyphs().
417 *
418 * Since: 0.9.20
419 */
420 typedef enum { /*< flags >*/
421 HB_BUFFER_SERIALIZE_FLAG_DEFAULT = 0x00000000u,
422 HB_BUFFER_SERIALIZE_FLAG_NO_CLUSTERS = 0x00000001u,
423 HB_BUFFER_SERIALIZE_FLAG_NO_POSITIONS = 0x00000002u,
424 HB_BUFFER_SERIALIZE_FLAG_NO_GLYPH_NAMES = 0x00000004u,
425 HB_BUFFER_SERIALIZE_FLAG_GLYPH_EXTENTS = 0x00000008u,
426 HB_BUFFER_SERIALIZE_FLAG_GLYPH_FLAGS = 0x00000010u
427 } hb_buffer_serialize_flags_t;
428
429 /**
430 * hb_buffer_serialize_format_t:
431 * @HB_BUFFER_SERIALIZE_FORMAT_TEXT: a human-readable, plain text format.
432 * @HB_BUFFER_SERIALIZE_FORMAT_JSON: a machine-readable JSON format.
433 * @HB_BUFFER_SERIALIZE_FORMAT_INVALID: invalid format.
434 *
435 * The buffer serialization and de-serialization format used in
436 * hb_buffer_serialize_glyphs() and hb_buffer_deserialize_glyphs().
437 *
438 * Since: 0.9.2
439 */
440 typedef enum {
441 HB_BUFFER_SERIALIZE_FORMAT_TEXT = HB_TAG('T','E','X','T'),
442 HB_BUFFER_SERIALIZE_FORMAT_JSON = HB_TAG('J','S','O','N'),
443 HB_BUFFER_SERIALIZE_FORMAT_INVALID = HB_TAG_NONE
444 } hb_buffer_serialize_format_t;
445
446 HB_EXTERN hb_buffer_serialize_format_t
453 hb_buffer_serialize_list_formats (void);
454
455 HB_EXTERN unsigned int
456 hb_buffer_serialize_glyphs (hb_buffer_t *buffer,
457 unsigned int start,
458 unsigned int end,
459 char *buf,
460 unsigned int buf_size,
461 unsigned int *buf_consumed,
462 hb_font_t *font,
463 hb_buffer_serialize_format_t format,
464 hb_buffer_serialize_flags_t flags);
465
466 HB_EXTERN hb_bool_t
467 hb_buffer_deserialize_glyphs (hb_buffer_t *buffer,
468 const char *buf,
469 int buf_len,
470 const char **end_ptr,
471 hb_font_t *font,
472 hb_buffer_serialize_format_t format);
473
474
475 /*
476 * Compare buffers
477 */
478
479 typedef enum { /*< flags >*/
480 HB_BUFFER_DIFF_FLAG_EQUAL = 0x0000,
481
482 /* Buffers with different content_type cannot be meaningfully compared
483 * in any further detail. */
484 HB_BUFFER_DIFF_FLAG_CONTENT_TYPE_MISMATCH = 0x0001,
485
486 /* For buffers with differing length, the per-glyph comparison is not
487 * attempted, though we do still scan reference for dottedcircle / .notdef
488 * glyphs. */
489 HB_BUFFER_DIFF_FLAG_LENGTH_MISMATCH = 0x0002,
490
491 /* We want to know if dottedcircle / .notdef glyphs are present in the
492 * reference, as we may not care so much about other differences in this
493 * case. */
494 HB_BUFFER_DIFF_FLAG_NOTDEF_PRESENT = 0x0004,
495 HB_BUFFER_DIFF_FLAG_DOTTED_CIRCLE_PRESENT = 0x0008,
496
497 /* If the buffers have the same length, we compare them glyph-by-glyph
498 * and report which aspect(s) of the glyph info/position are different. */
499 HB_BUFFER_DIFF_FLAG_CODEPOINT_MISMATCH = 0x0010,
500 HB_BUFFER_DIFF_FLAG_CLUSTER_MISMATCH = 0x0020,
501 HB_BUFFER_DIFF_FLAG_GLYPH_FLAGS_MISMATCH = 0x0040,
502 HB_BUFFER_DIFF_FLAG_POSITION_MISMATCH = 0x0080
503
504 } hb_buffer_diff_flags_t;
505
506 /* Compare the contents of two buffers, report types of differences. */
507 HB_EXTERN hb_buffer_diff_flags_t
508 hb_buffer_diff (hb_buffer_t *buffer,
509 hb_buffer_t *reference,
510 hb_codepoint_t dottedcircle_glyph,
511 unsigned int position_fuzz);
512
513
514 /*
515 * Debugging.
516 */
517
518 typedef hb_bool_t (*hb_buffer_message_func_t) (hb_buffer_t *buffer,
519 hb_font_t *font,
520 const char *message,
521 void *user_data);
522
523 HB_EXTERN void
524 hb_buffer_set_message_func (hb_buffer_t *buffer,
525 hb_buffer_message_func_t func,
526 void *user_data, hb_destroy_func_t destroy);
527
528
529 HB_END_DECLS
530
531 #endif /* HB_BUFFER_H */
|