26 * Google Author(s): Behdad Esfahbod
27 */
28
29 #ifndef HB_H_IN
30 #error "Include <hb.h> instead."
31 #endif
32
33 #ifndef HB_COMMON_H
34 #define HB_COMMON_H
35
36 #ifndef HB_BEGIN_DECLS
37 # ifdef __cplusplus
38 # define HB_BEGIN_DECLS extern "C" {
39 # define HB_END_DECLS }
40 # else /* !__cplusplus */
41 # define HB_BEGIN_DECLS
42 # define HB_END_DECLS
43 # endif /* !__cplusplus */
44 #endif
45
46 #if !defined (HB_DONT_DEFINE_STDINT)
47
48 #if defined (_SVR4) || defined (SVR4) || defined (__OpenBSD__) || \
49 defined (_sgi) || defined (__sun) || defined (sun) || \
50 defined (__digital__) || defined (__HP_cc)
51 # include <inttypes.h>
52 #elif defined (_AIX)
53 # include <sys/inttypes.h>
54 /* VS 2010 (_MSC_VER 1600) has stdint.h */
55 #elif defined (_MSC_VER) && _MSC_VER < 1600
56 typedef __int8 int8_t;
57 typedef unsigned __int8 uint8_t;
58 typedef __int16 int16_t;
59 typedef unsigned __int16 uint16_t;
60 typedef __int32 int32_t;
61 typedef unsigned __int32 uint32_t;
62 typedef __int64 int64_t;
63 typedef unsigned __int64 uint64_t;
64 #else
65 # include <stdint.h>
66 #endif
67
68 #endif
69
70 HB_BEGIN_DECLS
71
72
73 typedef int hb_bool_t;
74
75 typedef uint32_t hb_codepoint_t;
76 typedef int32_t hb_position_t;
77 typedef uint32_t hb_mask_t;
78
79 typedef union _hb_var_int_t {
80 uint32_t u32;
81 int32_t i32;
82 uint16_t u16[2];
83 int16_t i16[2];
84 uint8_t u8[4];
85 int8_t i8[4];
86 } hb_var_int_t;
87
88
89 /* hb_tag_t */
131
132 #define HB_DIRECTION_IS_VALID(dir) ((((unsigned int) (dir)) & ~3U) == 4)
133 /* Direction must be valid for the following */
134 #define HB_DIRECTION_IS_HORIZONTAL(dir) ((((unsigned int) (dir)) & ~1U) == 4)
135 #define HB_DIRECTION_IS_VERTICAL(dir) ((((unsigned int) (dir)) & ~1U) == 6)
136 #define HB_DIRECTION_IS_FORWARD(dir) ((((unsigned int) (dir)) & ~2U) == 4)
137 #define HB_DIRECTION_IS_BACKWARD(dir) ((((unsigned int) (dir)) & ~2U) == 5)
138 #define HB_DIRECTION_REVERSE(dir) ((hb_direction_t) (((unsigned int) (dir)) ^ 1))
139
140
141 /* hb_language_t */
142
143 typedef const struct hb_language_impl_t *hb_language_t;
144
145 HB_EXTERN hb_language_t
146 hb_language_from_string (const char *str, int len);
147
148 HB_EXTERN const char *
149 hb_language_to_string (hb_language_t language);
150
151 #define HB_LANGUAGE_INVALID ((hb_language_t) NULL)
152
153 HB_EXTERN hb_language_t
154 hb_language_get_default (void);
155
156
157 /* hb_script_t */
158
159 /* http://unicode.org/iso15924/ */
160 /* http://goo.gl/x9ilM */
161 /* Unicode Character Database property: Script (sc) */
162 typedef enum
163 {
164 /*1.1*/ HB_SCRIPT_COMMON = HB_TAG ('Z','y','y','y'),
165 /*1.1*/ HB_SCRIPT_INHERITED = HB_TAG ('Z','i','n','h'),
166 /*5.0*/ HB_SCRIPT_UNKNOWN = HB_TAG ('Z','z','z','z'),
167
168 /*1.1*/ HB_SCRIPT_ARABIC = HB_TAG ('A','r','a','b'),
169 /*1.1*/ HB_SCRIPT_ARMENIAN = HB_TAG ('A','r','m','n'),
170 /*1.1*/ HB_SCRIPT_BENGALI = HB_TAG ('B','e','n','g'),
171 /*1.1*/ HB_SCRIPT_CYRILLIC = HB_TAG ('C','y','r','l'),
304 /*7.0*/ HB_SCRIPT_TIRHUTA = HB_TAG ('T','i','r','h'),
305 /*7.0*/ HB_SCRIPT_WARANG_CITI = HB_TAG ('W','a','r','a'),
306
307 /*8.0*/ HB_SCRIPT_AHOM = HB_TAG ('A','h','o','m'),
308 /*8.0*/ HB_SCRIPT_ANATOLIAN_HIEROGLYPHS = HB_TAG ('H','l','u','w'),
309 /*8.0*/ HB_SCRIPT_HATRAN = HB_TAG ('H','a','t','r'),
310 /*8.0*/ HB_SCRIPT_MULTANI = HB_TAG ('M','u','l','t'),
311 /*8.0*/ HB_SCRIPT_OLD_HUNGARIAN = HB_TAG ('H','u','n','g'),
312 /*8.0*/ HB_SCRIPT_SIGNWRITING = HB_TAG ('S','g','n','w'),
313
314 /*
315 * Since 1.3.0
316 */
317 /*9.0*/ HB_SCRIPT_ADLAM = HB_TAG ('A','d','l','m'),
318 /*9.0*/ HB_SCRIPT_BHAIKSUKI = HB_TAG ('B','h','k','s'),
319 /*9.0*/ HB_SCRIPT_MARCHEN = HB_TAG ('M','a','r','c'),
320 /*9.0*/ HB_SCRIPT_OSAGE = HB_TAG ('O','s','g','e'),
321 /*9.0*/ HB_SCRIPT_TANGUT = HB_TAG ('T','a','n','g'),
322 /*9.0*/ HB_SCRIPT_NEWA = HB_TAG ('N','e','w','a'),
323
324 /* No script set. */
325 HB_SCRIPT_INVALID = HB_TAG_NONE,
326
327 /* Dummy values to ensure any hb_tag_t value can be passed/stored as hb_script_t
328 * without risking undefined behavior. Include both a signed and unsigned max,
329 * since technically enums are int, and indeed, hb_script_t ends up being signed.
330 * See this thread for technicalities:
331 *
332 * http://lists.freedesktop.org/archives/harfbuzz/2014-March/004150.html
333 */
334 _HB_SCRIPT_MAX_VALUE = HB_TAG_MAX, /*< skip >*/
335 _HB_SCRIPT_MAX_VALUE_SIGNED = HB_TAG_MAX_SIGNED /*< skip >*/
336
337 } hb_script_t;
338
339
340 /* Script functions */
341
342 HB_EXTERN hb_script_t
343 hb_script_from_iso15924_tag (hb_tag_t tag);
344
345 HB_EXTERN hb_script_t
346 hb_script_from_string (const char *str, int len);
347
348 HB_EXTERN hb_tag_t
349 hb_script_to_iso15924_tag (hb_script_t script);
350
351 HB_EXTERN hb_direction_t
352 hb_script_get_horizontal_direction (hb_script_t script);
353
354
355 /* User data */
356
357 typedef struct hb_user_data_key_t {
358 /*< private >*/
359 char unused;
360 } hb_user_data_key_t;
361
362 typedef void (*hb_destroy_func_t) (void *user_data);
363
364
365 HB_END_DECLS
366
367 #endif /* HB_COMMON_H */
|
26 * Google Author(s): Behdad Esfahbod
27 */
28
29 #ifndef HB_H_IN
30 #error "Include <hb.h> instead."
31 #endif
32
33 #ifndef HB_COMMON_H
34 #define HB_COMMON_H
35
36 #ifndef HB_BEGIN_DECLS
37 # ifdef __cplusplus
38 # define HB_BEGIN_DECLS extern "C" {
39 # define HB_END_DECLS }
40 # else /* !__cplusplus */
41 # define HB_BEGIN_DECLS
42 # define HB_END_DECLS
43 # endif /* !__cplusplus */
44 #endif
45
46 #if defined (_SVR4) || defined (SVR4) || defined (__OpenBSD__) || \
47 defined (_sgi) || defined (__sun) || defined (sun) || \
48 defined (__digital__) || defined (__HP_cc)
49 # include <inttypes.h>
50 #elif defined (_AIX)
51 # include <sys/inttypes.h>
52 #else
53 # include <stdint.h>
54 #endif
55
56 HB_BEGIN_DECLS
57
58
59 typedef int hb_bool_t;
60
61 typedef uint32_t hb_codepoint_t;
62 typedef int32_t hb_position_t;
63 typedef uint32_t hb_mask_t;
64
65 typedef union _hb_var_int_t {
66 uint32_t u32;
67 int32_t i32;
68 uint16_t u16[2];
69 int16_t i16[2];
70 uint8_t u8[4];
71 int8_t i8[4];
72 } hb_var_int_t;
73
74
75 /* hb_tag_t */
117
118 #define HB_DIRECTION_IS_VALID(dir) ((((unsigned int) (dir)) & ~3U) == 4)
119 /* Direction must be valid for the following */
120 #define HB_DIRECTION_IS_HORIZONTAL(dir) ((((unsigned int) (dir)) & ~1U) == 4)
121 #define HB_DIRECTION_IS_VERTICAL(dir) ((((unsigned int) (dir)) & ~1U) == 6)
122 #define HB_DIRECTION_IS_FORWARD(dir) ((((unsigned int) (dir)) & ~2U) == 4)
123 #define HB_DIRECTION_IS_BACKWARD(dir) ((((unsigned int) (dir)) & ~2U) == 5)
124 #define HB_DIRECTION_REVERSE(dir) ((hb_direction_t) (((unsigned int) (dir)) ^ 1))
125
126
127 /* hb_language_t */
128
129 typedef const struct hb_language_impl_t *hb_language_t;
130
131 HB_EXTERN hb_language_t
132 hb_language_from_string (const char *str, int len);
133
134 HB_EXTERN const char *
135 hb_language_to_string (hb_language_t language);
136
137 #define HB_LANGUAGE_INVALID ((hb_language_t) 0)
138
139 HB_EXTERN hb_language_t
140 hb_language_get_default (void);
141
142
143 /* hb_script_t */
144
145 /* http://unicode.org/iso15924/ */
146 /* http://goo.gl/x9ilM */
147 /* Unicode Character Database property: Script (sc) */
148 typedef enum
149 {
150 /*1.1*/ HB_SCRIPT_COMMON = HB_TAG ('Z','y','y','y'),
151 /*1.1*/ HB_SCRIPT_INHERITED = HB_TAG ('Z','i','n','h'),
152 /*5.0*/ HB_SCRIPT_UNKNOWN = HB_TAG ('Z','z','z','z'),
153
154 /*1.1*/ HB_SCRIPT_ARABIC = HB_TAG ('A','r','a','b'),
155 /*1.1*/ HB_SCRIPT_ARMENIAN = HB_TAG ('A','r','m','n'),
156 /*1.1*/ HB_SCRIPT_BENGALI = HB_TAG ('B','e','n','g'),
157 /*1.1*/ HB_SCRIPT_CYRILLIC = HB_TAG ('C','y','r','l'),
290 /*7.0*/ HB_SCRIPT_TIRHUTA = HB_TAG ('T','i','r','h'),
291 /*7.0*/ HB_SCRIPT_WARANG_CITI = HB_TAG ('W','a','r','a'),
292
293 /*8.0*/ HB_SCRIPT_AHOM = HB_TAG ('A','h','o','m'),
294 /*8.0*/ HB_SCRIPT_ANATOLIAN_HIEROGLYPHS = HB_TAG ('H','l','u','w'),
295 /*8.0*/ HB_SCRIPT_HATRAN = HB_TAG ('H','a','t','r'),
296 /*8.0*/ HB_SCRIPT_MULTANI = HB_TAG ('M','u','l','t'),
297 /*8.0*/ HB_SCRIPT_OLD_HUNGARIAN = HB_TAG ('H','u','n','g'),
298 /*8.0*/ HB_SCRIPT_SIGNWRITING = HB_TAG ('S','g','n','w'),
299
300 /*
301 * Since 1.3.0
302 */
303 /*9.0*/ HB_SCRIPT_ADLAM = HB_TAG ('A','d','l','m'),
304 /*9.0*/ HB_SCRIPT_BHAIKSUKI = HB_TAG ('B','h','k','s'),
305 /*9.0*/ HB_SCRIPT_MARCHEN = HB_TAG ('M','a','r','c'),
306 /*9.0*/ HB_SCRIPT_OSAGE = HB_TAG ('O','s','g','e'),
307 /*9.0*/ HB_SCRIPT_TANGUT = HB_TAG ('T','a','n','g'),
308 /*9.0*/ HB_SCRIPT_NEWA = HB_TAG ('N','e','w','a'),
309
310 /*
311 * Since 1.6.0
312 */
313 /*10.0*/HB_SCRIPT_MASARAM_GONDI = HB_TAG ('G','o','n','m'),
314 /*10.0*/HB_SCRIPT_NUSHU = HB_TAG ('N','s','h','u'),
315 /*10.0*/HB_SCRIPT_SOYOMBO = HB_TAG ('S','o','y','o'),
316 /*10.0*/HB_SCRIPT_ZANABAZAR_SQUARE = HB_TAG ('Z','a','n','b'),
317
318 /* No script set. */
319 HB_SCRIPT_INVALID = HB_TAG_NONE,
320
321 /* Dummy values to ensure any hb_tag_t value can be passed/stored as hb_script_t
322 * without risking undefined behavior. Include both a signed and unsigned max,
323 * since technically enums are int, and indeed, hb_script_t ends up being signed.
324 * See this thread for technicalities:
325 *
326 * http://lists.freedesktop.org/archives/harfbuzz/2014-March/004150.html
327 */
328 _HB_SCRIPT_MAX_VALUE = HB_TAG_MAX, /*< skip >*/
329 _HB_SCRIPT_MAX_VALUE_SIGNED = HB_TAG_MAX_SIGNED /*< skip >*/
330
331 } hb_script_t;
332
333
334 /* Script functions */
335
336 HB_EXTERN hb_script_t
337 hb_script_from_iso15924_tag (hb_tag_t tag);
338
339 HB_EXTERN hb_script_t
340 hb_script_from_string (const char *str, int len);
341
342 HB_EXTERN hb_tag_t
343 hb_script_to_iso15924_tag (hb_script_t script);
344
345 HB_EXTERN hb_direction_t
346 hb_script_get_horizontal_direction (hb_script_t script);
347
348
349 /* User data */
350
351 typedef struct hb_user_data_key_t {
352 /*< private >*/
353 char unused;
354 } hb_user_data_key_t;
355
356 typedef void (*hb_destroy_func_t) (void *user_data);
357
358
359 /* Font features and variations. */
360
361 typedef struct hb_feature_t {
362 hb_tag_t tag;
363 uint32_t value;
364 unsigned int start;
365 unsigned int end;
366 } hb_feature_t;
367
368 HB_EXTERN hb_bool_t
369 hb_feature_from_string (const char *str, int len,
370 hb_feature_t *feature);
371
372 HB_EXTERN void
373 hb_feature_to_string (hb_feature_t *feature,
374 char *buf, unsigned int size);
375
376 /**
377 * hb_variation_t:
378 *
379 * Since: 1.4.2
380 */
381 typedef struct hb_variation_t {
382 hb_tag_t tag;
383 float value;
384 } hb_variation_t;
385
386 HB_EXTERN hb_bool_t
387 hb_variation_from_string (const char *str, int len,
388 hb_variation_t *variation);
389
390 HB_EXTERN void
391 hb_variation_to_string (hb_variation_t *variation,
392 char *buf, unsigned int size);
393
394
395 HB_END_DECLS
396
397 #endif /* HB_COMMON_H */
|