11512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod/*
21512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod * Copyright (C) 1998-2004  David Turner and Werner Lemberg
31512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod * Copyright (C) 2006  Behdad Esfahbod
41512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod *
51512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod * This is part of HarfBuzz, an OpenType Layout engine library.
61512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod *
71512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod * Permission is hereby granted, without written agreement and without
81512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod * license or royalty fees, to use, copy, modify, and distribute this
91512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod * software and its documentation for any purpose, provided that the
101512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod * above copyright notice and the following two paragraphs appear in
111512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod * all copies of this software.
121512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod *
131512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
141512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
151512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
161512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
171512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod * DAMAGE.
181512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod *
191512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
201512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
211512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
221512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
231512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
241512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod */
251512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
261512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod#ifndef HARFBUZZ_IMPL_H
271512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod#define HARFBUZZ_IMPL_H
281512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
291512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod#include "harfbuzz-global.h"
301512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
311512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod#include <stdlib.h>
321512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
331512a7357513b72e2a07dda706a176bb23d694e9Behdad EsfahbodHB_BEGIN_HEADER
341512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
351512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod#ifndef HB_INTERNAL
36fa2dfcd560444d8c54b6349ee106134d3536f79bBehdad Esfahbod# ifndef __MINGW32__
37fa2dfcd560444d8c54b6349ee106134d3536f79bBehdad Esfahbod#  define HB_INTERNAL __attribute__((__visibility__("hidden")))
38fa2dfcd560444d8c54b6349ee106134d3536f79bBehdad Esfahbod# else
39fa2dfcd560444d8c54b6349ee106134d3536f79bBehdad Esfahbod#  define HB_INTERNAL
40fa2dfcd560444d8c54b6349ee106134d3536f79bBehdad Esfahbod# endif
411512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod#endif
421512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
431512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod#ifndef NULL
441512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod# define NULL ((void *)0)
451512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod#endif
461512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
471512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod#ifndef FALSE
481512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod# define FALSE 0
491512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod#endif
501512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
511512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod#ifndef TRUE
521512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod# define TRUE 1
531512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod#endif
541512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
551512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod#ifndef TTAG_GDEF
561512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod# define TTAG_GDEF  HB_MAKE_TAG( 'G', 'D', 'E', 'F' )
571512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod#endif
581512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod#ifndef TTAG_GPOS
591512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod# define TTAG_GPOS  HB_MAKE_TAG( 'G', 'P', 'O', 'S' )
601512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod#endif
611512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod#ifndef TTAG_GSUB
621512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod# define TTAG_GSUB  HB_MAKE_TAG( 'G', 'S', 'U', 'B' )
631512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod#endif
641512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
651512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod#ifndef HB_UNUSED
661512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod# define HB_UNUSED(arg) ((arg) = (arg))
671512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod#endif
681512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
691512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod#define HB_LIKELY(cond) (cond)
701512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod#define HB_UNLIKELY(cond) (cond)
711512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
721512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod#define ARRAY_LEN(Array) ((int)(sizeof (Array) / sizeof (Array)[0]))
731512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
741512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
751512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
761512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod#define HB_IsHighSurrogate(ucs) \
771512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod    (((ucs) & 0xfc00) == 0xd800)
781512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
791512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod#define HB_IsLowSurrogate(ucs) \
801512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod    (((ucs) & 0xfc00) == 0xdc00)
811512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
821512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod#define HB_SurrogateToUcs4(high, low) \
831512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod    (((HB_UChar32)(high))<<10) + (low) - 0x35fdc00;
841512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
851512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
861512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
871512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
881512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
891512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod#define  ALLOC(_ptr,_size)   \
901512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod           ( (_ptr) = _hb_alloc( _size, &error ), error != 0 )
911512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
921512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod#define  REALLOC(_ptr,_newsz)  \
931512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod           ( (_ptr) = _hb_realloc( (_ptr), (_newsz), &error ), error != 0 )
941512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
951512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod#define  FREE(_ptr)                    \
961512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod  do {                                 \
971512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod    if ( (_ptr) )                      \
981512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod    {                                  \
991512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod      _hb_free( _ptr );     \
1001512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod      _ptr = NULL;                     \
1011512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod    }                                  \
1021512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod  } while (0)
1031512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
1041512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod#define  ALLOC_ARRAY(_ptr,_count,_type)   \
1051512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod           ALLOC(_ptr,(_count)*sizeof(_type))
1061512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
1071512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod#define  REALLOC_ARRAY(_ptr,_newcnt,_type) \
1081512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod           REALLOC(_ptr,(_newcnt)*sizeof(_type))
1091512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
1101512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod#define  MEM_Copy(dest,source,count)   memcpy( (char*)(dest), (const char*)(source), (size_t)(count) )
1111512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
1121512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod#define ERR(err)   _hb_err (err)
1131512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
1141512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
1151512a7357513b72e2a07dda706a176bb23d694e9Behdad EsfahbodHB_INTERNAL HB_Pointer
1161512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod_hb_alloc( size_t    size,
1171512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod	   HB_Error *perror_ );
1181512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
1191512a7357513b72e2a07dda706a176bb23d694e9Behdad EsfahbodHB_INTERNAL HB_Pointer
1201512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod_hb_realloc( HB_Pointer block,
1211512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod	     size_t     new_size,
1221512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod	     HB_Error  *perror_ );
1231512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
1241512a7357513b72e2a07dda706a176bb23d694e9Behdad EsfahbodHB_INTERNAL void
1251512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod_hb_free( HB_Pointer block );
1261512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
1271512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
1281512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod/* helper func to set a breakpoint on */
1291512a7357513b72e2a07dda706a176bb23d694e9Behdad EsfahbodHB_INTERNAL HB_Error
1301512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod_hb_err (HB_Error code);
1311512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
1321512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
1331512a7357513b72e2a07dda706a176bb23d694e9Behdad EsfahbodHB_END_HEADER
1341512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod
1351512a7357513b72e2a07dda706a176bb23d694e9Behdad Esfahbod#endif /* HARFBUZZ_IMPL_H */
136