src/java.desktop/share/native/libfontmanager/harfbuzz/hb-common.h
changeset 54232 7c11a7cc7c1d
parent 50826 f5b95be8b6e2
equal deleted inserted replaced
54231:e4813eded7cb 54232:7c11a7cc7c1d
    30 #error "Include <hb.h> instead."
    30 #error "Include <hb.h> instead."
    31 #endif
    31 #endif
    32 
    32 
    33 #ifndef HB_COMMON_H
    33 #ifndef HB_COMMON_H
    34 #define HB_COMMON_H
    34 #define HB_COMMON_H
       
    35 
       
    36 #ifndef HB_EXTERN
       
    37 #define HB_EXTERN extern
       
    38 #endif
    35 
    39 
    36 #ifndef HB_BEGIN_DECLS
    40 #ifndef HB_BEGIN_DECLS
    37 # ifdef __cplusplus
    41 # ifdef __cplusplus
    38 #  define HB_BEGIN_DECLS        extern "C" {
    42 #  define HB_BEGIN_DECLS        extern "C" {
    39 #  define HB_END_DECLS          }
    43 #  define HB_END_DECLS          }
    61 typedef unsigned __int64 uint64_t;
    65 typedef unsigned __int64 uint64_t;
    62 #else
    66 #else
    63 #  include <stdint.h>
    67 #  include <stdint.h>
    64 #endif
    68 #endif
    65 
    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 
    66 HB_BEGIN_DECLS
    87 HB_BEGIN_DECLS
    67 
    88 
    68 
    89 
    69 typedef int hb_bool_t;
    90 typedef int hb_bool_t;
    70 
    91 
    84 
   105 
    85 /* hb_tag_t */
   106 /* hb_tag_t */
    86 
   107 
    87 typedef uint32_t hb_tag_t;
   108 typedef uint32_t hb_tag_t;
    88 
   109 
    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))))
   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)))
    90 #define HB_UNTAG(tag)   ((uint8_t)((tag)>>24)), ((uint8_t)((tag)>>16)), ((uint8_t)((tag)>>8)), ((uint8_t)(tag))
   111 #define HB_UNTAG(tag)   (uint8_t)(((tag)>>24)&0xFF), (uint8_t)(((tag)>>16)&0xFF), (uint8_t)(((tag)>>8)&0xFF), (uint8_t)((tag)&0xFF)
    91 
   112 
    92 #define HB_TAG_NONE HB_TAG(0,0,0,0)
   113 #define HB_TAG_NONE HB_TAG(0,0,0,0)
    93 #define HB_TAG_MAX HB_TAG(0xff,0xff,0xff,0xff)
   114 #define HB_TAG_MAX HB_TAG(0xff,0xff,0xff,0xff)
    94 #define HB_TAG_MAX_SIGNED HB_TAG(0x7f,0xff,0xff,0xff)
   115 #define HB_TAG_MAX_SIGNED HB_TAG(0x7f,0xff,0xff,0xff)
    95 
   116 
   338 
   359 
   339   /* No script set. */
   360   /* No script set. */
   340   HB_SCRIPT_INVALID                             = HB_TAG_NONE,
   361   HB_SCRIPT_INVALID                             = HB_TAG_NONE,
   341 
   362 
   342   /* Dummy values to ensure any hb_tag_t value can be passed/stored as hb_script_t
   363   /* 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,
   364    * without risking undefined behavior.  We have two, for historical reasons.
   344    * since technically enums are int, and indeed, hb_script_t ends up being signed.
   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    *
   345    * See this thread for technicalities:
   368    * See this thread for technicalities:
   346    *
   369    *
   347    *   https://lists.freedesktop.org/archives/harfbuzz/2014-March/004150.html
   370    *   https://lists.freedesktop.org/archives/harfbuzz/2014-March/004150.html
   348    */
   371    */
   349   _HB_SCRIPT_MAX_VALUE                          = HB_TAG_MAX, /*< skip >*/
   372   _HB_SCRIPT_MAX_VALUE                          = HB_TAG_MAX_SIGNED, /*< skip >*/
   350   _HB_SCRIPT_MAX_VALUE_SIGNED                   = HB_TAG_MAX_SIGNED /*< skip >*/
   373   _HB_SCRIPT_MAX_VALUE_SIGNED                   = HB_TAG_MAX_SIGNED /*< skip >*/
   351 
   374 
   352 } hb_script_t;
   375 } hb_script_t;
   353 
   376 
   354 
   377 
   376 
   399 
   377 typedef void (*hb_destroy_func_t) (void *user_data);
   400 typedef void (*hb_destroy_func_t) (void *user_data);
   378 
   401 
   379 
   402 
   380 /* Font features and variations. */
   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)
   381 
   417 
   382 typedef struct hb_feature_t {
   418 typedef struct hb_feature_t {
   383   hb_tag_t      tag;
   419   hb_tag_t      tag;
   384   uint32_t      value;
   420   uint32_t      value;
   385   unsigned int  start;
   421   unsigned int  start;
   410 
   446 
   411 HB_EXTERN void
   447 HB_EXTERN void
   412 hb_variation_to_string (hb_variation_t *variation,
   448 hb_variation_to_string (hb_variation_t *variation,
   413                         char *buf, unsigned int size);
   449                         char *buf, unsigned int size);
   414 
   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 
   415 
   495 
   416 HB_END_DECLS
   496 HB_END_DECLS
   417 
   497 
   418 #endif /* HB_COMMON_H */
   498 #endif /* HB_COMMON_H */