Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-17 09:01:46

0001 /*
0002  * Copyright © 2007,2008,2009  Red Hat, Inc.
0003  * Copyright © 2011,2012  Google, Inc.
0004  *
0005  *  This is part of HarfBuzz, a text shaping library.
0006  *
0007  * Permission is hereby granted, without written agreement and without
0008  * license or royalty fees, to use, copy, modify, and distribute this
0009  * software and its documentation for any purpose, provided that the
0010  * above copyright notice and the following two paragraphs appear in
0011  * all copies of this software.
0012  *
0013  * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
0014  * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
0015  * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
0016  * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
0017  * DAMAGE.
0018  *
0019  * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
0020  * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
0021  * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
0022  * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
0023  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
0024  *
0025  * Red Hat Author(s): Behdad Esfahbod
0026  * Google Author(s): Behdad Esfahbod
0027  */
0028 
0029 #if !defined(HB_H_IN) && !defined(HB_NO_SINGLE_HEADER_ERROR)
0030 #error "Include <hb.h> instead."
0031 #endif
0032 
0033 #ifndef HB_COMMON_H
0034 #define HB_COMMON_H
0035 
0036 #ifndef HB_EXTERN
0037 #define HB_EXTERN extern
0038 #endif
0039 
0040 #ifndef HB_BEGIN_DECLS
0041 # ifdef __cplusplus
0042 #  define HB_BEGIN_DECLS    extern "C" {
0043 #  define HB_END_DECLS      }
0044 # else /* !__cplusplus */
0045 #  define HB_BEGIN_DECLS
0046 #  define HB_END_DECLS
0047 # endif /* !__cplusplus */
0048 #endif
0049 
0050 #if defined (_AIX)
0051 #  include <sys/inttypes.h>
0052 #elif defined (_MSC_VER) && _MSC_VER < 1600
0053 /* VS 2010 (_MSC_VER 1600) has stdint.h   */
0054 typedef __int8 int8_t;
0055 typedef unsigned __int8 uint8_t;
0056 typedef __int16 int16_t;
0057 typedef unsigned __int16 uint16_t;
0058 typedef __int32 int32_t;
0059 typedef unsigned __int32 uint32_t;
0060 typedef __int64 int64_t;
0061 typedef unsigned __int64 uint64_t;
0062 #elif defined (_MSC_VER) && _MSC_VER < 1800
0063 /* VS 2013 (_MSC_VER 1800) has inttypes.h */
0064 #  include <stdint.h>
0065 #else
0066 #  include <inttypes.h>
0067 #endif
0068 #include <stddef.h>
0069 
0070 #if defined(__GNUC__) && ((__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
0071 #define HB_DEPRECATED __attribute__((__deprecated__))
0072 #elif defined(_MSC_VER) && (_MSC_VER >= 1300)
0073 #define HB_DEPRECATED __declspec(deprecated)
0074 #else
0075 #define HB_DEPRECATED
0076 #endif
0077 
0078 #if defined(__GNUC__) && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
0079 #define HB_DEPRECATED_FOR(f) __attribute__((__deprecated__("Use '" #f "' instead")))
0080 #elif defined(_MSC_FULL_VER) && (_MSC_FULL_VER > 140050320)
0081 #define HB_DEPRECATED_FOR(f) __declspec(deprecated("is deprecated. Use '" #f "' instead"))
0082 #else
0083 #define HB_DEPRECATED_FOR(f) HB_DEPRECATED
0084 #endif
0085 
0086 
0087 HB_BEGIN_DECLS
0088 
0089 /**
0090  * hb_bool_t:
0091  * 
0092  * Data type for booleans.
0093  *
0094  **/
0095 typedef int hb_bool_t;
0096 
0097 /**
0098  * hb_codepoint_t:
0099  * 
0100  * Data type for holding Unicode codepoints. Also
0101  * used to hold glyph IDs.
0102  *
0103  **/
0104 typedef uint32_t hb_codepoint_t;
0105 
0106 /**
0107  * HB_CODEPOINT_INVALID:
0108  *
0109  * Unused #hb_codepoint_t value.
0110  *
0111  * Since: 8.0.0
0112  */
0113 #define HB_CODEPOINT_INVALID ((hb_codepoint_t) -1)
0114 
0115 /**
0116  * hb_position_t:
0117  * 
0118  * Data type for holding a single coordinate value.
0119  * Contour points and other multi-dimensional data are
0120  * stored as tuples of #hb_position_t's.
0121  *
0122  **/
0123 typedef int32_t hb_position_t;
0124 /**
0125  * hb_mask_t:
0126  * 
0127  * Data type for bitmasks.
0128  *
0129  **/
0130 typedef uint32_t hb_mask_t;
0131 
0132 typedef union _hb_var_int_t {
0133   uint32_t u32;
0134   int32_t i32;
0135   uint16_t u16[2];
0136   int16_t i16[2];
0137   uint8_t u8[4];
0138   int8_t i8[4];
0139 } hb_var_int_t;
0140 
0141 typedef union _hb_var_num_t {
0142   float f;
0143   uint32_t u32;
0144   int32_t i32;
0145   uint16_t u16[2];
0146   int16_t i16[2];
0147   uint8_t u8[4];
0148   int8_t i8[4];
0149 } hb_var_num_t;
0150 
0151 
0152 /* hb_tag_t */
0153 
0154 /**
0155  * hb_tag_t:
0156  *
0157  * Data type for tag identifiers. Tags are four
0158  * byte integers, each byte representing a character.
0159  *
0160  * Tags are used to identify tables, design-variation axes,
0161  * scripts, languages, font features, and baselines with
0162  * human-readable names.
0163  *
0164  **/
0165 typedef uint32_t hb_tag_t;
0166 
0167 /**
0168  * HB_TAG:
0169  * @c1: 1st character of the tag
0170  * @c2: 2nd character of the tag
0171  * @c3: 3rd character of the tag
0172  * @c4: 4th character of the tag
0173  *
0174  * Constructs an #hb_tag_t from four character literals.
0175  *
0176  **/
0177 #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)))
0178 
0179 /**
0180  * HB_UNTAG:
0181  * @tag: an #hb_tag_t
0182  *
0183  * Extracts four character literals from an #hb_tag_t.
0184  *
0185  * Since: 0.6.0
0186  *
0187  **/
0188 #define HB_UNTAG(tag)   (uint8_t)(((tag)>>24)&0xFF), (uint8_t)(((tag)>>16)&0xFF), (uint8_t)(((tag)>>8)&0xFF), (uint8_t)((tag)&0xFF)
0189 
0190 /**
0191  * HB_TAG_NONE:
0192  *
0193  * Unset #hb_tag_t.
0194  */
0195 #define HB_TAG_NONE HB_TAG(0,0,0,0)
0196 /**
0197  * HB_TAG_MAX:
0198  *
0199  * Maximum possible unsigned #hb_tag_t.
0200  *
0201  * Since: 0.9.26
0202  */
0203 #define HB_TAG_MAX HB_TAG(0xff,0xff,0xff,0xff)
0204 /**
0205  * HB_TAG_MAX_SIGNED:
0206  *
0207  * Maximum possible signed #hb_tag_t.
0208  *
0209  * Since: 0.9.33
0210  */
0211 #define HB_TAG_MAX_SIGNED HB_TAG(0x7f,0xff,0xff,0xff)
0212 
0213 /* len=-1 means str is NUL-terminated. */
0214 HB_EXTERN hb_tag_t
0215 hb_tag_from_string (const char *str, int len);
0216 
0217 /* buf should have 4 bytes. */
0218 HB_EXTERN void
0219 hb_tag_to_string (hb_tag_t tag, char *buf);
0220 
0221 
0222 /**
0223  * hb_direction_t:
0224  * @HB_DIRECTION_INVALID: Initial, unset direction.
0225  * @HB_DIRECTION_LTR: Text is set horizontally from left to right.
0226  * @HB_DIRECTION_RTL: Text is set horizontally from right to left.
0227  * @HB_DIRECTION_TTB: Text is set vertically from top to bottom.
0228  * @HB_DIRECTION_BTT: Text is set vertically from bottom to top.
0229  *
0230  * The direction of a text segment or buffer.
0231  * 
0232  * A segment can also be tested for horizontal or vertical
0233  * orientation (irrespective of specific direction) with 
0234  * HB_DIRECTION_IS_HORIZONTAL() or HB_DIRECTION_IS_VERTICAL().
0235  *
0236  */
0237 typedef enum {
0238   HB_DIRECTION_INVALID = 0,
0239   HB_DIRECTION_LTR = 4,
0240   HB_DIRECTION_RTL,
0241   HB_DIRECTION_TTB,
0242   HB_DIRECTION_BTT
0243 } hb_direction_t;
0244 
0245 /* len=-1 means str is NUL-terminated */
0246 HB_EXTERN hb_direction_t
0247 hb_direction_from_string (const char *str, int len);
0248 
0249 HB_EXTERN const char *
0250 hb_direction_to_string (hb_direction_t direction);
0251 
0252 /**
0253  * HB_DIRECTION_IS_VALID:
0254  * @dir: #hb_direction_t to test
0255  *
0256  * Tests whether a text direction is valid.
0257  *
0258  **/
0259 #define HB_DIRECTION_IS_VALID(dir)  ((((unsigned int) (dir)) & ~3U) == 4)
0260 /* Direction must be valid for the following */
0261 /**
0262  * HB_DIRECTION_IS_HORIZONTAL:
0263  * @dir: #hb_direction_t to test
0264  *
0265  * Tests whether a text direction is horizontal. Requires
0266  * that the direction be valid.
0267  *
0268  **/
0269 #define HB_DIRECTION_IS_HORIZONTAL(dir) ((((unsigned int) (dir)) & ~1U) == 4)
0270 /**
0271  * HB_DIRECTION_IS_VERTICAL:
0272  * @dir: #hb_direction_t to test
0273  *
0274  * Tests whether a text direction is vertical. Requires
0275  * that the direction be valid.
0276  *
0277  **/
0278 #define HB_DIRECTION_IS_VERTICAL(dir)   ((((unsigned int) (dir)) & ~1U) == 6)
0279 /**
0280  * HB_DIRECTION_IS_FORWARD:
0281  * @dir: #hb_direction_t to test
0282  *
0283  * Tests whether a text direction moves forward (from left to right, or from
0284  * top to bottom). Requires that the direction be valid.
0285  *
0286  **/
0287 #define HB_DIRECTION_IS_FORWARD(dir)    ((((unsigned int) (dir)) & ~2U) == 4)
0288 /**
0289  * HB_DIRECTION_IS_BACKWARD:
0290  * @dir: #hb_direction_t to test
0291  *
0292  * Tests whether a text direction moves backward (from right to left, or from
0293  * bottom to top). Requires that the direction be valid.
0294  *
0295  **/
0296 #define HB_DIRECTION_IS_BACKWARD(dir)   ((((unsigned int) (dir)) & ~2U) == 5)
0297 /**
0298  * HB_DIRECTION_REVERSE:
0299  * @dir: #hb_direction_t to reverse
0300  *
0301  * Reverses a text direction. Requires that the direction
0302  * be valid.
0303  *
0304  **/
0305 #define HB_DIRECTION_REVERSE(dir)   ((hb_direction_t) (((unsigned int) (dir)) ^ 1))
0306 
0307 
0308 /* hb_language_t */
0309 
0310 /**
0311  * hb_language_t:
0312  *
0313  * Data type for languages. Each #hb_language_t corresponds to a BCP 47
0314  * language tag.
0315  *
0316  */
0317 typedef const struct hb_language_impl_t *hb_language_t;
0318 
0319 HB_EXTERN hb_language_t
0320 hb_language_from_string (const char *str, int len);
0321 
0322 HB_EXTERN const char *
0323 hb_language_to_string (hb_language_t language);
0324 
0325 /**
0326  * HB_LANGUAGE_INVALID:
0327  *
0328  * An unset #hb_language_t.
0329  *
0330  * Since: 0.6.0
0331  */
0332 #define HB_LANGUAGE_INVALID ((hb_language_t) 0)
0333 
0334 HB_EXTERN hb_language_t
0335 hb_language_get_default (void);
0336 
0337 HB_EXTERN hb_bool_t
0338 hb_language_matches (hb_language_t language,
0339              hb_language_t specific);
0340 
0341 #include "hb-script-list.h"
0342 
0343 /* Script functions */
0344 
0345 HB_EXTERN hb_script_t
0346 hb_script_from_iso15924_tag (hb_tag_t tag);
0347 
0348 HB_EXTERN hb_script_t
0349 hb_script_from_string (const char *str, int len);
0350 
0351 HB_EXTERN hb_tag_t
0352 hb_script_to_iso15924_tag (hb_script_t script);
0353 
0354 HB_EXTERN hb_direction_t
0355 hb_script_get_horizontal_direction (hb_script_t script);
0356 
0357 
0358 /* User data */
0359 
0360 /**
0361  * hb_user_data_key_t:
0362  *
0363  * Data structure for holding user-data keys.
0364  *
0365  **/
0366 typedef struct hb_user_data_key_t {
0367   /*< private >*/
0368   char unused;
0369 } hb_user_data_key_t;
0370 
0371 /**
0372  * hb_destroy_func_t:
0373  * @user_data: the data to be destroyed
0374  *
0375  * A virtual method for destroy user-data callbacks.
0376  *
0377  */
0378 typedef void (*hb_destroy_func_t) (void *user_data);
0379 
0380 
0381 /* Font features and variations. */
0382 
0383 /**
0384  * HB_FEATURE_GLOBAL_START:
0385  *
0386  * Special setting for #hb_feature_t.start to apply the feature from the start
0387  * of the buffer.
0388  *
0389  * Since: 2.0.0
0390  */
0391 #define HB_FEATURE_GLOBAL_START 0
0392 
0393 /**
0394  * HB_FEATURE_GLOBAL_END:
0395  *
0396  * Special setting for #hb_feature_t.end to apply the feature from to the end
0397  * of the buffer.
0398  *
0399  * Since: 2.0.0
0400  */
0401 #define HB_FEATURE_GLOBAL_END   ((unsigned int) -1)
0402 
0403 /**
0404  * hb_feature_t:
0405  * @tag: The #hb_tag_t tag of the feature
0406  * @value: The value of the feature. 0 disables the feature, non-zero (usually
0407  * 1) enables the feature.  For features implemented as lookup type 3 (like
0408  * 'salt') the @value is a one based index into the alternates.
0409  * @start: the cluster to start applying this feature setting (inclusive).
0410  * @end: the cluster to end applying this feature setting (exclusive).
0411  *
0412  * The #hb_feature_t is the structure that holds information about requested
0413  * feature application. The feature will be applied with the given value to all
0414  * glyphs which are in clusters between @start (inclusive) and @end (exclusive).
0415  * Setting start to #HB_FEATURE_GLOBAL_START and end to #HB_FEATURE_GLOBAL_END
0416  * specifies that the feature always applies to the entire buffer.
0417  */
0418 typedef struct hb_feature_t {
0419   hb_tag_t      tag;
0420   uint32_t      value;
0421   unsigned int  start;
0422   unsigned int  end;
0423 } hb_feature_t;
0424 
0425 HB_EXTERN hb_bool_t
0426 hb_feature_from_string (const char *str, int len,
0427             hb_feature_t *feature);
0428 
0429 HB_EXTERN void
0430 hb_feature_to_string (hb_feature_t *feature,
0431               char *buf, unsigned int size);
0432 
0433 /**
0434  * hb_variation_t:
0435  * @tag: The #hb_tag_t tag of the variation-axis name
0436  * @value: The value of the variation axis
0437  *
0438  * Data type for holding variation data. Registered OpenType
0439  * variation-axis tags are listed in
0440  * [OpenType Axis Tag Registry](https://docs.microsoft.com/en-us/typography/opentype/spec/dvaraxisreg).
0441  * 
0442  * Since: 1.4.2
0443  */
0444 typedef struct hb_variation_t {
0445   hb_tag_t tag;
0446   float    value;
0447 } hb_variation_t;
0448 
0449 HB_EXTERN hb_bool_t
0450 hb_variation_from_string (const char *str, int len,
0451               hb_variation_t *variation);
0452 
0453 HB_EXTERN void
0454 hb_variation_to_string (hb_variation_t *variation,
0455             char *buf, unsigned int size);
0456 
0457 /**
0458  * hb_color_t:
0459  *
0460  * Data type for holding color values. Colors are eight bits per
0461  * channel RGB plus alpha transparency.
0462  *
0463  * Since: 2.1.0
0464  */
0465 typedef uint32_t hb_color_t;
0466 
0467 /**
0468  * HB_COLOR:
0469  * @b: blue channel value
0470  * @g: green channel value
0471  * @r: red channel value
0472  * @a: alpha channel value
0473  *
0474  * Constructs an #hb_color_t from four integers.
0475  *
0476  * Since: 2.1.0
0477  */
0478 #define HB_COLOR(b,g,r,a) ((hb_color_t) HB_TAG ((b),(g),(r),(a)))
0479 
0480 HB_EXTERN uint8_t
0481 hb_color_get_alpha (hb_color_t color);
0482 #define hb_color_get_alpha(color)   ((color) & 0xFF)
0483 
0484 HB_EXTERN uint8_t
0485 hb_color_get_red (hb_color_t color);
0486 #define hb_color_get_red(color)     (((color) >> 8) & 0xFF)
0487 
0488 HB_EXTERN uint8_t
0489 hb_color_get_green (hb_color_t color);
0490 #define hb_color_get_green(color)   (((color) >> 16) & 0xFF)
0491 
0492 HB_EXTERN uint8_t
0493 hb_color_get_blue (hb_color_t color);
0494 #define hb_color_get_blue(color)    (((color) >> 24) & 0xFF)
0495 
0496 /**
0497  * hb_glyph_extents_t:
0498  * @x_bearing: Distance from the x-origin to the left extremum of the glyph.
0499  * @y_bearing: Distance from the top extremum of the glyph to the y-origin.
0500  * @width: Distance from the left extremum of the glyph to the right extremum.
0501  * @height: Distance from the top extremum of the glyph to the bottom extremum.
0502  *
0503  * Glyph extent values, measured in font units.
0504  *
0505  * Note that @height is negative, in coordinate systems that grow up.
0506  **/
0507 typedef struct hb_glyph_extents_t {
0508   hb_position_t x_bearing;
0509   hb_position_t y_bearing;
0510   hb_position_t width;
0511   hb_position_t height;
0512 } hb_glyph_extents_t;
0513 
0514 /**
0515  * hb_font_t:
0516  *
0517  * Data type for holding fonts.
0518  *
0519  */
0520 typedef struct hb_font_t hb_font_t;
0521 
0522 /* Not of much use to clients. */
0523 HB_EXTERN void*
0524 hb_malloc (size_t size);
0525 HB_EXTERN void*
0526 hb_calloc (size_t nmemb, size_t size);
0527 HB_EXTERN void*
0528 hb_realloc (void *ptr, size_t size);
0529 HB_EXTERN void
0530 hb_free (void *ptr);
0531 
0532 HB_END_DECLS
0533 
0534 #endif /* HB_COMMON_H */