hb-common.h revision 6cb8c3493019e1497921666fc268cb81943f9f1f
164aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod/*
26c78683c042250a7b5a6fc6ebae4717b03fadf9eBehdad Esfahbod * Copyright (C) 2007,2008,2009  Red Hat, Inc.
364aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod *
4c755cb3e3ac55156d0d2ec05adea7a650b97cc41Behdad Esfahbod *  This is part of HarfBuzz, a text shaping library.
564aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod *
664aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod * Permission is hereby granted, without written agreement and without
764aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod * license or royalty fees, to use, copy, modify, and distribute this
864aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod * software and its documentation for any purpose, provided that the
964aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod * above copyright notice and the following two paragraphs appear in
1064aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod * all copies of this software.
1164aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod *
1264aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
1364aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
1464aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
1564aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
1664aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod * DAMAGE.
1764aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod *
1864aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
1964aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
2064aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
2164aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
2264aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
2364aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod *
2464aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod * Red Hat Author(s): Behdad Esfahbod
2564aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod */
2664aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod
278dd1c8b8d6797d899d0f5b0a8015886bf6520ca2Behdad Esfahbod#ifndef HB_COMMON_H
288dd1c8b8d6797d899d0f5b0a8015886bf6520ca2Behdad Esfahbod#define HB_COMMON_H
298dd1c8b8d6797d899d0f5b0a8015886bf6520ca2Behdad Esfahbod
30acdba3f90b232fc12fcb200dca2584481b339118Behdad Esfahbod# ifdef __cplusplus
31acdba3f90b232fc12fcb200dca2584481b339118Behdad Esfahbod#  define HB_BEGIN_DECLS	extern "C" {
32acdba3f90b232fc12fcb200dca2584481b339118Behdad Esfahbod#  define HB_END_DECLS		}
33acdba3f90b232fc12fcb200dca2584481b339118Behdad Esfahbod# else /* !__cplusplus */
34acdba3f90b232fc12fcb200dca2584481b339118Behdad Esfahbod#  define HB_BEGIN_DECLS
35acdba3f90b232fc12fcb200dca2584481b339118Behdad Esfahbod#  define HB_END_DECLS
36acdba3f90b232fc12fcb200dca2584481b339118Behdad Esfahbod# endif /* !__cplusplus */
37acdba3f90b232fc12fcb200dca2584481b339118Behdad Esfahbod
38acdba3f90b232fc12fcb200dca2584481b339118Behdad EsfahbodHB_BEGIN_DECLS
39acdba3f90b232fc12fcb200dca2584481b339118Behdad Esfahbod
40acdba3f90b232fc12fcb200dca2584481b339118Behdad Esfahbod
41cc4c096a7e08ae96b3030fe27f871ce5b797f370Behdad Esfahbod#ifdef _MSC_VER
42cd7555eef27cb18857c0c06d2afdaf3a354a3c15Behdad Esfahbod#define _HB__STR2__(x) #x
43cd7555eef27cb18857c0c06d2afdaf3a354a3c15Behdad Esfahbod#define _HB__STR1__(x) _HB__STR2__(x)
44cd7555eef27cb18857c0c06d2afdaf3a354a3c15Behdad Esfahbod#define _HB__LOC__ __FILE__ "("_HB__STR1__(__LINE__)") : Warning Msg: "
45cd7555eef27cb18857c0c06d2afdaf3a354a3c15Behdad Esfahbod#pragma message(_HB__LOC__"Not using stdint.h; integer types may have wrong size")
46cc4c096a7e08ae96b3030fe27f871ce5b797f370Behdad Esfahbodtypedef signed char int8_t;
47cc4c096a7e08ae96b3030fe27f871ce5b797f370Behdad Esfahbodtypedef unsigned char uint8_t;
48cc4c096a7e08ae96b3030fe27f871ce5b797f370Behdad Esfahbodtypedef signed short int16_t;
49cc4c096a7e08ae96b3030fe27f871ce5b797f370Behdad Esfahbodtypedef unsigned short uint16_t;
50cc4c096a7e08ae96b3030fe27f871ce5b797f370Behdad Esfahbodtypedef signed int int32_t;
51cc4c096a7e08ae96b3030fe27f871ce5b797f370Behdad Esfahbodtypedef unsigned int uint32_t;
52ffbe0a853d5e7defa85d0eef53814c22d1ecb412Behdad Esfahbodtypedef signed long long int64_t;
53ffbe0a853d5e7defa85d0eef53814c22d1ecb412Behdad Esfahbodtypedef unsigned long long uint64_t;
54cc4c096a7e08ae96b3030fe27f871ce5b797f370Behdad Esfahbod#ifndef __cplusplus
55cc4c096a7e08ae96b3030fe27f871ce5b797f370Behdad Esfahbod#define inline __inline
56cc4c096a7e08ae96b3030fe27f871ce5b797f370Behdad Esfahbod#endif
57cc4c096a7e08ae96b3030fe27f871ce5b797f370Behdad Esfahbod#else
588dd1c8b8d6797d899d0f5b0a8015886bf6520ca2Behdad Esfahbod#include <stdint.h>
59cc4c096a7e08ae96b3030fe27f871ce5b797f370Behdad Esfahbod#endif
608dd1c8b8d6797d899d0f5b0a8015886bf6520ca2Behdad Esfahbod
61590d55cbb9e21ef74dfd88eee51fd0a763958cd2Behdad Esfahbodtypedef int hb_bool_t;
62590d55cbb9e21ef74dfd88eee51fd0a763958cd2Behdad Esfahbod
63590d55cbb9e21ef74dfd88eee51fd0a763958cd2Behdad Esfahbodtypedef uint32_t hb_tag_t;
64590d55cbb9e21ef74dfd88eee51fd0a763958cd2Behdad Esfahbod#define HB_TAG(a,b,c,d) ((hb_tag_t)(((uint8_t)a<<24)|((uint8_t)b<<16)|((uint8_t)c<<8)|(uint8_t)d))
65590d55cbb9e21ef74dfd88eee51fd0a763958cd2Behdad Esfahbod#define HB_TAG_STR(s)   (HB_TAG(((const char *) s)[0], \
66590d55cbb9e21ef74dfd88eee51fd0a763958cd2Behdad Esfahbod				((const char *) s)[1], \
67590d55cbb9e21ef74dfd88eee51fd0a763958cd2Behdad Esfahbod				((const char *) s)[2], \
68590d55cbb9e21ef74dfd88eee51fd0a763958cd2Behdad Esfahbod				((const char *) s)[3]))
690ead481a5a8623103565fd7d924666e7342278ddBehdad Esfahbod#define HB_TAG_NONE HB_TAG(0,0,0,0)
70590d55cbb9e21ef74dfd88eee51fd0a763958cd2Behdad Esfahbod
7183f34677bcbc6bb194940407b0fcb23575650e3dBehdad Esfahbodhb_tag_t hb_tag_from_string (const char *s);
7283f34677bcbc6bb194940407b0fcb23575650e3dBehdad Esfahbod
7383f34677bcbc6bb194940407b0fcb23575650e3dBehdad Esfahbod
742d15e72c75931398db5e027e660f1320bb979117Behdad Esfahbodtypedef uint32_t hb_codepoint_t;
75c7d457aa3ae7138630f52ca7263f663a3ea284c0Behdad Esfahbodtypedef int32_t hb_position_t;
76468769b8f5332940278244e744ec2bd5a5dc5ee9Behdad Esfahbodtypedef uint32_t hb_mask_t;
77590d55cbb9e21ef74dfd88eee51fd0a763958cd2Behdad Esfahbod
780090dc0f67b553d2f6eaaedc289c0956ade09ef6Behdad Esfahbodtypedef void (*hb_destroy_func_t) (void *user_data);
790090dc0f67b553d2f6eaaedc289c0956ade09ef6Behdad Esfahbod
80ff44f88df2c46920f3ec2384ef321a4c7bb0f6efBehdad Esfahbodtypedef enum _hb_direction_t {
81ff44f88df2c46920f3ec2384ef321a4c7bb0f6efBehdad Esfahbod  HB_DIRECTION_LTR,
82ff44f88df2c46920f3ec2384ef321a4c7bb0f6efBehdad Esfahbod  HB_DIRECTION_RTL,
83ff44f88df2c46920f3ec2384ef321a4c7bb0f6efBehdad Esfahbod  HB_DIRECTION_TTB,
84ff44f88df2c46920f3ec2384ef321a4c7bb0f6efBehdad Esfahbod  HB_DIRECTION_BTT
85ff44f88df2c46920f3ec2384ef321a4c7bb0f6efBehdad Esfahbod} hb_direction_t;
86ff44f88df2c46920f3ec2384ef321a4c7bb0f6efBehdad Esfahbod
871ce4dc95dbb28842085342aea4f9d12cbe9671a9Behdad Esfahbod#define HB_DIRECTION_IS_HORIZONTAL(dir)	((((unsigned int) (dir)) & ~1U) == 0)
881ce4dc95dbb28842085342aea4f9d12cbe9671a9Behdad Esfahbod#define HB_DIRECTION_IS_VERTICAL(dir)	((((unsigned int) (dir)) & ~1U) == 2)
891ce4dc95dbb28842085342aea4f9d12cbe9671a9Behdad Esfahbod#define HB_DIRECTION_IS_FORWARD(dir)	((((unsigned int) (dir)) & ~2U) == 0)
901ce4dc95dbb28842085342aea4f9d12cbe9671a9Behdad Esfahbod#define HB_DIRECTION_IS_BACKWARD(dir)	((((unsigned int) (dir)) & ~2U) == 1)
9122da7fd94d6318c52df69d70470a85464ffc533dBehdad Esfahbod#define HB_DIRECTION_REVERSE(dir)	((hb_direction_t) (((unsigned int) (dir)) ^ 1))
92ff44f88df2c46920f3ec2384ef321a4c7bb0f6efBehdad Esfahbod
93ff44f88df2c46920f3ec2384ef321a4c7bb0f6efBehdad Esfahbod
946cb8c3493019e1497921666fc268cb81943f9f1fBehdad Esfahbodtypedef union _hb_var_int_t {
956cb8c3493019e1497921666fc268cb81943f9f1fBehdad Esfahbod  uint32_t u32;
966cb8c3493019e1497921666fc268cb81943f9f1fBehdad Esfahbod  int32_t i32;
976cb8c3493019e1497921666fc268cb81943f9f1fBehdad Esfahbod  uint16_t u16[2];
986cb8c3493019e1497921666fc268cb81943f9f1fBehdad Esfahbod  int16_t i16[2];
996cb8c3493019e1497921666fc268cb81943f9f1fBehdad Esfahbod  uint8_t u8[4];
1006cb8c3493019e1497921666fc268cb81943f9f1fBehdad Esfahbod  int8_t i8[4];
1016cb8c3493019e1497921666fc268cb81943f9f1fBehdad Esfahbod} hb_var_int_t;
1026cb8c3493019e1497921666fc268cb81943f9f1fBehdad Esfahbod
1036cb8c3493019e1497921666fc268cb81943f9f1fBehdad Esfahbod
104acdba3f90b232fc12fcb200dca2584481b339118Behdad EsfahbodHB_END_DECLS
105acdba3f90b232fc12fcb200dca2584481b339118Behdad Esfahbod
1068dd1c8b8d6797d899d0f5b0a8015886bf6520ca2Behdad Esfahbod#endif /* HB_COMMON_H */
107