hb-common.h revision 3cbdf70e0a92f1c24e16c0d4dcfbec4ac59a77a3
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 42cc4c096a7e08ae96b3030fe27f871ce5b797f370Behdad Esfahbodtypedef signed char int8_t; 43cc4c096a7e08ae96b3030fe27f871ce5b797f370Behdad Esfahbodtypedef unsigned char uint8_t; 44cc4c096a7e08ae96b3030fe27f871ce5b797f370Behdad Esfahbodtypedef signed short int16_t; 45cc4c096a7e08ae96b3030fe27f871ce5b797f370Behdad Esfahbodtypedef unsigned short uint16_t; 46cc4c096a7e08ae96b3030fe27f871ce5b797f370Behdad Esfahbodtypedef signed int int32_t; 47cc4c096a7e08ae96b3030fe27f871ce5b797f370Behdad Esfahbodtypedef unsigned int uint32_t; 48ffbe0a853d5e7defa85d0eef53814c22d1ecb412Behdad Esfahbodtypedef signed long long int64_t; 49ffbe0a853d5e7defa85d0eef53814c22d1ecb412Behdad Esfahbodtypedef unsigned long long uint64_t; 50cc4c096a7e08ae96b3030fe27f871ce5b797f370Behdad Esfahbod#else 518dd1c8b8d6797d899d0f5b0a8015886bf6520ca2Behdad Esfahbod#include <stdint.h> 52cc4c096a7e08ae96b3030fe27f871ce5b797f370Behdad Esfahbod#endif 538dd1c8b8d6797d899d0f5b0a8015886bf6520ca2Behdad Esfahbod 54590d55cbb9e21ef74dfd88eee51fd0a763958cd2Behdad Esfahbodtypedef int hb_bool_t; 55590d55cbb9e21ef74dfd88eee51fd0a763958cd2Behdad Esfahbod 568e4bb3cacc269ed32187aaaeaa166c64f41a0418Behdad Esfahbodtypedef uint32_t hb_codepoint_t; 578e4bb3cacc269ed32187aaaeaa166c64f41a0418Behdad Esfahbodtypedef int32_t hb_position_t; 588e4bb3cacc269ed32187aaaeaa166c64f41a0418Behdad Esfahbodtypedef uint32_t hb_mask_t; 598e4bb3cacc269ed32187aaaeaa166c64f41a0418Behdad Esfahbod 608e4bb3cacc269ed32187aaaeaa166c64f41a0418Behdad Esfahbodtypedef union _hb_var_int_t { 618e4bb3cacc269ed32187aaaeaa166c64f41a0418Behdad Esfahbod uint32_t u32; 628e4bb3cacc269ed32187aaaeaa166c64f41a0418Behdad Esfahbod int32_t i32; 638e4bb3cacc269ed32187aaaeaa166c64f41a0418Behdad Esfahbod uint16_t u16[2]; 648e4bb3cacc269ed32187aaaeaa166c64f41a0418Behdad Esfahbod int16_t i16[2]; 658e4bb3cacc269ed32187aaaeaa166c64f41a0418Behdad Esfahbod uint8_t u8[4]; 668e4bb3cacc269ed32187aaaeaa166c64f41a0418Behdad Esfahbod int8_t i8[4]; 678e4bb3cacc269ed32187aaaeaa166c64f41a0418Behdad Esfahbod} hb_var_int_t; 688e4bb3cacc269ed32187aaaeaa166c64f41a0418Behdad Esfahbod 698e4bb3cacc269ed32187aaaeaa166c64f41a0418Behdad Esfahbodtypedef void (*hb_destroy_func_t) (void *user_data); 708e4bb3cacc269ed32187aaaeaa166c64f41a0418Behdad Esfahbod 718e4bb3cacc269ed32187aaaeaa166c64f41a0418Behdad Esfahbod 728e4bb3cacc269ed32187aaaeaa166c64f41a0418Behdad Esfahbod/* hb_tag_t */ 738e4bb3cacc269ed32187aaaeaa166c64f41a0418Behdad Esfahbod 74590d55cbb9e21ef74dfd88eee51fd0a763958cd2Behdad Esfahbodtypedef uint32_t hb_tag_t; 758e4bb3cacc269ed32187aaaeaa166c64f41a0418Behdad Esfahbod 76d77b76200efbaa0611691920f9f2018b1e8be340Behdad 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)))) 774188096a7722f09ffa9319986c0286071da10a27Behdad Esfahbod 780ead481a5a8623103565fd7d924666e7342278ddBehdad Esfahbod#define HB_TAG_NONE HB_TAG(0,0,0,0) 79590d55cbb9e21ef74dfd88eee51fd0a763958cd2Behdad Esfahbod 8083f34677bcbc6bb194940407b0fcb23575650e3dBehdad Esfahbodhb_tag_t hb_tag_from_string (const char *s); 8183f34677bcbc6bb194940407b0fcb23575650e3dBehdad Esfahbod 8283f34677bcbc6bb194940407b0fcb23575650e3dBehdad Esfahbod 838e4bb3cacc269ed32187aaaeaa166c64f41a0418Behdad Esfahbod/* hb_direction_t */ 840090dc0f67b553d2f6eaaedc289c0956ade09ef6Behdad Esfahbod 85ff44f88df2c46920f3ec2384ef321a4c7bb0f6efBehdad Esfahbodtypedef enum _hb_direction_t { 863286fc0e9adc3f2874c9409e7fdb09e4d2b7dda1Behdad Esfahbod HB_DIRECTION_INVALID = -1, 873286fc0e9adc3f2874c9409e7fdb09e4d2b7dda1Behdad Esfahbod HB_DIRECTION_LTR = 0, 88ff44f88df2c46920f3ec2384ef321a4c7bb0f6efBehdad Esfahbod HB_DIRECTION_RTL, 89ff44f88df2c46920f3ec2384ef321a4c7bb0f6efBehdad Esfahbod HB_DIRECTION_TTB, 90ff44f88df2c46920f3ec2384ef321a4c7bb0f6efBehdad Esfahbod HB_DIRECTION_BTT 91ff44f88df2c46920f3ec2384ef321a4c7bb0f6efBehdad Esfahbod} hb_direction_t; 92ff44f88df2c46920f3ec2384ef321a4c7bb0f6efBehdad Esfahbod 931ce4dc95dbb28842085342aea4f9d12cbe9671a9Behdad Esfahbod#define HB_DIRECTION_IS_HORIZONTAL(dir) ((((unsigned int) (dir)) & ~1U) == 0) 941ce4dc95dbb28842085342aea4f9d12cbe9671a9Behdad Esfahbod#define HB_DIRECTION_IS_VERTICAL(dir) ((((unsigned int) (dir)) & ~1U) == 2) 951ce4dc95dbb28842085342aea4f9d12cbe9671a9Behdad Esfahbod#define HB_DIRECTION_IS_FORWARD(dir) ((((unsigned int) (dir)) & ~2U) == 0) 961ce4dc95dbb28842085342aea4f9d12cbe9671a9Behdad Esfahbod#define HB_DIRECTION_IS_BACKWARD(dir) ((((unsigned int) (dir)) & ~2U) == 1) 9722da7fd94d6318c52df69d70470a85464ffc533dBehdad Esfahbod#define HB_DIRECTION_REVERSE(dir) ((hb_direction_t) (((unsigned int) (dir)) ^ 1)) 98ff44f88df2c46920f3ec2384ef321a4c7bb0f6efBehdad Esfahbod 99ff44f88df2c46920f3ec2384ef321a4c7bb0f6efBehdad Esfahbod 1008e4bb3cacc269ed32187aaaeaa166c64f41a0418Behdad Esfahbod/* hb_language_t */ 1018e4bb3cacc269ed32187aaaeaa166c64f41a0418Behdad Esfahbod 1023cbdf70e0a92f1c24e16c0d4dcfbec4ac59a77a3Behdad Esfahbodtypedef struct _hb_language_t *hb_language_t; 1038e4bb3cacc269ed32187aaaeaa166c64f41a0418Behdad Esfahbod 1048e4bb3cacc269ed32187aaaeaa166c64f41a0418Behdad Esfahbodhb_language_t 1058e4bb3cacc269ed32187aaaeaa166c64f41a0418Behdad Esfahbodhb_language_from_string (const char *str); 1068e4bb3cacc269ed32187aaaeaa166c64f41a0418Behdad Esfahbod 1078e4bb3cacc269ed32187aaaeaa166c64f41a0418Behdad Esfahbodconst char * 1088e4bb3cacc269ed32187aaaeaa166c64f41a0418Behdad Esfahbodhb_language_to_string (hb_language_t language); 1096cb8c3493019e1497921666fc268cb81943f9f1fBehdad Esfahbod 1106cb8c3493019e1497921666fc268cb81943f9f1fBehdad Esfahbod 111acdba3f90b232fc12fcb200dca2584481b339118Behdad EsfahbodHB_END_DECLS 112acdba3f90b232fc12fcb200dca2584481b339118Behdad Esfahbod 1138dd1c8b8d6797d899d0f5b0a8015886bf6520ca2Behdad Esfahbod#endif /* HB_COMMON_H */ 114