Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/jdk17u
Path: blob/master/src/java.desktop/share/native/libharfbuzz/hb-buffer.h
66644 views
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
30
#if !defined(HB_H_IN) && !defined(HB_NO_SINGLE_HEADER_ERROR)
31
#error "Include <hb.h> instead."
32
#endif
33
34
#ifndef HB_BUFFER_H
35
#define HB_BUFFER_H
36
37
#include "hb-common.h"
38
#include "hb-unicode.h"
39
#include "hb-font.h"
40
41
HB_BEGIN_DECLS
42
43
/**
44
* hb_glyph_info_t:
45
* @codepoint: either a Unicode code point (before shaping) or a glyph index
46
* (after shaping).
47
* @cluster: the index of the character in the original text that corresponds
48
* to this #hb_glyph_info_t, or whatever the client passes to
49
* hb_buffer_add(). More than one #hb_glyph_info_t can have the same
50
* @cluster value, if they resulted from the same character (e.g. one
51
* to many glyph substitution), and when more than one character gets
52
* merged in the same glyph (e.g. many to one glyph substitution) the
53
* #hb_glyph_info_t will have the smallest cluster value of them.
54
* By default some characters are merged into the same cluster
55
* (e.g. combining marks have the same cluster as their bases)
56
* even if they are separate glyphs, hb_buffer_set_cluster_level()
57
* allow selecting more fine-grained cluster handling.
58
*
59
* The #hb_glyph_info_t is the structure that holds information about the
60
* glyphs and their relation to input text.
61
*/
62
typedef struct hb_glyph_info_t {
63
hb_codepoint_t codepoint;
64
/*< private >*/
65
hb_mask_t mask;
66
/*< public >*/
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_flags_t:
76
* @HB_GLYPH_FLAG_UNSAFE_TO_BREAK: Indicates that if input text is broken at the
77
* beginning of the cluster this glyph is part of,
78
* then both sides need to be re-shaped, as the
79
* result might be different.
80
* On the flip side, it means that when this
81
* flag is not present, then it is safe to break
82
* the glyph-run at the beginning of this
83
* cluster, and the two sides will represent the
84
* exact same result one would get if breaking
85
* input text at the beginning of this cluster
86
* and shaping the two sides separately.
87
* This can be used to optimize paragraph
88
* layout, by avoiding re-shaping of each line
89
* after line-breaking.
90
* @HB_GLYPH_FLAG_UNSAFE_TO_CONCAT: Indicates that if input text is changed on one
91
* side of the beginning of the cluster this glyph
92
* is part of, then the shaping results for the
93
* other side might change.
94
* Note that the absence of this flag will NOT by
95
* itself mean that it IS safe to concat text.
96
* Only two pieces of text both of which clear of
97
* this flag can be concatenated safely.
98
* This can be used to optimize paragraph
99
* layout, by avoiding re-shaping of each line
100
* after line-breaking, by limiting the
101
* reshaping to a small piece around the
102
* breaking positin only, even if the breaking
103
* position carries the
104
* #HB_GLYPH_FLAG_UNSAFE_TO_BREAK or when
105
* hyphenation or other text transformation
106
* happens at line-break position, in the following
107
* way:
108
* 1. Iterate back from the line-break position
109
* until the first cluster start position that is
110
* NOT unsafe-to-concat, 2. shape the segment from
111
* there till the end of line, 3. check whether the
112
* resulting glyph-run also is clear of the
113
* unsafe-to-concat at its start-of-text position;
114
* if it is, just splice it into place and the line
115
* is shaped; If not, move on to a position further
116
* back that is clear of unsafe-to-concat and retry
117
* from there, and repeat.
118
* At the start of next line a similar algorithm can
119
* be implemented. That is: 1. Iterate forward from
120
* the line-break position until the first cluster
121
* start position that is NOT unsafe-to-concat, 2.
122
* shape the segment from beginning of the line to
123
* that position, 3. check whether the resulting
124
* glyph-run also is clear of the unsafe-to-concat
125
* at its end-of-text position; if it is, just splice
126
* it into place and the beginning is shaped; If not,
127
* move on to a position further forward that is clear
128
* of unsafe-to-concat and retry up to there, and repeat.
129
* A slight complication will arise in the
130
* implementation of the algorithm above,
131
* because while our buffer API has a way to
132
* return flags for position corresponding to
133
* start-of-text, there is currently no position
134
* corresponding to end-of-text. This limitation
135
* can be alleviated by shaping more text than needed
136
* and looking for unsafe-to-concat flag within text
137
* clusters.
138
* The #HB_GLYPH_FLAG_UNSAFE_TO_BREAK flag will
139
* always imply this flag.
140
* To use this flag, you must enable the buffer flag
141
* @HB_BUFFER_FLAG_PRODUCE_UNSAFE_TO_CONCAT during
142
* shaping, otherwise the buffer flag will not be
143
* reliably produced.
144
* Since: 4.0.0
145
* @HB_GLYPH_FLAG_DEFINED: All the currently defined flags.
146
*
147
* Flags for #hb_glyph_info_t.
148
*
149
* Since: 1.5.0
150
*/
151
typedef enum { /*< flags >*/
152
HB_GLYPH_FLAG_UNSAFE_TO_BREAK = 0x00000001,
153
HB_GLYPH_FLAG_UNSAFE_TO_CONCAT = 0x00000002,
154
155
HB_GLYPH_FLAG_DEFINED = 0x00000003 /* OR of all defined flags */
156
} hb_glyph_flags_t;
157
158
HB_EXTERN hb_glyph_flags_t
159
hb_glyph_info_get_glyph_flags (const hb_glyph_info_t *info);
160
161
#define hb_glyph_info_get_glyph_flags(info) \
162
((hb_glyph_flags_t) ((unsigned int) (info)->mask & HB_GLYPH_FLAG_DEFINED))
163
164
165
/**
166
* hb_glyph_position_t:
167
* @x_advance: how much the line advances after drawing this glyph when setting
168
* text in horizontal direction.
169
* @y_advance: how much the line advances after drawing this glyph when setting
170
* text in vertical direction.
171
* @x_offset: how much the glyph moves on the X-axis before drawing it, this
172
* should not affect how much the line advances.
173
* @y_offset: how much the glyph moves on the Y-axis before drawing it, this
174
* should not affect how much the line advances.
175
*
176
* The #hb_glyph_position_t is the structure that holds the positions of the
177
* glyph in both horizontal and vertical directions. All positions in
178
* #hb_glyph_position_t are relative to the current point.
179
*
180
*/
181
typedef struct hb_glyph_position_t {
182
hb_position_t x_advance;
183
hb_position_t y_advance;
184
hb_position_t x_offset;
185
hb_position_t y_offset;
186
187
/*< private >*/
188
hb_var_int_t var;
189
} hb_glyph_position_t;
190
191
/**
192
* hb_segment_properties_t:
193
* @direction: the #hb_direction_t of the buffer, see hb_buffer_set_direction().
194
* @script: the #hb_script_t of the buffer, see hb_buffer_set_script().
195
* @language: the #hb_language_t of the buffer, see hb_buffer_set_language().
196
*
197
* The structure that holds various text properties of an #hb_buffer_t. Can be
198
* set and retrieved using hb_buffer_set_segment_properties() and
199
* hb_buffer_get_segment_properties(), respectively.
200
*/
201
typedef struct hb_segment_properties_t {
202
hb_direction_t direction;
203
hb_script_t script;
204
hb_language_t language;
205
/*< private >*/
206
void *reserved1;
207
void *reserved2;
208
} hb_segment_properties_t;
209
210
/**
211
* HB_SEGMENT_PROPERTIES_DEFAULT:
212
*
213
* The default #hb_segment_properties_t of of freshly created #hb_buffer_t.
214
*/
215
#define HB_SEGMENT_PROPERTIES_DEFAULT {HB_DIRECTION_INVALID, \
216
HB_SCRIPT_INVALID, \
217
HB_LANGUAGE_INVALID, \
218
(void *) 0, \
219
(void *) 0}
220
221
HB_EXTERN hb_bool_t
222
hb_segment_properties_equal (const hb_segment_properties_t *a,
223
const hb_segment_properties_t *b);
224
225
HB_EXTERN unsigned int
226
hb_segment_properties_hash (const hb_segment_properties_t *p);
227
228
HB_EXTERN void
229
hb_segment_properties_overlay (hb_segment_properties_t *p,
230
const hb_segment_properties_t *src);
231
232
233
/**
234
* hb_buffer_t:
235
*
236
* The main structure holding the input text and its properties before shaping,
237
* and output glyphs and their information after shaping.
238
*/
239
240
typedef struct hb_buffer_t hb_buffer_t;
241
242
HB_EXTERN hb_buffer_t *
243
hb_buffer_create (void);
244
245
HB_EXTERN hb_buffer_t *
246
hb_buffer_create_similar (const hb_buffer_t *src);
247
248
HB_EXTERN void
249
hb_buffer_reset (hb_buffer_t *buffer);
250
251
252
HB_EXTERN hb_buffer_t *
253
hb_buffer_get_empty (void);
254
255
HB_EXTERN hb_buffer_t *
256
hb_buffer_reference (hb_buffer_t *buffer);
257
258
HB_EXTERN void
259
hb_buffer_destroy (hb_buffer_t *buffer);
260
261
HB_EXTERN hb_bool_t
262
hb_buffer_set_user_data (hb_buffer_t *buffer,
263
hb_user_data_key_t *key,
264
void * data,
265
hb_destroy_func_t destroy,
266
hb_bool_t replace);
267
268
HB_EXTERN void *
269
hb_buffer_get_user_data (hb_buffer_t *buffer,
270
hb_user_data_key_t *key);
271
272
273
/**
274
* hb_buffer_content_type_t:
275
* @HB_BUFFER_CONTENT_TYPE_INVALID: Initial value for new buffer.
276
* @HB_BUFFER_CONTENT_TYPE_UNICODE: The buffer contains input characters (before shaping).
277
* @HB_BUFFER_CONTENT_TYPE_GLYPHS: The buffer contains output glyphs (after shaping).
278
*
279
* The type of #hb_buffer_t contents.
280
*/
281
typedef enum {
282
HB_BUFFER_CONTENT_TYPE_INVALID = 0,
283
HB_BUFFER_CONTENT_TYPE_UNICODE,
284
HB_BUFFER_CONTENT_TYPE_GLYPHS
285
} hb_buffer_content_type_t;
286
287
HB_EXTERN void
288
hb_buffer_set_content_type (hb_buffer_t *buffer,
289
hb_buffer_content_type_t content_type);
290
291
HB_EXTERN hb_buffer_content_type_t
292
hb_buffer_get_content_type (const hb_buffer_t *buffer);
293
294
295
HB_EXTERN void
296
hb_buffer_set_unicode_funcs (hb_buffer_t *buffer,
297
hb_unicode_funcs_t *unicode_funcs);
298
299
HB_EXTERN hb_unicode_funcs_t *
300
hb_buffer_get_unicode_funcs (const hb_buffer_t *buffer);
301
302
HB_EXTERN void
303
hb_buffer_set_direction (hb_buffer_t *buffer,
304
hb_direction_t direction);
305
306
HB_EXTERN hb_direction_t
307
hb_buffer_get_direction (const hb_buffer_t *buffer);
308
309
HB_EXTERN void
310
hb_buffer_set_script (hb_buffer_t *buffer,
311
hb_script_t script);
312
313
HB_EXTERN hb_script_t
314
hb_buffer_get_script (const hb_buffer_t *buffer);
315
316
HB_EXTERN void
317
hb_buffer_set_language (hb_buffer_t *buffer,
318
hb_language_t language);
319
320
321
HB_EXTERN hb_language_t
322
hb_buffer_get_language (const hb_buffer_t *buffer);
323
324
HB_EXTERN void
325
hb_buffer_set_segment_properties (hb_buffer_t *buffer,
326
const hb_segment_properties_t *props);
327
328
HB_EXTERN void
329
hb_buffer_get_segment_properties (const hb_buffer_t *buffer,
330
hb_segment_properties_t *props);
331
332
HB_EXTERN void
333
hb_buffer_guess_segment_properties (hb_buffer_t *buffer);
334
335
336
/**
337
* hb_buffer_flags_t:
338
* @HB_BUFFER_FLAG_DEFAULT: the default buffer flag.
339
* @HB_BUFFER_FLAG_BOT: flag indicating that special handling of the beginning
340
* of text paragraph can be applied to this buffer. Should usually
341
* be set, unless you are passing to the buffer only part
342
* of the text without the full context.
343
* @HB_BUFFER_FLAG_EOT: flag indicating that special handling of the end of text
344
* paragraph can be applied to this buffer, similar to
345
* @HB_BUFFER_FLAG_BOT.
346
* @HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES:
347
* flag indication that character with Default_Ignorable
348
* Unicode property should use the corresponding glyph
349
* from the font, instead of hiding them (done by
350
* replacing them with the space glyph and zeroing the
351
* advance width.) This flag takes precedence over
352
* @HB_BUFFER_FLAG_REMOVE_DEFAULT_IGNORABLES.
353
* @HB_BUFFER_FLAG_REMOVE_DEFAULT_IGNORABLES:
354
* flag indication that character with Default_Ignorable
355
* Unicode property should be removed from glyph string
356
* instead of hiding them (done by replacing them with the
357
* space glyph and zeroing the advance width.)
358
* @HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES takes
359
* precedence over this flag. Since: 1.8.0
360
* @HB_BUFFER_FLAG_DO_NOT_INSERT_DOTTED_CIRCLE:
361
* flag indicating that a dotted circle should
362
* not be inserted in the rendering of incorrect
363
* character sequences (such at <0905 093E>). Since: 2.4.0
364
* @HB_BUFFER_FLAG_VERIFY:
365
* flag indicating that the hb_shape() call and its variants
366
* should perform various verification processes on the results
367
* of the shaping operation on the buffer. If the verification
368
* fails, then either a buffer message is sent, if a message
369
* handler is installed on the buffer, or a message is written
370
* to standard error. In either case, the shaping result might
371
* be modified to show the failed output. Since: 3.4.0
372
* @HB_BUFFER_FLAG_PRODUCE_UNSAFE_TO_CONCAT:
373
* flag indicating that the @HB_GLYPH_FLAG_UNSAFE_TO_CONCAT
374
* glyph-flag should be produced by the shaper. By default
375
* it will not be produced since it incurs a cost. Since: 4.0.0
376
* @HB_BUFFER_FLAG_DEFINED: All currently defined flags: Since: 4.4.0
377
*
378
* Flags for #hb_buffer_t.
379
*
380
* Since: 0.9.20
381
*/
382
typedef enum { /*< flags >*/
383
HB_BUFFER_FLAG_DEFAULT = 0x00000000u,
384
HB_BUFFER_FLAG_BOT = 0x00000001u, /* Beginning-of-text */
385
HB_BUFFER_FLAG_EOT = 0x00000002u, /* End-of-text */
386
HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES = 0x00000004u,
387
HB_BUFFER_FLAG_REMOVE_DEFAULT_IGNORABLES = 0x00000008u,
388
HB_BUFFER_FLAG_DO_NOT_INSERT_DOTTED_CIRCLE = 0x00000010u,
389
HB_BUFFER_FLAG_VERIFY = 0x00000020u,
390
HB_BUFFER_FLAG_PRODUCE_UNSAFE_TO_CONCAT = 0x00000040u,
391
392
HB_BUFFER_FLAG_DEFINED = 0x0000007Fu
393
} hb_buffer_flags_t;
394
395
HB_EXTERN void
396
hb_buffer_set_flags (hb_buffer_t *buffer,
397
hb_buffer_flags_t flags);
398
399
HB_EXTERN hb_buffer_flags_t
400
hb_buffer_get_flags (const hb_buffer_t *buffer);
401
402
/**
403
* hb_buffer_cluster_level_t:
404
* @HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES: Return cluster values grouped by graphemes into
405
* monotone order.
406
* @HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS: Return cluster values grouped into monotone order.
407
* @HB_BUFFER_CLUSTER_LEVEL_CHARACTERS: Don't group cluster values.
408
* @HB_BUFFER_CLUSTER_LEVEL_DEFAULT: Default cluster level,
409
* equal to @HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES.
410
*
411
* Data type for holding HarfBuzz's clustering behavior options. The cluster level
412
* dictates one aspect of how HarfBuzz will treat non-base characters
413
* during shaping.
414
*
415
* In @HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES, non-base
416
* characters are merged into the cluster of the base character that precedes them.
417
*
418
* In @HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS, non-base characters are initially
419
* assigned their own cluster values, which are not merged into preceding base
420
* clusters. This allows HarfBuzz to perform additional operations like reorder
421
* sequences of adjacent marks.
422
*
423
* @HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES is the default, because it maintains
424
* backward compatibility with older versions of HarfBuzz. New client programs that
425
* do not need to maintain such backward compatibility are recommended to use
426
* @HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS instead of the default.
427
*
428
* Since: 0.9.42
429
*/
430
typedef enum {
431
HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES = 0,
432
HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS = 1,
433
HB_BUFFER_CLUSTER_LEVEL_CHARACTERS = 2,
434
HB_BUFFER_CLUSTER_LEVEL_DEFAULT = HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES
435
} hb_buffer_cluster_level_t;
436
437
HB_EXTERN void
438
hb_buffer_set_cluster_level (hb_buffer_t *buffer,
439
hb_buffer_cluster_level_t cluster_level);
440
441
HB_EXTERN hb_buffer_cluster_level_t
442
hb_buffer_get_cluster_level (const hb_buffer_t *buffer);
443
444
/**
445
* HB_BUFFER_REPLACEMENT_CODEPOINT_DEFAULT:
446
*
447
* The default code point for replacing invalid characters in a given encoding.
448
* Set to U+FFFD REPLACEMENT CHARACTER.
449
*
450
* Since: 0.9.31
451
*/
452
#define HB_BUFFER_REPLACEMENT_CODEPOINT_DEFAULT 0xFFFDu
453
454
HB_EXTERN void
455
hb_buffer_set_replacement_codepoint (hb_buffer_t *buffer,
456
hb_codepoint_t replacement);
457
458
HB_EXTERN hb_codepoint_t
459
hb_buffer_get_replacement_codepoint (const hb_buffer_t *buffer);
460
461
HB_EXTERN void
462
hb_buffer_set_invisible_glyph (hb_buffer_t *buffer,
463
hb_codepoint_t invisible);
464
465
HB_EXTERN hb_codepoint_t
466
hb_buffer_get_invisible_glyph (const hb_buffer_t *buffer);
467
468
HB_EXTERN void
469
hb_buffer_set_not_found_glyph (hb_buffer_t *buffer,
470
hb_codepoint_t not_found);
471
472
HB_EXTERN hb_codepoint_t
473
hb_buffer_get_not_found_glyph (const hb_buffer_t *buffer);
474
475
476
/*
477
* Content API.
478
*/
479
480
HB_EXTERN void
481
hb_buffer_clear_contents (hb_buffer_t *buffer);
482
483
HB_EXTERN hb_bool_t
484
hb_buffer_pre_allocate (hb_buffer_t *buffer,
485
unsigned int size);
486
487
488
HB_EXTERN hb_bool_t
489
hb_buffer_allocation_successful (hb_buffer_t *buffer);
490
491
HB_EXTERN void
492
hb_buffer_reverse (hb_buffer_t *buffer);
493
494
HB_EXTERN void
495
hb_buffer_reverse_range (hb_buffer_t *buffer,
496
unsigned int start, unsigned int end);
497
498
HB_EXTERN void
499
hb_buffer_reverse_clusters (hb_buffer_t *buffer);
500
501
502
/* Filling the buffer in */
503
504
HB_EXTERN void
505
hb_buffer_add (hb_buffer_t *buffer,
506
hb_codepoint_t codepoint,
507
unsigned int cluster);
508
509
HB_EXTERN void
510
hb_buffer_add_utf8 (hb_buffer_t *buffer,
511
const char *text,
512
int text_length,
513
unsigned int item_offset,
514
int item_length);
515
516
HB_EXTERN void
517
hb_buffer_add_utf16 (hb_buffer_t *buffer,
518
const uint16_t *text,
519
int text_length,
520
unsigned int item_offset,
521
int item_length);
522
523
HB_EXTERN void
524
hb_buffer_add_utf32 (hb_buffer_t *buffer,
525
const uint32_t *text,
526
int text_length,
527
unsigned int item_offset,
528
int item_length);
529
530
HB_EXTERN void
531
hb_buffer_add_latin1 (hb_buffer_t *buffer,
532
const uint8_t *text,
533
int text_length,
534
unsigned int item_offset,
535
int item_length);
536
537
HB_EXTERN void
538
hb_buffer_add_codepoints (hb_buffer_t *buffer,
539
const hb_codepoint_t *text,
540
int text_length,
541
unsigned int item_offset,
542
int item_length);
543
544
HB_EXTERN void
545
hb_buffer_append (hb_buffer_t *buffer,
546
const hb_buffer_t *source,
547
unsigned int start,
548
unsigned int end);
549
550
HB_EXTERN hb_bool_t
551
hb_buffer_set_length (hb_buffer_t *buffer,
552
unsigned int length);
553
554
HB_EXTERN unsigned int
555
hb_buffer_get_length (const hb_buffer_t *buffer);
556
557
/* Getting glyphs out of the buffer */
558
559
HB_EXTERN hb_glyph_info_t *
560
hb_buffer_get_glyph_infos (hb_buffer_t *buffer,
561
unsigned int *length);
562
563
HB_EXTERN hb_glyph_position_t *
564
hb_buffer_get_glyph_positions (hb_buffer_t *buffer,
565
unsigned int *length);
566
567
HB_EXTERN hb_bool_t
568
hb_buffer_has_positions (hb_buffer_t *buffer);
569
570
571
HB_EXTERN void
572
hb_buffer_normalize_glyphs (hb_buffer_t *buffer);
573
574
575
/*
576
* Serialize
577
*/
578
579
/**
580
* hb_buffer_serialize_flags_t:
581
* @HB_BUFFER_SERIALIZE_FLAG_DEFAULT: serialize glyph names, clusters and positions.
582
* @HB_BUFFER_SERIALIZE_FLAG_NO_CLUSTERS: do not serialize glyph cluster.
583
* @HB_BUFFER_SERIALIZE_FLAG_NO_POSITIONS: do not serialize glyph position information.
584
* @HB_BUFFER_SERIALIZE_FLAG_NO_GLYPH_NAMES: do no serialize glyph name.
585
* @HB_BUFFER_SERIALIZE_FLAG_GLYPH_EXTENTS: serialize glyph extents.
586
* @HB_BUFFER_SERIALIZE_FLAG_GLYPH_FLAGS: serialize glyph flags. Since: 1.5.0
587
* @HB_BUFFER_SERIALIZE_FLAG_NO_ADVANCES: do not serialize glyph advances,
588
* glyph offsets will reflect absolute glyph positions. Since: 1.8.0
589
* @HB_BUFFER_SERIALIZE_FLAG_DEFINED: All currently defined flags. Since: 4.4.0
590
*
591
* Flags that control what glyph information are serialized in hb_buffer_serialize_glyphs().
592
*
593
* Since: 0.9.20
594
*/
595
typedef enum { /*< flags >*/
596
HB_BUFFER_SERIALIZE_FLAG_DEFAULT = 0x00000000u,
597
HB_BUFFER_SERIALIZE_FLAG_NO_CLUSTERS = 0x00000001u,
598
HB_BUFFER_SERIALIZE_FLAG_NO_POSITIONS = 0x00000002u,
599
HB_BUFFER_SERIALIZE_FLAG_NO_GLYPH_NAMES = 0x00000004u,
600
HB_BUFFER_SERIALIZE_FLAG_GLYPH_EXTENTS = 0x00000008u,
601
HB_BUFFER_SERIALIZE_FLAG_GLYPH_FLAGS = 0x00000010u,
602
HB_BUFFER_SERIALIZE_FLAG_NO_ADVANCES = 0x00000020u,
603
604
HB_BUFFER_SERIALIZE_FLAG_DEFINED = 0x0000003Fu
605
} hb_buffer_serialize_flags_t;
606
607
/**
608
* hb_buffer_serialize_format_t:
609
* @HB_BUFFER_SERIALIZE_FORMAT_TEXT: a human-readable, plain text format.
610
* @HB_BUFFER_SERIALIZE_FORMAT_JSON: a machine-readable JSON format.
611
* @HB_BUFFER_SERIALIZE_FORMAT_INVALID: invalid format.
612
*
613
* The buffer serialization and de-serialization format used in
614
* hb_buffer_serialize_glyphs() and hb_buffer_deserialize_glyphs().
615
*
616
* Since: 0.9.2
617
*/
618
typedef enum {
619
HB_BUFFER_SERIALIZE_FORMAT_TEXT = HB_TAG('T','E','X','T'),
620
HB_BUFFER_SERIALIZE_FORMAT_JSON = HB_TAG('J','S','O','N'),
621
HB_BUFFER_SERIALIZE_FORMAT_INVALID = HB_TAG_NONE
622
} hb_buffer_serialize_format_t;
623
624
HB_EXTERN hb_buffer_serialize_format_t
625
hb_buffer_serialize_format_from_string (const char *str, int len);
626
627
HB_EXTERN const char *
628
hb_buffer_serialize_format_to_string (hb_buffer_serialize_format_t format);
629
630
HB_EXTERN const char **
631
hb_buffer_serialize_list_formats (void);
632
633
HB_EXTERN unsigned int
634
hb_buffer_serialize_glyphs (hb_buffer_t *buffer,
635
unsigned int start,
636
unsigned int end,
637
char *buf,
638
unsigned int buf_size,
639
unsigned int *buf_consumed,
640
hb_font_t *font,
641
hb_buffer_serialize_format_t format,
642
hb_buffer_serialize_flags_t flags);
643
644
HB_EXTERN unsigned int
645
hb_buffer_serialize_unicode (hb_buffer_t *buffer,
646
unsigned int start,
647
unsigned int end,
648
char *buf,
649
unsigned int buf_size,
650
unsigned int *buf_consumed,
651
hb_buffer_serialize_format_t format,
652
hb_buffer_serialize_flags_t flags);
653
654
HB_EXTERN unsigned int
655
hb_buffer_serialize (hb_buffer_t *buffer,
656
unsigned int start,
657
unsigned int end,
658
char *buf,
659
unsigned int buf_size,
660
unsigned int *buf_consumed,
661
hb_font_t *font,
662
hb_buffer_serialize_format_t format,
663
hb_buffer_serialize_flags_t flags);
664
665
HB_EXTERN hb_bool_t
666
hb_buffer_deserialize_glyphs (hb_buffer_t *buffer,
667
const char *buf,
668
int buf_len,
669
const char **end_ptr,
670
hb_font_t *font,
671
hb_buffer_serialize_format_t format);
672
673
HB_EXTERN hb_bool_t
674
hb_buffer_deserialize_unicode (hb_buffer_t *buffer,
675
const char *buf,
676
int buf_len,
677
const char **end_ptr,
678
hb_buffer_serialize_format_t format);
679
680
681
682
/*
683
* Compare buffers
684
*/
685
686
/**
687
* hb_buffer_diff_flags_t:
688
* @HB_BUFFER_DIFF_FLAG_EQUAL: equal buffers.
689
* @HB_BUFFER_DIFF_FLAG_CONTENT_TYPE_MISMATCH: buffers with different
690
* #hb_buffer_content_type_t.
691
* @HB_BUFFER_DIFF_FLAG_LENGTH_MISMATCH: buffers with differing length.
692
* @HB_BUFFER_DIFF_FLAG_NOTDEF_PRESENT: `.notdef` glyph is present in the
693
* reference buffer.
694
* @HB_BUFFER_DIFF_FLAG_DOTTED_CIRCLE_PRESENT: dotted circle glyph is present
695
* in the reference buffer.
696
* @HB_BUFFER_DIFF_FLAG_CODEPOINT_MISMATCH: difference in #hb_glyph_info_t.codepoint
697
* @HB_BUFFER_DIFF_FLAG_CLUSTER_MISMATCH: difference in #hb_glyph_info_t.cluster
698
* @HB_BUFFER_DIFF_FLAG_GLYPH_FLAGS_MISMATCH: difference in #hb_glyph_flags_t.
699
* @HB_BUFFER_DIFF_FLAG_POSITION_MISMATCH: difference in #hb_glyph_position_t.
700
*
701
* Flags from comparing two #hb_buffer_t's.
702
*
703
* Buffer with different #hb_buffer_content_type_t cannot be meaningfully
704
* compared in any further detail.
705
*
706
* For buffers with differing length, the per-glyph comparison is not
707
* attempted, though we do still scan reference buffer for dotted circle and
708
* `.notdef` glyphs.
709
*
710
* If the buffers have the same length, we compare them glyph-by-glyph and
711
* report which aspect(s) of the glyph info/position are different.
712
*
713
* Since: 1.5.0
714
*/
715
typedef enum { /*< flags >*/
716
HB_BUFFER_DIFF_FLAG_EQUAL = 0x0000,
717
718
/* Buffers with different content_type cannot be meaningfully compared
719
* in any further detail. */
720
HB_BUFFER_DIFF_FLAG_CONTENT_TYPE_MISMATCH = 0x0001,
721
722
/* For buffers with differing length, the per-glyph comparison is not
723
* attempted, though we do still scan reference for dottedcircle / .notdef
724
* glyphs. */
725
HB_BUFFER_DIFF_FLAG_LENGTH_MISMATCH = 0x0002,
726
727
/* We want to know if dottedcircle / .notdef glyphs are present in the
728
* reference, as we may not care so much about other differences in this
729
* case. */
730
HB_BUFFER_DIFF_FLAG_NOTDEF_PRESENT = 0x0004,
731
HB_BUFFER_DIFF_FLAG_DOTTED_CIRCLE_PRESENT = 0x0008,
732
733
/* If the buffers have the same length, we compare them glyph-by-glyph
734
* and report which aspect(s) of the glyph info/position are different. */
735
HB_BUFFER_DIFF_FLAG_CODEPOINT_MISMATCH = 0x0010,
736
HB_BUFFER_DIFF_FLAG_CLUSTER_MISMATCH = 0x0020,
737
HB_BUFFER_DIFF_FLAG_GLYPH_FLAGS_MISMATCH = 0x0040,
738
HB_BUFFER_DIFF_FLAG_POSITION_MISMATCH = 0x0080
739
740
} hb_buffer_diff_flags_t;
741
742
/* Compare the contents of two buffers, report types of differences. */
743
HB_EXTERN hb_buffer_diff_flags_t
744
hb_buffer_diff (hb_buffer_t *buffer,
745
hb_buffer_t *reference,
746
hb_codepoint_t dottedcircle_glyph,
747
unsigned int position_fuzz);
748
749
750
/*
751
* Debugging.
752
*/
753
754
/**
755
* hb_buffer_message_func_t:
756
* @buffer: An #hb_buffer_t to work upon
757
* @font: The #hb_font_t the @buffer is shaped with
758
* @message: %NULL-terminated message passed to the function
759
* @user_data: User data pointer passed by the caller
760
*
761
* A callback method for #hb_buffer_t. The method gets called with the
762
* #hb_buffer_t it was set on, the #hb_font_t the buffer is shaped with and a
763
* message describing what step of the shaping process will be performed.
764
* Returning %false from this method will skip this shaping step and move to
765
* the next one.
766
*
767
* Return value: %true to perform the shaping step, %false to skip it.
768
*
769
* Since: 1.1.3
770
*/
771
typedef hb_bool_t (*hb_buffer_message_func_t) (hb_buffer_t *buffer,
772
hb_font_t *font,
773
const char *message,
774
void *user_data);
775
776
HB_EXTERN void
777
hb_buffer_set_message_func (hb_buffer_t *buffer,
778
hb_buffer_message_func_t func,
779
void *user_data, hb_destroy_func_t destroy);
780
781
782
HB_END_DECLS
783
784
#endif /* HB_BUFFER_H */
785
786