16 * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 17 * DAMAGE. 18 * 19 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, 20 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 21 * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS 22 * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO 23 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 24 * 25 * Red Hat Author(s): Behdad Esfahbod 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 #elif defined (_MSC_VER) && _MSC_VER < 1600 53 /* VS 2010 (_MSC_VER 1600) has stdint.h */ 54 typedef __int8 int8_t; 55 typedef unsigned __int8 uint8_t; 56 typedef __int16 int16_t; 57 typedef unsigned __int16 uint16_t; 58 typedef __int32 int32_t; 59 typedef unsigned __int32 uint32_t; 60 typedef __int64 int64_t; 61 typedef unsigned __int64 uint64_t; 62 #else 63 # include <stdint.h> 64 #endif 65 66 HB_BEGIN_DECLS 67 68 69 typedef int hb_bool_t; 70 71 typedef uint32_t hb_codepoint_t; 72 typedef int32_t hb_position_t; 73 typedef uint32_t hb_mask_t; 74 75 typedef union _hb_var_int_t { 76 uint32_t u32; 77 int32_t i32; 78 uint16_t u16[2]; 79 int16_t i16[2]; 80 uint8_t u8[4]; 81 int8_t i8[4]; 82 } hb_var_int_t; 83 84 85 /* hb_tag_t */ 86 87 typedef uint32_t hb_tag_t; 88 89 #define HB_TAG(c1,c2,c3,c4) ((hb_tag_t)((((uint8_t)(c1))<<24)|(((uint8_t)(c2))<<16)|(((uint8_t)(c3))<<8)|((uint8_t)(c4)))) 90 #define HB_UNTAG(tag) ((uint8_t)((tag)>>24)), ((uint8_t)((tag)>>16)), ((uint8_t)((tag)>>8)), ((uint8_t)(tag)) 91 92 #define HB_TAG_NONE HB_TAG(0,0,0,0) 93 #define HB_TAG_MAX HB_TAG(0xff,0xff,0xff,0xff) 94 #define HB_TAG_MAX_SIGNED HB_TAG(0x7f,0xff,0xff,0xff) 95 96 /* len=-1 means str is NUL-terminated. */ 97 HB_EXTERN hb_tag_t 98 hb_tag_from_string (const char *str, int len); 99 100 /* buf should have 4 bytes. */ 101 HB_EXTERN void 102 hb_tag_to_string (hb_tag_t tag, char *buf); 103 104 105 /** 106 * hb_direction_t: 107 * @HB_DIRECTION_INVALID: Initial, unset direction. 108 * @HB_DIRECTION_LTR: Text is set horizontally from left to right. 109 * @HB_DIRECTION_RTL: Text is set horizontally from right to left. 110 * @HB_DIRECTION_TTB: Text is set vertically from top to bottom. 323 /*10.0*/HB_SCRIPT_MASARAM_GONDI = HB_TAG ('G','o','n','m'), 324 /*10.0*/HB_SCRIPT_NUSHU = HB_TAG ('N','s','h','u'), 325 /*10.0*/HB_SCRIPT_SOYOMBO = HB_TAG ('S','o','y','o'), 326 /*10.0*/HB_SCRIPT_ZANABAZAR_SQUARE = HB_TAG ('Z','a','n','b'), 327 328 /* 329 * Since 1.8.0 330 */ 331 /*11.0*/HB_SCRIPT_DOGRA = HB_TAG ('D','o','g','r'), 332 /*11.0*/HB_SCRIPT_GUNJALA_GONDI = HB_TAG ('G','o','n','g'), 333 /*11.0*/HB_SCRIPT_HANIFI_ROHINGYA = HB_TAG ('R','o','h','g'), 334 /*11.0*/HB_SCRIPT_MAKASAR = HB_TAG ('M','a','k','a'), 335 /*11.0*/HB_SCRIPT_MEDEFAIDRIN = HB_TAG ('M','e','d','f'), 336 /*11.0*/HB_SCRIPT_OLD_SOGDIAN = HB_TAG ('S','o','g','o'), 337 /*11.0*/HB_SCRIPT_SOGDIAN = HB_TAG ('S','o','g','d'), 338 339 /* No script set. */ 340 HB_SCRIPT_INVALID = HB_TAG_NONE, 341 342 /* Dummy values to ensure any hb_tag_t value can be passed/stored as hb_script_t 343 * without risking undefined behavior. Include both a signed and unsigned max, 344 * since technically enums are int, and indeed, hb_script_t ends up being signed. 345 * See this thread for technicalities: 346 * 347 * https://lists.freedesktop.org/archives/harfbuzz/2014-March/004150.html 348 */ 349 _HB_SCRIPT_MAX_VALUE = HB_TAG_MAX, /*< skip >*/ 350 _HB_SCRIPT_MAX_VALUE_SIGNED = HB_TAG_MAX_SIGNED /*< skip >*/ 351 352 } hb_script_t; 353 354 355 /* Script functions */ 356 357 HB_EXTERN hb_script_t 358 hb_script_from_iso15924_tag (hb_tag_t tag); 359 360 HB_EXTERN hb_script_t 361 hb_script_from_string (const char *str, int len); 362 363 HB_EXTERN hb_tag_t 364 hb_script_to_iso15924_tag (hb_script_t script); 365 366 HB_EXTERN hb_direction_t 367 hb_script_get_horizontal_direction (hb_script_t script); 368 369 370 /* User data */ 371 372 typedef struct hb_user_data_key_t { 373 /*< private >*/ 374 char unused; 375 } hb_user_data_key_t; 376 377 typedef void (*hb_destroy_func_t) (void *user_data); 378 379 380 /* Font features and variations. */ 381 382 typedef struct hb_feature_t { 383 hb_tag_t tag; 384 uint32_t value; 385 unsigned int start; 386 unsigned int end; 387 } hb_feature_t; 388 389 HB_EXTERN hb_bool_t 390 hb_feature_from_string (const char *str, int len, 391 hb_feature_t *feature); 392 393 HB_EXTERN void 394 hb_feature_to_string (hb_feature_t *feature, 395 char *buf, unsigned int size); 396 397 /** 398 * hb_variation_t: 399 * 400 * Since: 1.4.2 401 */ 402 typedef struct hb_variation_t { 403 hb_tag_t tag; 404 float value; 405 } hb_variation_t; 406 407 HB_EXTERN hb_bool_t 408 hb_variation_from_string (const char *str, int len, 409 hb_variation_t *variation); 410 411 HB_EXTERN void 412 hb_variation_to_string (hb_variation_t *variation, 413 char *buf, unsigned int size); 414 415 416 HB_END_DECLS 417 418 #endif /* HB_COMMON_H */ | 16 * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 17 * DAMAGE. 18 * 19 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, 20 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 21 * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS 22 * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO 23 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 24 * 25 * Red Hat Author(s): Behdad Esfahbod 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_EXTERN 37 #define HB_EXTERN extern 38 #endif 39 40 #ifndef HB_BEGIN_DECLS 41 # ifdef __cplusplus 42 # define HB_BEGIN_DECLS extern "C" { 43 # define HB_END_DECLS } 44 # else /* !__cplusplus */ 45 # define HB_BEGIN_DECLS 46 # define HB_END_DECLS 47 # endif /* !__cplusplus */ 48 #endif 49 50 #if defined (_SVR4) || defined (SVR4) || defined (__OpenBSD__) || \ 51 defined (_sgi) || defined (__sun) || defined (sun) || \ 52 defined (__digital__) || defined (__HP_cc) 53 # include <inttypes.h> 54 #elif defined (_AIX) 55 # include <sys/inttypes.h> 56 #elif defined (_MSC_VER) && _MSC_VER < 1600 57 /* VS 2010 (_MSC_VER 1600) has stdint.h */ 58 typedef __int8 int8_t; 59 typedef unsigned __int8 uint8_t; 60 typedef __int16 int16_t; 61 typedef unsigned __int16 uint16_t; 62 typedef __int32 int32_t; 63 typedef unsigned __int32 uint32_t; 64 typedef __int64 int64_t; 65 typedef unsigned __int64 uint64_t; 66 #else 67 # include <stdint.h> 68 #endif 69 70 #if defined(__GNUC__) && ((__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) 71 #define HB_DEPRECATED __attribute__((__deprecated__)) 72 #elif defined(_MSC_VER) && (_MSC_VER >= 1300) 73 #define HB_DEPRECATED __declspec(deprecated) 74 #else 75 #define HB_DEPRECATED 76 #endif 77 78 #if defined(__GNUC__) && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)) 79 #define HB_DEPRECATED_FOR(f) __attribute__((__deprecated__("Use '" #f "' instead"))) 80 #elif defined(_MSC_FULL_VER) && (_MSC_FULL_VER > 140050320) 81 #define HB_DEPRECATED_FOR(f) __declspec(deprecated("is deprecated. Use '" #f "' instead")) 82 #else 83 #define HB_DEPRECATED_FOR(f) HB_DEPRECATED 84 #endif 85 86 87 HB_BEGIN_DECLS 88 89 90 typedef int hb_bool_t; 91 92 typedef uint32_t hb_codepoint_t; 93 typedef int32_t hb_position_t; 94 typedef uint32_t hb_mask_t; 95 96 typedef union _hb_var_int_t { 97 uint32_t u32; 98 int32_t i32; 99 uint16_t u16[2]; 100 int16_t i16[2]; 101 uint8_t u8[4]; 102 int8_t i8[4]; 103 } hb_var_int_t; 104 105 106 /* hb_tag_t */ 107 108 typedef uint32_t hb_tag_t; 109 110 #define HB_TAG(c1,c2,c3,c4) ((hb_tag_t)((((uint32_t)(c1)&0xFF)<<24)|(((uint32_t)(c2)&0xFF)<<16)|(((uint32_t)(c3)&0xFF)<<8)|((uint32_t)(c4)&0xFF))) 111 #define HB_UNTAG(tag) (uint8_t)(((tag)>>24)&0xFF), (uint8_t)(((tag)>>16)&0xFF), (uint8_t)(((tag)>>8)&0xFF), (uint8_t)((tag)&0xFF) 112 113 #define HB_TAG_NONE HB_TAG(0,0,0,0) 114 #define HB_TAG_MAX HB_TAG(0xff,0xff,0xff,0xff) 115 #define HB_TAG_MAX_SIGNED HB_TAG(0x7f,0xff,0xff,0xff) 116 117 /* len=-1 means str is NUL-terminated. */ 118 HB_EXTERN hb_tag_t 119 hb_tag_from_string (const char *str, int len); 120 121 /* buf should have 4 bytes. */ 122 HB_EXTERN void 123 hb_tag_to_string (hb_tag_t tag, char *buf); 124 125 126 /** 127 * hb_direction_t: 128 * @HB_DIRECTION_INVALID: Initial, unset direction. 129 * @HB_DIRECTION_LTR: Text is set horizontally from left to right. 130 * @HB_DIRECTION_RTL: Text is set horizontally from right to left. 131 * @HB_DIRECTION_TTB: Text is set vertically from top to bottom. 344 /*10.0*/HB_SCRIPT_MASARAM_GONDI = HB_TAG ('G','o','n','m'), 345 /*10.0*/HB_SCRIPT_NUSHU = HB_TAG ('N','s','h','u'), 346 /*10.0*/HB_SCRIPT_SOYOMBO = HB_TAG ('S','o','y','o'), 347 /*10.0*/HB_SCRIPT_ZANABAZAR_SQUARE = HB_TAG ('Z','a','n','b'), 348 349 /* 350 * Since 1.8.0 351 */ 352 /*11.0*/HB_SCRIPT_DOGRA = HB_TAG ('D','o','g','r'), 353 /*11.0*/HB_SCRIPT_GUNJALA_GONDI = HB_TAG ('G','o','n','g'), 354 /*11.0*/HB_SCRIPT_HANIFI_ROHINGYA = HB_TAG ('R','o','h','g'), 355 /*11.0*/HB_SCRIPT_MAKASAR = HB_TAG ('M','a','k','a'), 356 /*11.0*/HB_SCRIPT_MEDEFAIDRIN = HB_TAG ('M','e','d','f'), 357 /*11.0*/HB_SCRIPT_OLD_SOGDIAN = HB_TAG ('S','o','g','o'), 358 /*11.0*/HB_SCRIPT_SOGDIAN = HB_TAG ('S','o','g','d'), 359 360 /* No script set. */ 361 HB_SCRIPT_INVALID = HB_TAG_NONE, 362 363 /* Dummy values to ensure any hb_tag_t value can be passed/stored as hb_script_t 364 * without risking undefined behavior. We have two, for historical reasons. 365 * HB_TAG_MAX used to be unsigned, but that was invalid Ansi C, so was changed 366 * to _HB_SCRIPT_MAX_VALUE to be equal to HB_TAG_MAX_SIGNED as well. 367 * 368 * See this thread for technicalities: 369 * 370 * https://lists.freedesktop.org/archives/harfbuzz/2014-March/004150.html 371 */ 372 _HB_SCRIPT_MAX_VALUE = HB_TAG_MAX_SIGNED, /*< skip >*/ 373 _HB_SCRIPT_MAX_VALUE_SIGNED = HB_TAG_MAX_SIGNED /*< skip >*/ 374 375 } hb_script_t; 376 377 378 /* Script functions */ 379 380 HB_EXTERN hb_script_t 381 hb_script_from_iso15924_tag (hb_tag_t tag); 382 383 HB_EXTERN hb_script_t 384 hb_script_from_string (const char *str, int len); 385 386 HB_EXTERN hb_tag_t 387 hb_script_to_iso15924_tag (hb_script_t script); 388 389 HB_EXTERN hb_direction_t 390 hb_script_get_horizontal_direction (hb_script_t script); 391 392 393 /* User data */ 394 395 typedef struct hb_user_data_key_t { 396 /*< private >*/ 397 char unused; 398 } hb_user_data_key_t; 399 400 typedef void (*hb_destroy_func_t) (void *user_data); 401 402 403 /* Font features and variations. */ 404 405 /** 406 * HB_FEATURE_GLOBAL_START 407 * 408 * Since: 2.0.0 409 */ 410 #define HB_FEATURE_GLOBAL_START 0 411 /** 412 * HB_FEATURE_GLOBAL_END 413 * 414 * Since: 2.0.0 415 */ 416 #define HB_FEATURE_GLOBAL_END ((unsigned int) -1) 417 418 typedef struct hb_feature_t { 419 hb_tag_t tag; 420 uint32_t value; 421 unsigned int start; 422 unsigned int end; 423 } hb_feature_t; 424 425 HB_EXTERN hb_bool_t 426 hb_feature_from_string (const char *str, int len, 427 hb_feature_t *feature); 428 429 HB_EXTERN void 430 hb_feature_to_string (hb_feature_t *feature, 431 char *buf, unsigned int size); 432 433 /** 434 * hb_variation_t: 435 * 436 * Since: 1.4.2 437 */ 438 typedef struct hb_variation_t { 439 hb_tag_t tag; 440 float value; 441 } hb_variation_t; 442 443 HB_EXTERN hb_bool_t 444 hb_variation_from_string (const char *str, int len, 445 hb_variation_t *variation); 446 447 HB_EXTERN void 448 hb_variation_to_string (hb_variation_t *variation, 449 char *buf, unsigned int size); 450 451 /** 452 * hb_color_t: 453 * 454 * Data type for holding color values. 455 * 456 * Since: 2.1.0 457 */ 458 typedef uint32_t hb_color_t; 459 460 #define HB_COLOR(b,g,r,a) ((hb_color_t) HB_TAG ((b),(g),(r),(a))) 461 462 /** 463 * hb_color_get_alpha: 464 * 465 * 466 * 467 * Since: 2.1.0 468 */ 469 #define hb_color_get_alpha(color) ((color) & 0xFF) 470 /** 471 * hb_color_get_red: 472 * 473 * 474 * 475 * Since: 2.1.0 476 */ 477 #define hb_color_get_red(color) (((color) >> 8) & 0xFF) 478 /** 479 * hb_color_get_green: 480 * 481 * 482 * 483 * Since: 2.1.0 484 */ 485 #define hb_color_get_green(color) (((color) >> 16) & 0xFF) 486 /** 487 * hb_color_get_blue: 488 * 489 * 490 * 491 * Since: 2.1.0 492 */ 493 #define hb_color_get_blue(color) (((color) >> 24) & 0xFF) 494 495 496 HB_END_DECLS 497 498 #endif /* HB_COMMON_H */ |