Rename ftglue.c to harfbuzz-impl.c and more type renames and moving code
authorBehdad Esfahbod <behdad@gnome.org>
Thu, 25 Oct 2007 00:23:46 +0000 (00:23 +0000)
committerBehdad Esfahbod <behdad@src.gnome.org>
Thu, 25 Oct 2007 00:23:46 +0000 (00:23 +0000)
2007-10-24  Behdad Esfahbod  <behdad@gnome.org>

        * pango/opentype/*: Rename ftglue.c to harfbuzz-impl.c and more
        type renames and moving code around.

16 files changed:
src/Makefile.am
src/ftglue.h [deleted file]
src/harfbuzz-dump-main.c
src/harfbuzz-dump.c
src/harfbuzz-gdef.c
src/harfbuzz-global.h
src/harfbuzz-gpos-private.h
src/harfbuzz-gpos.c
src/harfbuzz-gsub-private.h
src/harfbuzz-gsub.c
src/harfbuzz-impl.c [moved from src/ftglue.c with 76% similarity]
src/harfbuzz-impl.h
src/harfbuzz-open-private.h
src/harfbuzz-open.c
src/harfbuzz-open.h
src/harfbuzz.c

index 98adae1..c6d2c15 100644 (file)
@@ -10,11 +10,11 @@ MAINSOURCES =  \
 
 # included from harfbuzz.c
 INCLUDEDSOURCES = \
-       ftglue.c \
        harfbuzz-buffer.c \
        harfbuzz-gdef.c \
        harfbuzz-gpos.c \
        harfbuzz-gsub.c \
+       harfbuzz-impl.c \
        harfbuzz-open.c
 
 PUBLICHEADERS = \
@@ -27,7 +27,6 @@ PUBLICHEADERS = \
        harfbuzz-open.h
 
 PRIVATEHEADERS = \
-       ftglue.h \
        harfbuzz-impl.h \
        harfbuzz-buffer-private.h \
        harfbuzz-gdef-private.h \
diff --git a/src/ftglue.h b/src/ftglue.h
deleted file mode 100644 (file)
index 16873d1..0000000
+++ /dev/null
@@ -1,151 +0,0 @@
-/* ftglue.h: Glue code for compiling the OpenType code from
- *           FreeType 1 using only the public API of FreeType 2
- *
- * By David Turner, The FreeType Project (www.freetype.org)
- *
- * This code is explicitely put in the public domain
- *
- * ==========================================================================
- *
- * the OpenType parser codes was originally written as an extension to
- * FreeType 1.x. As such, its source code was embedded within the library,
- * and used many internal FreeType functions to deal with memory and
- * stream i/o.
- *
- * When it was 'salvaged' for Pango and Qt, the code was "ported" to FreeType 2,
- * which basically means that some macro tricks were performed in order to
- * directly access FT2 _internal_ functions.
- *
- * these functions were never part of FT2 public API, and _did_ change between
- * various releases. This created chaos for many users: when they upgraded the
- * FreeType library on their system, they couldn't run Gnome anymore since
- * Pango refused to link.
- *
- * Very fortunately, it's possible to completely avoid this problem because
- * the FT_StreamRec and FT_MemoryRec structure types, which describe how
- * memory and stream implementations interface with the rest of the font
- * library, have always been part of the public API, and never changed.
- *
- * What we do thus is re-implement, within the OpenType parser, the few
- * functions that depend on them. This only adds one or two kilobytes of
- * code, and ensures that the parser can work with _any_ version
- * of FreeType installed on your system. How sweet... !
- *
- * Note that we assume that Pango doesn't use any other internal functions
- * from FreeType. It used to in old versions, but this should no longer
- * be the case. (crossing my fingers).
- *
- *  - David Turner
- *  - The FreeType Project  (www.freetype.org)
- *
- * PS: This "glue" code is explicitely put in the public domain
- */
-#ifndef FTGLUE_H
-#define FTGLUE_H
-
-#include <ft2build.h>
-#include FT_FREETYPE_H
-
-#include "harfbuzz-open.h"
-#include "harfbuzz-impl.h"
-
-HB_BEGIN_HEADER
-
-
-/* utility macros */
-
-#ifndef HB_Error
-#define HB_Error FT_Error
-#endif
-
-#define  SET_ERR(c)   ( (error = (c)) != 0 )
-
-/* stream macros used by the OpenType parser */
-#define  FILE_Pos()      _hb_ftglue_stream_pos( stream )
-#define  FILE_Seek(pos)  SET_ERR( _hb_ftglue_stream_seek( stream, pos ) )
-#define  ACCESS_Frame(size)  SET_ERR( _hb_ftglue_stream_frame_enter( stream, size ) )
-#define  FORGET_Frame()      _hb_ftglue_stream_frame_exit( stream )
-
-#define  GET_Byte()      (*stream->cursor++)
-#define  GET_Short()     (stream->cursor += 2, (HB_Short)( \
-                               (*(((FT_Byte*)stream->cursor)-2) << 8) | \
-                                *(((FT_Byte*)stream->cursor)-1) \
-                        ))
-#define  GET_Long()      (stream->cursor += 4, (HB_Int)( \
-                               (*(((FT_Byte*)stream->cursor)-4) << 24) | \
-                               (*(((FT_Byte*)stream->cursor)-3) << 16) | \
-                               (*(((FT_Byte*)stream->cursor)-2) << 8) | \
-                                *(((FT_Byte*)stream->cursor)-1) \
-                        ))
-
-
-#define  GET_Char()      ((FT_Char)GET_Byte())
-#define  GET_UShort()    ((HB_UShort)GET_Short())
-#define  GET_ULong()     ((HB_UInt)GET_Long())
-#define  GET_Tag4()      GET_ULong()
-
-HB_INTERNAL HB_Int
-_hb_ftglue_stream_pos( FT_Stream   stream );
-
-HB_INTERNAL HB_Error
-_hb_ftglue_stream_seek( FT_Stream   stream,
-                    HB_Int     pos );
-
-HB_INTERNAL HB_Error
-_hb_ftglue_stream_frame_enter( FT_Stream   stream,
-                           HB_UInt    size );
-
-HB_INTERNAL void
-_hb_ftglue_stream_frame_exit( FT_Stream  stream );
-
-HB_INTERNAL HB_Error
-_hb_ftglue_face_goto_table( FT_Face    face,
-                        HB_UInt   tag,
-                        FT_Stream  stream );
-
-/* memory macros used by the OpenType parser */
-#define  ALLOC(_ptr,_size)   \
-           ( (_ptr) = _hb_ftglue_alloc( _size, &error ), error != 0 )
-
-#define  REALLOC(_ptr,_newsz)  \
-           ( (_ptr) = _hb_ftglue_realloc( (_ptr), (_newsz), &error ), error != 0 )
-
-#define  FREE(_ptr)                    \
-  do {                                 \
-    if ( (_ptr) )                      \
-    {                                  \
-      _hb_ftglue_free( _ptr );         \
-      _ptr = NULL;                     \
-    }                                  \
-  } while (0)
-
-#define  ALLOC_ARRAY(_ptr,_count,_type)   \
-           ALLOC(_ptr,(_count)*sizeof(_type))
-
-#define  REALLOC_ARRAY(_ptr,_newcnt,_type) \
-           REALLOC(_ptr,(_newcnt)*sizeof(_type))
-
-#define  MEM_Copy(dest,source,count)   memcpy( (char*)(dest), (const char*)(source), (size_t)(count) )
-
-
-HB_INTERNAL FT_Pointer
-_hb_ftglue_alloc( HB_UInt   size,
-                 HB_Error  *perror_ );
-
-HB_INTERNAL FT_Pointer
-_hb_ftglue_realloc( FT_Pointer  block,
-                   HB_UInt    new_size,
-                   HB_Error   *perror_ );
-
-HB_INTERNAL void
-_hb_ftglue_free( FT_Pointer  block );
-
-/* abuse these private header/source files */
-
-/* helper func to set a breakpoint on */
-HB_INTERNAL HB_Error
-_hb_err (HB_Error code);
-
-HB_END_HEADER
-
-#endif /* FTGLUE_H */
index 1643225..7f2ab5b 100644 (file)
@@ -82,48 +82,10 @@ maybe_add_feature (HB_GSUB  gsub,
 }
 
 static void
-select_cmap (FT_Face face)
-{
-  HB_UShort  i;
-  FT_CharMap cmap = NULL;
-  
-  for (i = 0; i < face->num_charmaps; i++)
-    {
-      if (face->charmaps[i]->platform_id == 3 && face->charmaps[i]->encoding_id == 1)
-       {
-         cmap = face->charmaps[i];
-         break;
-       }
-    }
-  
-  /* we try only pid/eid (0,0) if no (3,1) map is found -- many Windows
-     fonts have only rudimentary (0,0) support.                         */
-
-  if (!cmap)
-    for (i = 0; i < face->num_charmaps; i++)
-      {
-       if (face->charmaps[i]->platform_id == 3 && face->charmaps[i]->encoding_id == 1)
-         {
-           cmap = face->charmaps[i];
-           break;
-         }
-      }
-
-  if (cmap)
-    FT_Set_Charmap (face, cmap);
-  else
-    {
-      fprintf (stderr, "Sorry, but this font doesn't contain"
-              " any Unicode mapping table.\n");
-      exit (1);
-    }
-}
-
-static void
 add_features (HB_GSUB gsub)
 {
   HB_Error error;
-  HB_UInt tag = FT_MAKE_TAG ('a', 'r', 'a', 'b');
+  HB_UInt tag = HB_MAKE_TAG ('a', 'r', 'a', 'b');
   HB_UShort script_index;
 
   error = HB_GSUB_Select_Script (gsub, tag, &script_index);
@@ -139,10 +101,10 @@ add_features (HB_GSUB gsub)
       croak ("HB_GSUB_Select_Script", error);
     }
 
-  maybe_add_feature (gsub, script_index, FT_MAKE_TAG ('i', 'n', 'i', 't'), I);
-  maybe_add_feature (gsub, script_index, FT_MAKE_TAG ('m', 'e', 'd', 'i'), M);
-  maybe_add_feature (gsub, script_index, FT_MAKE_TAG ('f', 'i', 'n', 'a'), F);
-  maybe_add_feature (gsub, script_index, FT_MAKE_TAG ('l', 'i', 'g', 'a'), L);
+  maybe_add_feature (gsub, script_index, HB_MAKE_TAG ('i', 'n', 'i', 't'), I);
+  maybe_add_feature (gsub, script_index, HB_MAKE_TAG ('m', 'e', 'd', 'i'), M);
+  maybe_add_feature (gsub, script_index, HB_MAKE_TAG ('f', 'i', 'n', 'a'), F);
+  maybe_add_feature (gsub, script_index, HB_MAKE_TAG ('l', 'i', 'g', 'a'), L);
 }
 #endif
 
index d1d4eb9..4ae548f 100644 (file)
@@ -87,7 +87,7 @@ DEF_DUMP (LangSys)
 {
   int i;
 
-  FT_UNUSED(hb_type);
+  HB_UNUSED(hb_type);
 
   DUMP_FUINT (LangSys, LookupOrderOffset);
   DUMP_FUINT (LangSys, ReqFeatureIndex);
@@ -135,7 +135,7 @@ DEF_DUMP (Feature)
 {
   int i;
 
-  FT_UNUSED(hb_type);
+  HB_UNUSED(hb_type);
 
   DUMP_FUINT (Feature, FeatureParams);
   DUMP_FUINT (Feature, LookupListCount);
@@ -146,7 +146,7 @@ DEF_DUMP (Feature)
 
 DEF_DUMP (MarkRecord)
 {
-  FT_UNUSED(hb_type);
+  HB_UNUSED(hb_type);
 
   DUMP_FUINT (MarkRecord, Class);
   DUMP1("<Anchor>%d</Anchor>\n", MarkRecord->MarkAnchor.PosFormat );
@@ -180,7 +180,7 @@ DEF_DUMP (FeatureList)
 
 DEF_DUMP (Coverage)
 {
-  FT_UNUSED(hb_type);
+  HB_UNUSED(hb_type);
 
   DUMP_FUINT (Coverage, CoverageFormat);
 
@@ -207,7 +207,7 @@ DEF_DUMP (Coverage)
 
 DEF_DUMP (ClassRangeRecord)
 {
-  FT_UNUSED(hb_type);
+  HB_UNUSED(hb_type);
 
   DUMP_FGLYPH (ClassRangeRecord, Start);
   DUMP_FGLYPH (ClassRangeRecord, End);
@@ -216,7 +216,7 @@ DEF_DUMP (ClassRangeRecord)
 
 DEF_DUMP (ClassDefinition)
 {
-  FT_UNUSED(hb_type);
+  HB_UNUSED(hb_type);
 
   DUMP_FUINT( ClassDefinition, ClassFormat);
   DUMP_FUINT( ClassDefinition, loaded);
@@ -247,7 +247,7 @@ DEF_DUMP (ClassDefinition)
 
 DEF_DUMP (SubstLookupRecord)
 {
-  FT_UNUSED(hb_type);
+  HB_UNUSED(hb_type);
 
   DUMP_FUINT (SubstLookupRecord, SequenceIndex);
   DUMP_FUINT (SubstLookupRecord, LookupListIndex);
@@ -302,7 +302,7 @@ DEF_DUMP (Ligature)
 {
   int i;
 
-  FT_UNUSED(hb_type);
+  HB_UNUSED(hb_type);
 
   DUMP_FGLYPH (Ligature, LigGlyph);
   DUMP_FUINT (Ligature, ComponentCount);
@@ -338,8 +338,8 @@ Dump_GSUB_Lookup_Ligature (HB_SubTable *subtable, FILE *stream, int indent, HB_T
 
 DEF_DUMP (ContextSubstFormat1)
 {
-  FT_UNUSED(hb_type);
-  FT_UNUSED(ContextSubstFormat1);
+  HB_UNUSED(hb_type);
+  HB_UNUSED(ContextSubstFormat1);
 
 
   DUMP("<!-- Not implemented!!! -->\n");
@@ -354,8 +354,8 @@ DEF_DUMP (ContextSubstFormat2)
 
 DEF_DUMP (ContextSubstFormat3)
 {
-  FT_UNUSED(hb_type);
-  FT_UNUSED(ContextSubstFormat3);
+  HB_UNUSED(hb_type);
+  HB_UNUSED(ContextSubstFormat3);
 
   DUMP("<!-- Not implemented!!! -->\n");
 }
@@ -384,8 +384,8 @@ Dump_GSUB_Lookup_Context (HB_SubTable *subtable, FILE *stream, int indent, HB_Ty
 
 DEF_DUMP (ChainContextSubstFormat1)
 {
-  FT_UNUSED(hb_type);
-  FT_UNUSED(ChainContextSubstFormat1);
+  HB_UNUSED(hb_type);
+  HB_UNUSED(ChainContextSubstFormat1);
 
   DUMP("<!-- Not implemented!!! -->\n");
 }
@@ -456,7 +456,7 @@ Dump_Device (HB_Device *Device, FILE *stream, int indent, HB_Type hb_type)
   int n_per;
   unsigned int mask;
 
-  FT_UNUSED(hb_type);
+  HB_UNUSED(hb_type);
 
   DUMP_FUINT (Device, StartSize);
   DUMP_FUINT (Device, EndSize);
index d6fdc26..cca0b8c 100644 (file)
@@ -15,9 +15,9 @@
 #include "harfbuzz-open-private.h"
 
 static HB_Error  Load_AttachList( HB_AttachList*  al,
-                                 FT_Stream        stream );
+                                 HB_Stream        stream );
 static HB_Error  Load_LigCaretList( HB_LigCaretList*  lcl,
-                                   FT_Stream          stream );
+                                   HB_Stream          stream );
 
 static void  Free_AttachList( HB_AttachList*  al );
 static void  Free_LigCaretList( HB_LigCaretList*  lcl );
@@ -157,7 +157,7 @@ HB_Error  HB_Load_GDEF_Table( FT_Face          face,
                              HB_GDEFHeader** retptr )
 {
   HB_Error         error;
-  FT_Stream        stream = face->stream;
+  HB_Stream        stream = face->stream;
   HB_UInt         cur_offset, new_offset, base_offset;
 
   HB_GDEFHeader*  gdef;
@@ -166,7 +166,7 @@ HB_Error  HB_Load_GDEF_Table( FT_Face          face,
   if ( !retptr )
     return HB_Err_Invalid_Argument;
 
-  if (( error = _hb_ftglue_face_goto_table( face, TTAG_GDEF, stream ) ))
+  if ( GOTO_Table( TTAG_GDEF ) )
     return error;
 
   if (( error = HB_New_GDEF_Table ( &gdef ) ))
@@ -299,7 +299,7 @@ HB_Error  HB_Done_GDEF_Table ( HB_GDEFHeader* gdef )
 /* AttachPoint */
 
 static HB_Error  Load_AttachPoint( HB_AttachPoint*  ap,
-                                  FT_Stream         stream )
+                                  HB_Stream         stream )
 {
   HB_Error  error;
 
@@ -348,7 +348,7 @@ static void  Free_AttachPoint( HB_AttachPoint*  ap )
 /* AttachList */
 
 static HB_Error  Load_AttachList( HB_AttachList*  al,
-                                 FT_Stream        stream )
+                                 HB_Stream        stream )
 {
   HB_Error  error;
 
@@ -456,7 +456,7 @@ static void  Free_AttachList( HB_AttachList*  al )
 /* CaretValueFormat4 */
 
 static HB_Error  Load_CaretValue( HB_CaretValue*  cv,
-                                 FT_Stream        stream )
+                                 HB_Stream        stream )
 {
   HB_Error  error;
 
@@ -540,7 +540,7 @@ static void  Free_CaretValue( HB_CaretValue*  cv )
 /* LigGlyph */
 
 static HB_Error  Load_LigGlyph( HB_LigGlyph*  lg,
-                               FT_Stream      stream )
+                               HB_Stream      stream )
 {
   HB_Error  error;
 
@@ -616,7 +616,7 @@ static void  Free_LigGlyph( HB_LigGlyph*  lg )
 /* LigCaretList */
 
 static HB_Error  Load_LigCaretList( HB_LigCaretList*  lcl,
-                                   FT_Stream          stream )
+                                   HB_Stream          stream )
 {
   HB_Error  error;
 
index d6e9047..88fe1aa 100644 (file)
@@ -29,6 +29,24 @@ typedef unsigned int HB_UInt;
 typedef signed int HB_Int;
 typedef int HB_Bool;
 
+
+/* compatible with FT_Error */
+typedef enum {
+  HB_Err_Invalid_Argument           = FT_Err_Invalid_Argument,
+  HB_Err_Invalid_Face_Handle        = FT_Err_Invalid_Face_Handle,
+  HB_Err_Invalid_Stream_Operation   = FT_Err_Invalid_Stream_Operation,
+  HB_Err_Empty_Script               = 0x1005,
+
+  HB_Err_Ok                         = FT_Err_Ok,
+  HB_Err_Not_Covered                = 0x1002,
+  HB_Err_Out_Of_Memory              = FT_Err_Out_Of_Memory,
+  HB_Err_Table_Missing              = FT_Err_Table_Missing,
+  HB_Err_Invalid_SubTable_Format    = 0x1000,
+  HB_Err_Invalid_SubTable           = 0x1001,
+  HB_Err_Too_Many_Nested_Contexts   = 0x1003,
+  HB_Err_No_MM_Interpreter          = 0x1004
+} HB_Error;
+
 HB_END_HEADER
 
 #endif
index 7a45d62..2829240 100644 (file)
@@ -686,7 +686,7 @@ typedef union HB_GPOS_SubTable_  HB_GPOS_SubTable;
 
 HB_INTERNAL HB_Error
 _HB_GPOS_Load_SubTable( HB_GPOS_SubTable* st,
-                       FT_Stream         stream,
+                       HB_Stream         stream,
                        HB_UShort         lookup_type );
 
 HB_INTERNAL void
index 01966ce..7ba1641 100644 (file)
@@ -49,10 +49,10 @@ static HB_Error  default_mmfunc( FT_Face      face,
                                 FT_Pos*      metric_value,
                                 void*        data )
 {
-  FT_UNUSED(face);
-  FT_UNUSED(metric_id);
-  FT_UNUSED(metric_value);
-  FT_UNUSED(data);
+  HB_UNUSED(face);
+  HB_UNUSED(metric_id);
+  HB_UNUSED(metric_value);
+  HB_UNUSED(data);
   return _hb_err(HB_Err_No_MM_Interpreter);
 }
 
@@ -68,14 +68,14 @@ HB_Error  HB_Load_GPOS_Table( FT_Face          face,
   HB_GPOSHeader*  gpos;
   HB_Lookup*      lo;
 
-  FT_Stream  stream = face->stream;
+  HB_Stream  stream = face->stream;
   HB_Error   error;
 
 
   if ( !retptr )
     return HB_Err_Invalid_Argument;
 
-  if (( error = _hb_ftglue_face_goto_table( face, TTAG_GPOS, stream ) ))
+  if ( GOTO_Table( TTAG_GPOS ) )
     return error;
 
   base_offset = FILE_Pos();
@@ -208,7 +208,7 @@ HB_Error  HB_Done_GPOS_Table( HB_GPOSHeader* gpos )
 static HB_Error  Load_ValueRecord( HB_ValueRecord*  vr,
                                   HB_UShort         format,
                                   HB_UInt          base_offset,
-                                  FT_Stream         stream )
+                                  HB_Stream         stream )
 {
   HB_Error  error;
 
@@ -567,7 +567,7 @@ static HB_Error  Get_ValueRecord( GPOS_Instance*    gpi,
 /* AnchorFormat4 */
 
 static HB_Error  Load_Anchor( HB_Anchor*  an,
-                             FT_Stream    stream )
+                             HB_Stream    stream )
 {
   HB_Error  error;
 
@@ -804,7 +804,7 @@ static HB_Error  Get_Anchor( GPOS_Instance*   gpi,
 /* MarkArray */
 
 static HB_Error  Load_MarkArray ( HB_MarkArray*  ma,
-                                 FT_Stream       stream )
+                                 HB_Stream       stream )
 {
   HB_Error  error;
 
@@ -884,7 +884,7 @@ static void  Free_MarkArray( HB_MarkArray*  ma )
 /* SinglePosFormat2 */
 
 static HB_Error  Load_SinglePos( HB_GPOS_SubTable* st,
-                                FT_Stream       stream )
+                                HB_Stream       stream )
 {
   HB_Error  error;
   HB_SinglePos*   sp = &st->single;
@@ -1013,7 +1013,7 @@ static HB_Error  Lookup_SinglePos( GPOS_Instance*    gpi,
   HB_GPOSHeader*  gpos = gpi->gpos;
   HB_SinglePos*   sp = &st->single;
 
-  FT_UNUSED(nesting_level);
+  HB_UNUSED(nesting_level);
 
   if ( context_length != 0xFFFF && context_length < 1 )
     return HB_Err_Not_Covered;
@@ -1060,7 +1060,7 @@ static HB_Error  Lookup_SinglePos( GPOS_Instance*    gpi,
 static HB_Error  Load_PairSet ( HB_PairSet*  ps,
                                HB_UShort     format1,
                                HB_UShort     format2,
-                               FT_Stream     stream )
+                               HB_Stream     stream )
 {
   HB_Error  error;
 
@@ -1163,7 +1163,7 @@ static void  Free_PairSet( HB_PairSet*  ps,
 static HB_Error  Load_PairPos1( HB_PairPosFormat1*  ppf1,
                                HB_UShort            format1,
                                HB_UShort            format2,
-                               FT_Stream            stream )
+                               HB_Stream            stream )
 {
   HB_Error  error;
 
@@ -1244,7 +1244,7 @@ static void  Free_PairPos1( HB_PairPosFormat1*  ppf1,
 static HB_Error  Load_PairPos2( HB_PairPosFormat2*  ppf2,
                                HB_UShort            format1,
                                HB_UShort            format2,
-                               FT_Stream            stream )
+                               HB_Stream            stream )
 {
   HB_Error  error;
 
@@ -1402,7 +1402,7 @@ static void  Free_PairPos2( HB_PairPosFormat2*  ppf2,
 
 
 static HB_Error  Load_PairPos( HB_GPOS_SubTable* st,
-                              FT_Stream     stream )
+                              HB_Stream     stream )
 {
   HB_Error  error;
   HB_PairPos*     pp = &st->pair;
@@ -1573,7 +1573,7 @@ static HB_Error  Lookup_PairPos( GPOS_Instance*    gpi,
   HB_GPOSHeader*  gpos = gpi->gpos;
   HB_PairPos*     pp = &st->pair;
 
-  FT_UNUSED(nesting_level);
+  HB_UNUSED(nesting_level);
 
   if ( buffer->in_pos >= buffer->in_length - 1 )
     return HB_Err_Not_Covered;           /* Not enough glyphs in stream */
@@ -1645,7 +1645,7 @@ static HB_Error  Lookup_PairPos( GPOS_Instance*    gpi,
 /* CursivePosFormat1 */
 
 static HB_Error  Load_CursivePos( HB_GPOS_SubTable* st,
-                                 FT_Stream        stream )
+                                 HB_Stream        stream )
 {
   HB_Error  error;
   HB_CursivePos*  cp = &st->cursive;
@@ -1796,7 +1796,7 @@ static HB_Error  Lookup_CursivePos( GPOS_Instance*    gpi,
   FT_Pos                entry_x, entry_y;
   FT_Pos                exit_x, exit_y;
 
-  FT_UNUSED(nesting_level);
+  HB_UNUSED(nesting_level);
 
   if ( context_length != 0xFFFF && context_length < 1 )
   {
@@ -2009,7 +2009,7 @@ end:
 
 static HB_Error  Load_BaseArray( HB_BaseArray*  ba,
                                 HB_UShort       num_classes,
-                                FT_Stream       stream )
+                                HB_Stream       stream )
 {
   HB_Error  error;
 
@@ -2127,7 +2127,7 @@ static void  Free_BaseArray( HB_BaseArray*  ba,
 /* MarkBasePosFormat1 */
 
 static HB_Error  Load_MarkBasePos( HB_GPOS_SubTable* st,
-                                  FT_Stream         stream )
+                                  HB_Stream         stream )
 {
   HB_Error  error;
   HB_MarkBasePos* mbp = &st->markbase;
@@ -2240,7 +2240,7 @@ static HB_Error  Lookup_MarkBasePos( GPOS_Instance*    gpi,
 
   HB_Position     o;
 
-  FT_UNUSED(nesting_level);
+  HB_UNUSED(nesting_level);
 
   if ( context_length != 0xFFFF && context_length < 1 )
     return HB_Err_Not_Covered;
@@ -2341,7 +2341,7 @@ static HB_Error  Lookup_MarkBasePos( GPOS_Instance*    gpi,
 
 static HB_Error  Load_LigatureAttach( HB_LigatureAttach*  lat,
                                      HB_UShort            num_classes,
-                                     FT_Stream            stream )
+                                     HB_Stream            stream )
 {
   HB_Error  error;
 
@@ -2458,7 +2458,7 @@ static void  Free_LigatureAttach( HB_LigatureAttach*  lat,
 
 static HB_Error  Load_LigatureArray( HB_LigatureArray*  la,
                                     HB_UShort           num_classes,
-                                    FT_Stream           stream )
+                                    HB_Stream           stream )
 {
   HB_Error  error;
 
@@ -2536,7 +2536,7 @@ static void  Free_LigatureArray( HB_LigatureArray*  la,
 /* MarkLigPosFormat1 */
 
 static HB_Error  Load_MarkLigPos( HB_GPOS_SubTable* st,
-                                 FT_Stream        stream )
+                                 HB_Stream        stream )
 {
   HB_Error  error;
   HB_MarkLigPos*  mlp = &st->marklig;
@@ -2650,7 +2650,7 @@ static HB_Error  Lookup_MarkLigPos( GPOS_Instance*    gpi,
 
   HB_Position    o;
 
-  FT_UNUSED(nesting_level);
+  HB_UNUSED(nesting_level);
 
   if ( context_length != 0xFFFF && context_length < 1 )
     return HB_Err_Not_Covered;
@@ -2767,7 +2767,7 @@ static HB_Error  Lookup_MarkLigPos( GPOS_Instance*    gpi,
 
 static HB_Error  Load_Mark2Array( HB_Mark2Array*  m2a,
                                  HB_UShort        num_classes,
-                                 FT_Stream        stream )
+                                 HB_Stream        stream )
 {
   HB_Error  error;
 
@@ -2876,7 +2876,7 @@ static void  Free_Mark2Array( HB_Mark2Array*  m2a,
 /* MarkMarkPosFormat1 */
 
 static HB_Error  Load_MarkMarkPos( HB_GPOS_SubTable* st,
-                                  FT_Stream         stream )
+                                  HB_Stream         stream )
 {
   HB_Error  error;
   HB_MarkMarkPos* mmp = &st->markmark;
@@ -2989,7 +2989,7 @@ static HB_Error  Lookup_MarkMarkPos( GPOS_Instance*    gpi,
 
   HB_Position    o;
 
-  FT_UNUSED(nesting_level);
+  HB_UNUSED(nesting_level);
 
   if ( context_length != 0xFFFF && context_length < 1 )
     return HB_Err_Not_Covered;
@@ -3136,7 +3136,7 @@ static HB_Error  Do_ContextPos( GPOS_Instance*        gpi,
 /* PosRule */
 
 static HB_Error  Load_PosRule( HB_PosRule*  pr,
-                              FT_Stream     stream )
+                              HB_Stream     stream )
 {
   HB_Error  error;
 
@@ -3212,7 +3212,7 @@ static void  Free_PosRule( HB_PosRule*  pr )
 /* PosRuleSet */
 
 static HB_Error  Load_PosRuleSet( HB_PosRuleSet*  prs,
-                                 FT_Stream        stream )
+                                 HB_Stream        stream )
 {
   HB_Error  error;
 
@@ -3288,7 +3288,7 @@ static void  Free_PosRuleSet( HB_PosRuleSet*  prs )
 /* ContextPosFormat1 */
 
 static HB_Error  Load_ContextPos1( HB_ContextPosFormat1*  cpf1,
-                                  FT_Stream               stream )
+                                  HB_Stream               stream )
 {
   HB_Error  error;
 
@@ -3383,7 +3383,7 @@ static void  Free_ContextPos1( HB_ContextPosFormat1*  cpf1 )
 
 static HB_Error  Load_PosClassRule( HB_ContextPosFormat2*  cpf2,
                                    HB_PosClassRule*       pcr,
-                                   FT_Stream               stream )
+                                   HB_Stream               stream )
 {
   HB_Error  error;
 
@@ -3473,7 +3473,7 @@ static void  Free_PosClassRule( HB_PosClassRule*  pcr )
 
 static HB_Error  Load_PosClassSet( HB_ContextPosFormat2*  cpf2,
                                   HB_PosClassSet*        pcs,
-                                  FT_Stream               stream )
+                                  HB_Stream               stream )
 {
   HB_Error  error;
 
@@ -3550,7 +3550,7 @@ static void  Free_PosClassSet( HB_PosClassSet*  pcs )
 /* ContextPosFormat2 */
 
 static HB_Error  Load_ContextPos2( HB_ContextPosFormat2*  cpf2,
-                                  FT_Stream               stream )
+                                  HB_Stream               stream )
 {
   HB_Error  error;
 
@@ -3672,7 +3672,7 @@ static void  Free_ContextPos2( HB_ContextPosFormat2*  cpf2 )
 /* ContextPosFormat3 */
 
 static HB_Error  Load_ContextPos3( HB_ContextPosFormat3*  cpf3,
-                                  FT_Stream               stream )
+                                  HB_Stream               stream )
 {
   HB_Error  error;
 
@@ -3777,7 +3777,7 @@ static void  Free_ContextPos3( HB_ContextPosFormat3*  cpf3 )
 /* ContextPos */
 
 static HB_Error  Load_ContextPos( HB_GPOS_SubTable* st,
-                                 FT_Stream        stream )
+                                 HB_Stream        stream )
 {
   HB_Error  error;
   HB_ContextPos*   cp = &st->context;
@@ -4083,7 +4083,7 @@ static HB_Error  Lookup_ContextPos( GPOS_Instance*    gpi,
 /* ChainPosRule */
 
 static HB_Error  Load_ChainPosRule( HB_ChainPosRule*  cpr,
-                                   FT_Stream          stream )
+                                   HB_Stream          stream )
 {
   HB_Error  error;
 
@@ -4223,7 +4223,7 @@ static void  Free_ChainPosRule( HB_ChainPosRule*  cpr )
 /* ChainPosRuleSet */
 
 static HB_Error  Load_ChainPosRuleSet( HB_ChainPosRuleSet*  cprs,
-                                      FT_Stream             stream )
+                                      HB_Stream             stream )
 {
   HB_Error  error;
 
@@ -4299,7 +4299,7 @@ static void  Free_ChainPosRuleSet( HB_ChainPosRuleSet*  cprs )
 /* ChainContextPosFormat1 */
 
 static HB_Error  Load_ChainContextPos1( HB_ChainContextPosFormat1*  ccpf1,
-                                       FT_Stream                    stream )
+                                       HB_Stream                    stream )
 {
   HB_Error  error;
 
@@ -4395,7 +4395,7 @@ static void  Free_ChainContextPos1( HB_ChainContextPosFormat1*  ccpf1 )
 static HB_Error  Load_ChainPosClassRule(
                   HB_ChainContextPosFormat2*  ccpf2,
                   HB_ChainPosClassRule*       cpcr,
-                  FT_Stream                    stream )
+                  HB_Stream                    stream )
 {
   HB_Error  error;
 
@@ -4568,7 +4568,7 @@ static void  Free_ChainPosClassRule( HB_ChainPosClassRule*  cpcr )
 static HB_Error  Load_ChainPosClassSet(
                   HB_ChainContextPosFormat2*  ccpf2,
                   HB_ChainPosClassSet*        cpcs,
-                  FT_Stream                    stream )
+                  HB_Stream                    stream )
 {
   HB_Error  error;
 
@@ -4646,7 +4646,7 @@ static void  Free_ChainPosClassSet( HB_ChainPosClassSet*  cpcs )
 /* ChainContextPosFormat2 */
 
 static HB_Error  Load_ChainContextPos2( HB_ChainContextPosFormat2*  ccpf2,
-                                       FT_Stream                    stream )
+                                       HB_Stream                    stream )
 {
   HB_Error  error;
 
@@ -4789,7 +4789,7 @@ static void  Free_ChainContextPos2( HB_ChainContextPosFormat2*  ccpf2 )
 /* ChainContextPosFormat3 */
 
 static HB_Error  Load_ChainContextPos3( HB_ChainContextPosFormat3*  ccpf3,
-                                       FT_Stream                    stream )
+                                       HB_Stream                    stream )
 {
   HB_Error  error;
 
@@ -5003,7 +5003,7 @@ static void  Free_ChainContextPos3( HB_ChainContextPosFormat3*  ccpf3 )
 /* ChainContextPos */
 
 static HB_Error  Load_ChainContextPos( HB_GPOS_SubTable* st,
-                                      FT_Stream             stream )
+                                      HB_Stream             stream )
 {
   HB_Error  error;
   HB_ChainContextPos*  ccp = &st->chain;
@@ -5879,7 +5879,7 @@ static HB_Error  GPOS_Do_Glyph_Lookup( GPOS_Instance*    gpi,
 
 HB_INTERNAL HB_Error
 _HB_GPOS_Load_SubTable( HB_GPOS_SubTable* st,
-                       FT_Stream         stream,
+                       HB_Stream         stream,
                        HB_UShort         lookup_type )
 {
   switch ( lookup_type ) {
index 9e39815..6d4be96 100644 (file)
@@ -450,7 +450,7 @@ union  HB_GSUB_SubTable_
 
 HB_INTERNAL HB_Error
 _HB_GSUB_Load_SubTable( HB_GSUB_SubTable* st,
-                       FT_Stream         stream,
+                       HB_Stream         stream,
                        HB_UShort         lookup_type );
 
 HB_INTERNAL void
index b02249d..ccdb57f 100644 (file)
@@ -34,7 +34,7 @@ HB_Error  HB_Load_GSUB_Table( FT_Face          face,
                              HB_GSUBHeader** retptr,
                              HB_GDEFHeader*  gdef )
 {
-  FT_Stream        stream = face->stream;
+  HB_Stream        stream = face->stream;
   HB_Error         error;
   HB_UInt         cur_offset, new_offset, base_offset;
 
@@ -45,7 +45,7 @@ HB_Error  HB_Load_GSUB_Table( FT_Face          face,
   if ( !retptr )
     return HB_Err_Invalid_Argument;
 
-  if (( error = _hb_ftglue_face_goto_table( face, TTAG_GSUB, stream ) ))
+  if ( GOTO_Table( TTAG_GSUB ) )
     return error;
 
   base_offset = FILE_Pos();
@@ -173,7 +173,7 @@ HB_Error   HB_Done_GSUB_Table( HB_GSUBHeader* gsub )
 /* SingleSubstFormat2 */
 
 static HB_Error  Load_SingleSubst( HB_GSUB_SubTable* st,
-                                  FT_Stream         stream )
+                                  HB_Stream         stream )
 {
   HB_Error error;
   HB_SingleSubst*  ss = &st->single;
@@ -285,7 +285,7 @@ static HB_Error  Lookup_SingleSubst( HB_GSUBHeader*   gsub,
   HB_SingleSubst*  ss = &st->single;
   HB_GDEFHeader*   gdef = gsub->gdef;
 
-  FT_UNUSED(nesting_level);
+  HB_UNUSED(nesting_level);
 
   if ( context_length != 0xFFFF && context_length < 1 )
     return HB_Err_Not_Covered;
@@ -335,7 +335,7 @@ static HB_Error  Lookup_SingleSubst( HB_GSUBHeader*   gsub,
 /* Sequence */
 
 static HB_Error  Load_Sequence( HB_Sequence*  s,
-                               FT_Stream      stream )
+                               HB_Stream      stream )
 {
   HB_Error error;
 
@@ -384,7 +384,7 @@ static void  Free_Sequence( HB_Sequence*  s )
 /* MultipleSubstFormat1 */
 
 static HB_Error  Load_MultipleSubst( HB_GSUB_SubTable* st,
-                                    FT_Stream         stream )
+                                    HB_Stream         stream )
 {
   HB_Error error;
   HB_MultipleSubst*  ms = &st->multiple;
@@ -491,7 +491,7 @@ static HB_Error  Lookup_MultipleSubst( HB_GSUBHeader*    gsub,
   HB_MultipleSubst*  ms = &st->multiple;
   HB_GDEFHeader*     gdef = gsub->gdef;
 
-  FT_UNUSED(nesting_level);
+  HB_UNUSED(nesting_level);
 
   if ( context_length != 0xFFFF && context_length < 1 )
     return HB_Err_Not_Covered;
@@ -536,7 +536,7 @@ static HB_Error  Lookup_MultipleSubst( HB_GSUBHeader*    gsub,
 /* AlternateSet */
 
 static HB_Error  Load_AlternateSet( HB_AlternateSet*  as,
-                                   FT_Stream          stream )
+                                   HB_Stream          stream )
 {
   HB_Error error;
 
@@ -582,7 +582,7 @@ static void  Free_AlternateSet( HB_AlternateSet*  as )
 /* AlternateSubstFormat1 */
 
 static HB_Error  Load_AlternateSubst( HB_GSUB_SubTable* st,
-                                     FT_Stream         stream )
+                                     HB_Stream         stream )
 {
   HB_Error error;
   HB_AlternateSubst* as = &st->alternate;
@@ -689,7 +689,7 @@ static HB_Error  Lookup_AlternateSubst( HB_GSUBHeader*    gsub,
   HB_GDEFHeader*     gdef = gsub->gdef;
   HB_AlternateSet  aset;
 
-  FT_UNUSED(nesting_level);
+  HB_UNUSED(nesting_level);
 
   if ( context_length != 0xFFFF && context_length < 1 )
     return HB_Err_Not_Covered;
@@ -734,7 +734,7 @@ static HB_Error  Lookup_AlternateSubst( HB_GSUBHeader*    gsub,
 /* Ligature */
 
 static HB_Error  Load_Ligature( HB_Ligature*  l,
-                               FT_Stream      stream )
+                               HB_Stream      stream )
 {
   HB_Error error;
 
@@ -783,7 +783,7 @@ static void  Free_Ligature( HB_Ligature*  l )
 /* LigatureSet */
 
 static HB_Error  Load_LigatureSet( HB_LigatureSet*  ls,
-                                  FT_Stream         stream )
+                                  HB_Stream         stream )
 {
   HB_Error error;
 
@@ -859,7 +859,7 @@ static void  Free_LigatureSet( HB_LigatureSet*  ls )
 /* LigatureSubstFormat1 */
 
 static HB_Error  Load_LigatureSubst( HB_GSUB_SubTable* st,
-                                    FT_Stream         stream )
+                                    HB_Stream         stream )
 {
   HB_Error error;
   HB_LigatureSubst*  ls = &st->ligature;
@@ -969,7 +969,7 @@ static HB_Error  Lookup_LigatureSubst( HB_GSUBHeader*    gsub,
 
   HB_Ligature*  lig;
 
-  FT_UNUSED(nesting_level);
+  HB_UNUSED(nesting_level);
 
   if ( CHECK_Property( gdef, IN_CURITEM(), flags, &property ) )
     return error;
@@ -1142,7 +1142,7 @@ static HB_Error  Do_ContextSubst( HB_GSUBHeader*        gsub,
 /* SubRule */
 
 static HB_Error  Load_SubRule( HB_SubRule*  sr,
-                              FT_Stream     stream )
+                              HB_Stream     stream )
 {
   HB_Error error;
 
@@ -1218,7 +1218,7 @@ static void  Free_SubRule( HB_SubRule*  sr )
 /* SubRuleSet */
 
 static HB_Error  Load_SubRuleSet( HB_SubRuleSet*  srs,
-                                 FT_Stream        stream )
+                                 HB_Stream        stream )
 {
   HB_Error error;
 
@@ -1294,7 +1294,7 @@ static void  Free_SubRuleSet( HB_SubRuleSet*  srs )
 /* ContextSubstFormat1 */
 
 static HB_Error  Load_ContextSubst1( HB_ContextSubstFormat1*  csf1,
-                                    FT_Stream                 stream )
+                                    HB_Stream                 stream )
 {
   HB_Error error;
 
@@ -1389,7 +1389,7 @@ static void  Free_ContextSubst1( HB_ContextSubstFormat1* csf1 )
 
 static HB_Error  Load_SubClassRule( HB_ContextSubstFormat2*  csf2,
                                    HB_SubClassRule*         scr,
-                                   FT_Stream                 stream )
+                                   HB_Stream                 stream )
 {
   HB_Error error;
 
@@ -1478,7 +1478,7 @@ static void  Free_SubClassRule( HB_SubClassRule*  scr )
 
 static HB_Error  Load_SubClassSet( HB_ContextSubstFormat2*  csf2,
                                   HB_SubClassSet*          scs,
-                                  FT_Stream                 stream )
+                                  HB_Stream                 stream )
 {
   HB_Error error;
 
@@ -1555,7 +1555,7 @@ static void  Free_SubClassSet( HB_SubClassSet*  scs )
 /* ContextSubstFormat2 */
 
 static HB_Error  Load_ContextSubst2( HB_ContextSubstFormat2*  csf2,
-                                    FT_Stream                 stream )
+                                    HB_Stream                 stream )
 {
   HB_Error error;
 
@@ -1677,7 +1677,7 @@ static void  Free_ContextSubst2( HB_ContextSubstFormat2*  csf2 )
 /* ContextSubstFormat3 */
 
 static HB_Error  Load_ContextSubst3( HB_ContextSubstFormat3*  csf3,
-                                    FT_Stream                 stream )
+                                    HB_Stream                 stream )
 {
   HB_Error error;
 
@@ -1783,7 +1783,7 @@ static void  Free_ContextSubst3( HB_ContextSubstFormat3*  csf3 )
 /* ContextSubst */
 
 static HB_Error  Load_ContextSubst( HB_GSUB_SubTable* st,
-                                   FT_Stream         stream )
+                                   HB_Stream         stream )
 {
   HB_Error error;
   HB_ContextSubst*  cs = &st->context;
@@ -2068,7 +2068,7 @@ static HB_Error  Lookup_ContextSubst( HB_GSUBHeader*    gsub,
 /* ChainSubRule */
 
 static HB_Error  Load_ChainSubRule( HB_ChainSubRule*  csr,
-                                   FT_Stream          stream )
+                                   HB_Stream          stream )
 {
   HB_Error error;
 
@@ -2208,7 +2208,7 @@ static void  Free_ChainSubRule( HB_ChainSubRule*  csr )
 /* ChainSubRuleSet */
 
 static HB_Error  Load_ChainSubRuleSet( HB_ChainSubRuleSet*  csrs,
-                                      FT_Stream             stream )
+                                      HB_Stream             stream )
 {
   HB_Error error;
 
@@ -2285,7 +2285,7 @@ static void  Free_ChainSubRuleSet( HB_ChainSubRuleSet*  csrs )
 
 static HB_Error  Load_ChainContextSubst1(
                   HB_ChainContextSubstFormat1*  ccsf1,
-                  FT_Stream                      stream )
+                  HB_Stream                      stream )
 {
   HB_Error error;
 
@@ -2381,7 +2381,7 @@ static void  Free_ChainContextSubst1( HB_ChainContextSubstFormat1*  ccsf1 )
 static HB_Error  Load_ChainSubClassRule(
                   HB_ChainContextSubstFormat2*  ccsf2,
                   HB_ChainSubClassRule*         cscr,
-                  FT_Stream                      stream )
+                  HB_Stream                      stream )
 {
   HB_Error error;
 
@@ -2555,7 +2555,7 @@ static void  Free_ChainSubClassRule( HB_ChainSubClassRule*  cscr )
 static HB_Error  Load_ChainSubClassSet(
                   HB_ChainContextSubstFormat2*  ccsf2,
                   HB_ChainSubClassSet*          cscs,
-                  FT_Stream                      stream )
+                  HB_Stream                      stream )
 {
   HB_Error error;
 
@@ -2634,7 +2634,7 @@ static void  Free_ChainSubClassSet( HB_ChainSubClassSet*  cscs )
 
 static HB_Error  Load_ChainContextSubst2(
                   HB_ChainContextSubstFormat2*  ccsf2,
-                  FT_Stream                      stream )
+                  HB_Stream                      stream )
 {
   HB_Error error;
 
@@ -2779,7 +2779,7 @@ static void  Free_ChainContextSubst2( HB_ChainContextSubstFormat2*  ccsf2 )
 
 static HB_Error  Load_ChainContextSubst3(
                   HB_ChainContextSubstFormat3*  ccsf3,
-                  FT_Stream                      stream )
+                  HB_Stream                      stream )
 {
   HB_Error error;
 
@@ -2994,7 +2994,7 @@ static void  Free_ChainContextSubst3( HB_ChainContextSubstFormat3*  ccsf3 )
 /* ChainContextSubst */
 
 static HB_Error  Load_ChainContextSubst( HB_GSUB_SubTable* st,
-                                        FT_Stream         stream )
+                                        HB_Stream         stream )
 {
   HB_Error error;
   HB_ChainContextSubst*  ccs = &st->chain;
@@ -3485,7 +3485,7 @@ static HB_Error  Lookup_ChainContextSubst( HB_GSUBHeader*    gsub,
 
 
 static HB_Error  Load_ReverseChainContextSubst( HB_GSUB_SubTable* st,
-                                               FT_Stream         stream )
+                                               HB_Stream         stream )
 {
   HB_Error error;
   HB_ReverseChainContextSubst*  rccs = &st->reverse;
@@ -4114,7 +4114,7 @@ static HB_Error  GSUB_Do_Glyph_Lookup( HB_GSUBHeader* gsub,
 
 HB_INTERNAL HB_Error
 _HB_GSUB_Load_SubTable( HB_GSUB_SubTable* st,
-                       FT_Stream         stream,
+                       HB_Stream         stream,
                        HB_UShort         lookup_type )
 {
   switch (lookup_type) {
similarity index 76%
rename from src/ftglue.c
rename to src/harfbuzz-impl.c
index c565e42..4479cd4 100644 (file)
@@ -1,21 +1,17 @@
-/* ftglue.c: Glue code for compiling the OpenType code from
- *           FreeType 1 using only the public API of FreeType 2
- *
+/*
  * By David Turner, The FreeType Project (www.freetype.org)
  *
  * This code is explicitely put in the public domain
- *
- * See ftglue.h for more information.
  */
 
-#include "ftglue.h"
+#include "harfbuzz-impl.h"
 
 #if 0
 #include <stdio.h>
-#define  LOG(x)  _hb_ftglue_log x
+#define  LOG(x)  _hb_log x
 
 static void
-_hb_ftglue_log( const char*   format, ... )
+_hb_log( const char*   format, ... )
 {
   va_list  ap;
  
@@ -30,8 +26,8 @@ _hb_ftglue_log( const char*   format, ... )
 
 /* only used internally */
 static FT_Pointer
-_hb_ftglue_qalloc( HB_UInt   size,
-                  HB_Error  *perror )
+_hb_qalloc( HB_UInt   size,
+           HB_Error  *perror )
 {
   HB_Error    error = 0;
   FT_Pointer  block = NULL;
@@ -48,12 +44,12 @@ _hb_ftglue_qalloc( HB_UInt   size,
 }
 
 #undef   QALLOC  /* just in case */
-#define  QALLOC(ptr,size)    ( (ptr) = _hb_ftglue_qalloc( (size), &error ), error != 0 )
+#define  QALLOC(ptr,size)    ( (ptr) = _hb_qalloc( (size), &error ), error != 0 )
 
 
 HB_INTERNAL FT_Pointer
-_hb_ftglue_alloc( HB_UInt   size,
-                 HB_Error  *perror )
+_hb_alloc( HB_UInt   size,
+          HB_Error *perror )
 {
   HB_Error    error = 0;
   FT_Pointer  block = NULL;
@@ -73,9 +69,9 @@ _hb_ftglue_alloc( HB_UInt   size,
 
 
 HB_INTERNAL FT_Pointer
-_hb_ftglue_realloc( FT_Pointer  block,
-                   HB_UInt    new_size,
-                   HB_Error   *perror )
+_hb_realloc( FT_Pointer  block,
+            HB_UInt     new_size,
+            HB_Error   *perror )
 {
   FT_Pointer  block2 = NULL;
   HB_Error    error  = 0;
@@ -93,7 +89,7 @@ _hb_ftglue_realloc( FT_Pointer  block,
 
 
 HB_INTERNAL void
-_hb_ftglue_free( FT_Pointer  block )
+_hb_free( FT_Pointer  block )
 {
   if ( block )
     free( block );
@@ -101,16 +97,16 @@ _hb_ftglue_free( FT_Pointer  block )
 
 
 HB_INTERNAL HB_Int
-_hb_ftglue_stream_pos( FT_Stream   stream )
+_hb_stream_pos( HB_Stream   stream )
 {
-  LOG(( "ftglue:stream:pos() -> %ld\n", stream->pos ));
+  LOG(( "_hb_stream_pos() -> %ld\n", stream->pos ));
   return stream->pos;
 }
 
 
 HB_INTERNAL HB_Error
-_hb_ftglue_stream_seek( FT_Stream   stream,
-                    HB_Int     pos )
+_hb_stream_seek( HB_Stream stream,
+                HB_Int    pos )
 {
   HB_Error  error = 0;
 
@@ -123,14 +119,14 @@ _hb_ftglue_stream_seek( FT_Stream   stream,
   else if ( pos > (HB_Int)stream->size )
     error = HB_Err_Invalid_Stream_Operation;
 
-  LOG(( "ftglue:stream:seek(%ld) -> %d\n", pos, error ));
+  LOG(( "_hb_stream_seek(%ld) -> %d\n", pos, error ));
   return error;
 }
 
 
 HB_INTERNAL HB_Error
-_hb_ftglue_stream_frame_enter( FT_Stream   stream,
-                           HB_UInt    count )
+_hb_stream_frame_enter( HB_Stream stream,
+                       HB_UInt   count )
 {
   HB_Error  error = HB_Err_Ok;
   HB_UInt  read_bytes;
@@ -171,13 +167,13 @@ _hb_ftglue_stream_frame_enter( FT_Stream   stream,
   }
 
 Exit:
-  LOG(( "ftglue:stream:frame_enter(%ld) -> %d\n", count, error ));
+  LOG(( "_hb_stream_frame_enter(%ld) -> %d\n", count, error ));
   return error;
 }
 
 
 HB_INTERNAL void
-_hb_ftglue_stream_frame_exit( FT_Stream  stream )
+_hb_stream_frame_exit( HB_Stream  stream )
 {
   if ( stream->read )
   {
@@ -186,18 +182,18 @@ _hb_ftglue_stream_frame_exit( FT_Stream  stream )
   stream->cursor = NULL;
   stream->limit  = NULL;
 
-  LOG(( "ftglue:stream:frame_exit()\n" ));
+  LOG(( "_hb_stream_frame_exit()\n" ));
 }
 
 
 HB_INTERNAL HB_Error
-_hb_ftglue_face_goto_table( FT_Face    face,
-                        HB_UInt   the_tag,
-                        FT_Stream  stream )
+_hb_face_goto_table( FT_Face    face,
+                    HB_UInt   the_tag,
+                    HB_Stream  stream )
 {
   HB_Error  error;
 
-  LOG(( "_hb_ftglue_face_goto_table( %p, %c%c%c%c, %p )\n",
+  LOG(( "_hb_face_goto_table( %p, %c%c%c%c, %p )\n",
                 face, 
                 (int)((the_tag >> 24) & 0xFF), 
                 (int)((the_tag >> 16) & 0xFF), 
@@ -253,13 +249,13 @@ _hb_ftglue_face_goto_table( FT_Face    face,
       HB_UInt  start    = GET_ULong();
       HB_UInt  size     = GET_ULong();
 
-      FT_UNUSED(checksum);
-      FT_UNUSED(size);
+      HB_UNUSED(checksum);
+      HB_UNUSED(size);
       
       if ( tag == the_tag )
       {
         LOG(( "TrueType table (start: %ld) (size: %ld)\n", start, size ));
-        error = _hb_ftglue_stream_seek( stream, start );
+        error = _hb_stream_seek( stream, start );
         goto FoundIt;
       }
     }
index 6fd04da..353123b 100644 (file)
 
 HB_BEGIN_HEADER
 
+/***********************************************************************/
+/************************ remaining freetype bits **********************/
+/***********************************************************************/
+
+typedef FT_Stream HB_Stream;
+#define HB_MAKE_TAG(a,b,c,d) FT_MAKE_TAG(a,b,c,d)
+
+/***********************************************************************/
+/***********************************************************************/
+/***********************************************************************/
+
 #ifndef HB_INTERNAL
 # define HB_INTERNAL
 #endif
@@ -38,28 +49,117 @@ HB_BEGIN_HEADER
 #endif
 
 #ifndef TTAG_GDEF
-# define TTAG_GDEF  FT_MAKE_TAG( 'G', 'D', 'E', 'F' )
+# define TTAG_GDEF  HB_MAKE_TAG( 'G', 'D', 'E', 'F' )
 #endif
 #ifndef TTAG_GPOS
-# define TTAG_GPOS  FT_MAKE_TAG( 'G', 'P', 'O', 'S' )
+# define TTAG_GPOS  HB_MAKE_TAG( 'G', 'P', 'O', 'S' )
 #endif
 #ifndef TTAG_GSUB
-# define TTAG_GSUB  FT_MAKE_TAG( 'G', 'S', 'U', 'B' )
+# define TTAG_GSUB  HB_MAKE_TAG( 'G', 'S', 'U', 'B' )
 #endif
 
-#ifndef FT_UNUSED
-# define FT_UNUSED(arg) ((arg) = (arg))
+#ifndef HB_UNUSED
+# define HB_UNUSED(arg) ((arg) = (arg))
 #endif
 
 #define HB_LIKELY(cond) (cond)
 #define HB_UNLIKELY(cond) (cond)
 
-#include "ftglue.h"
-
 #define ARRAY_LEN(Array) ((int)(sizeof (Array) / sizeof (Array)[0]))
 
 
+/* memory and stream management */
+
+#define  SET_ERR(c)   ( (error = (c)) != 0 )
+
+/* stream macros used by the OpenType parser */
+#define  GOTO_Table(tag) SET_ERR( _hb_face_goto_table( face, tag, stream ) )
+#define  FILE_Pos()      _hb_stream_pos( stream )
+#define  FILE_Seek(pos)  SET_ERR( _hb_stream_seek( stream, pos ) )
+#define  ACCESS_Frame(size)  SET_ERR( _hb_stream_frame_enter( stream, size ) )
+#define  FORGET_Frame()      _hb_stream_frame_exit( stream )
+
+#define  GET_Byte()      (*stream->cursor++)
+#define  GET_Short()     (stream->cursor += 2, (HB_Short)( \
+                               (*(((FT_Byte*)stream->cursor)-2) << 8) | \
+                                *(((FT_Byte*)stream->cursor)-1) \
+                        ))
+#define  GET_Long()      (stream->cursor += 4, (HB_Int)( \
+                               (*(((FT_Byte*)stream->cursor)-4) << 24) | \
+                               (*(((FT_Byte*)stream->cursor)-3) << 16) | \
+                               (*(((FT_Byte*)stream->cursor)-2) << 8) | \
+                                *(((FT_Byte*)stream->cursor)-1) \
+                        ))
+
+
+#define  GET_Char()      ((FT_Char)GET_Byte())
+#define  GET_UShort()    ((HB_UShort)GET_Short())
+#define  GET_ULong()     ((HB_UInt)GET_Long())
+#define  GET_Tag4()      GET_ULong()
+
+
+HB_INTERNAL HB_Int
+_hb_stream_pos( HB_Stream   stream );
+
+HB_INTERNAL HB_Error
+_hb_stream_seek( HB_Stream   stream,
+                    HB_Int     pos );
+
+HB_INTERNAL HB_Error
+_hb_stream_frame_enter( HB_Stream   stream,
+                           HB_UInt    size );
+
+HB_INTERNAL void
+_hb_stream_frame_exit( HB_Stream  stream );
+
+HB_INTERNAL HB_Error
+_hb_face_goto_table( FT_Face    face,
+                        HB_UInt   tag,
+                        HB_Stream  stream );
+
+#define  ALLOC(_ptr,_size)   \
+           ( (_ptr) = _hb_alloc( _size, &error ), error != 0 )
+
+#define  REALLOC(_ptr,_newsz)  \
+           ( (_ptr) = _hb_realloc( (_ptr), (_newsz), &error ), error != 0 )
+
+#define  FREE(_ptr)                    \
+  do {                                 \
+    if ( (_ptr) )                      \
+    {                                  \
+      _hb_free( _ptr );                \
+      _ptr = NULL;                     \
+    }                                  \
+  } while (0)
+
+#define  ALLOC_ARRAY(_ptr,_count,_type)   \
+           ALLOC(_ptr,(_count)*sizeof(_type))
+
+#define  REALLOC_ARRAY(_ptr,_newcnt,_type) \
+           REALLOC(_ptr,(_newcnt)*sizeof(_type))
+
+#define  MEM_Copy(dest,source,count)   memcpy( (char*)(dest), (const char*)(source), (size_t)(count) )
+
+
+HB_INTERNAL FT_Pointer
+_hb_alloc( HB_UInt   size,
+          HB_Error  *perror_ );
+
+HB_INTERNAL FT_Pointer
+_hb_realloc( FT_Pointer  block,
+            HB_UInt    new_size,
+            HB_Error   *perror_ );
+
+HB_INTERNAL void
+_hb_free( FT_Pointer  block );
+
+
+/* helper func to set a breakpoint on */
+HB_INTERNAL HB_Error
+_hb_err (HB_Error code);
+
 
+/* buffer access macros */
 
 #define IN_GLYPH( pos )        (buffer->in_string[(pos)].gindex)
 #define IN_ITEM( pos )         (&buffer->in_string[(pos)])
index de566e3..125bd09 100644 (file)
@@ -33,31 +33,31 @@ struct  HB_SubTable_
 
 HB_INTERNAL HB_Error
 _HB_OPEN_Load_ScriptList( HB_ScriptList* sl,
-                          FT_Stream     stream );
+                          HB_Stream     stream );
 HB_INTERNAL HB_Error
 _HB_OPEN_Load_FeatureList( HB_FeatureList* fl,
-                          FT_Stream       input );
+                          HB_Stream       input );
 HB_INTERNAL HB_Error
 _HB_OPEN_Load_LookupList( HB_LookupList*  ll,
-                         FT_Stream       input,
+                         HB_Stream       input,
                          HB_Type         type );
 
 HB_INTERNAL HB_Error
 _HB_OPEN_Load_Coverage( HB_Coverage* c,
-                       FT_Stream    input );
+                       HB_Stream    input );
 HB_INTERNAL HB_Error
 _HB_OPEN_Load_ClassDefinition( HB_ClassDefinition* cd,
                               HB_UShort           limit,
-                              FT_Stream           input );
+                              HB_Stream           input );
 HB_INTERNAL HB_Error
 _HB_OPEN_Load_EmptyOrClassDefinition( HB_ClassDefinition* cd,
                                      HB_UShort           limit,
                                      HB_UInt            class_offset,
                                      HB_UInt            base_offset,
-                                     FT_Stream           stream );
+                                     HB_Stream           stream );
 HB_INTERNAL HB_Error
 _HB_OPEN_Load_Device( HB_Device* d,
-                     FT_Stream  input );
+                     HB_Stream  input );
 
 HB_INTERNAL void  _HB_OPEN_Free_ScriptList( HB_ScriptList*  sl );
 HB_INTERNAL void  _HB_OPEN_Free_FeatureList( HB_FeatureList*  fl );
index 5f997e2..dfdaefd 100644 (file)
@@ -22,7 +22,7 @@
 /* LangSys */
 
 static HB_Error  Load_LangSys( HB_LangSys*  ls,
-                              FT_Stream     stream )
+                              HB_Stream     stream )
 {
   HB_Error   error;
   HB_UShort  n, count;
@@ -69,7 +69,7 @@ static void  Free_LangSys( HB_LangSys*  ls )
 /* Script */
 
 static HB_Error  Load_Script( HB_Script*  s,
-                             FT_Stream    stream )
+                             HB_Stream    stream )
 {
   HB_Error   error;
   HB_UShort  n, m, count;
@@ -186,7 +186,7 @@ static void  Free_Script( HB_Script*  s )
 
 HB_INTERNAL HB_Error
 _HB_OPEN_Load_ScriptList( HB_ScriptList* sl,
-                         FT_Stream      stream )
+                         HB_Stream      stream )
 {
   HB_Error   error;
 
@@ -289,7 +289,7 @@ _HB_OPEN_Free_ScriptList( HB_ScriptList* sl )
 /* Feature */
 
 static HB_Error  Load_Feature( HB_Feature*  f,
-                              FT_Stream     stream )
+                              HB_Stream     stream )
 {
   HB_Error   error;
 
@@ -338,7 +338,7 @@ static void  Free_Feature( HB_Feature*  f )
 
 HB_INTERNAL HB_Error
 _HB_OPEN_Load_FeatureList( HB_FeatureList* fl,
-                          FT_Stream       stream )
+                          HB_Stream       stream )
 {
   HB_Error   error;
 
@@ -435,7 +435,7 @@ _HB_OPEN_Free_FeatureList( HB_FeatureList*  fl )
 /* SubTable */
 
 static HB_Error  Load_SubTable( HB_SubTable*  st,
-                               FT_Stream     stream,
+                               HB_Stream     stream,
                                HB_Type       table_type,
                                HB_UShort     lookup_type )
 {
@@ -460,7 +460,7 @@ static void  Free_SubTable( HB_SubTable*  st,
 /* Lookup */
 
 static HB_Error  Load_Lookup( HB_Lookup*   l,
-                             FT_Stream     stream,
+                             HB_Stream     stream,
                              HB_Type      type )
 {
   HB_Error   error;
@@ -563,7 +563,7 @@ static void  Free_Lookup( HB_Lookup*   l,
 
 HB_INTERNAL HB_Error
 _HB_OPEN_Load_LookupList( HB_LookupList* ll,
-                         FT_Stream      stream,
+                         HB_Stream      stream,
                          HB_Type        type )
 {
   HB_Error   error;
@@ -655,7 +655,7 @@ _HB_OPEN_Free_LookupList( HB_LookupList* ll,
 /* CoverageFormat1 */
 
 static HB_Error  Load_Coverage1( HB_CoverageFormat1*  cf1,
-                                FT_Stream             stream )
+                                HB_Stream             stream )
 {
   HB_Error   error;
 
@@ -702,7 +702,7 @@ static void  Free_Coverage1( HB_CoverageFormat1*  cf1 )
 /* CoverageFormat2 */
 
 static HB_Error  Load_Coverage2( HB_CoverageFormat2*  cf2,
-                                FT_Stream             stream )
+                                HB_Stream             stream )
 {
   HB_Error   error;
 
@@ -762,7 +762,7 @@ static void  Free_Coverage2( HB_CoverageFormat2*  cf2 )
 
 HB_INTERNAL HB_Error
 _HB_OPEN_Load_Coverage( HB_Coverage* c,
-                       FT_Stream    stream )
+                       HB_Stream    stream )
 {
   HB_Error   error;
 
@@ -922,7 +922,7 @@ _HB_OPEN_Coverage_Index( HB_Coverage* c,
 
 static HB_Error  Load_ClassDef1( HB_ClassDefinition*  cd,
                                 HB_UShort             limit,
-                                FT_Stream             stream )
+                                HB_Stream             stream )
 {
   HB_Error   error;
 
@@ -992,7 +992,7 @@ static void  Free_ClassDef1( HB_ClassDefFormat1*  cdf1 )
 
 static HB_Error  Load_ClassDef2( HB_ClassDefinition*  cd,
                                 HB_UShort             limit,
-                                FT_Stream             stream )
+                                HB_Stream             stream )
 {
   HB_Error   error;
 
@@ -1071,7 +1071,7 @@ static void  Free_ClassDef2( HB_ClassDefFormat2*  cdf2 )
 HB_INTERNAL HB_Error
 _HB_OPEN_Load_ClassDefinition( HB_ClassDefinition* cd,
                               HB_UShort           limit,
-                              FT_Stream           stream )
+                              HB_Stream           stream )
 {
   HB_Error   error;
 
@@ -1131,7 +1131,7 @@ _HB_OPEN_Load_EmptyOrClassDefinition( HB_ClassDefinition* cd,
                                      HB_UShort           limit,
                                      HB_UInt            class_offset,
                                      HB_UInt            base_offset,
-                                     FT_Stream           stream )
+                                     HB_Stream           stream )
 {
   HB_Error error;
   HB_UInt               cur_offset;
@@ -1292,7 +1292,7 @@ _HB_OPEN_Get_Class( HB_ClassDefinition* cd,
 
 HB_INTERNAL HB_Error
 _HB_OPEN_Load_Device( HB_Device* d,
-                     FT_Stream  stream )
+                     HB_Stream  stream )
 {
   HB_Error   error;
 
index 73857f8..fd9c110 100644 (file)
@@ -27,22 +27,6 @@ HB_BEGIN_HEADER
 
 #define HB_MAX_NESTING_LEVEL             100
 
-typedef FT_Error HB_Error;
-
-#define HB_Err_Invalid_Argument          FT_Err_Invalid_Argument
-#define HB_Err_Invalid_Face_Handle       FT_Err_Invalid_Face_Handle
-#define HB_Err_Invalid_Stream_Operation  FT_Err_Invalid_Stream_Operation
-#define HB_Err_Empty_Script              0x1005
-
-#define HB_Err_Ok                        FT_Err_Ok
-#define HB_Err_Not_Covered               0x1002
-#define HB_Err_Out_Of_Memory             FT_Err_Out_Of_Memory
-#define HB_Err_Table_Missing             FT_Err_Table_Missing
-#define HB_Err_Invalid_SubTable_Format   0x1000
-#define HB_Err_Invalid_SubTable          0x1001
-#define HB_Err_Too_Many_Nested_Contexts  0x1003
-#define HB_Err_No_MM_Interpreter         0x1004
-
 
 /* Script list related structures */
 
index 78f06a9..1128746 100644 (file)
@@ -11,9 +11,9 @@
  *
  ******************************************************************/
 #define HB_INTERNAL static
-#include "ftglue.c"
-#include "harfbuzz-open.c"
 #include "harfbuzz-buffer.c"
 #include "harfbuzz-gdef.c"
 #include "harfbuzz-gsub.c"
 #include "harfbuzz-gpos.c"
+#include "harfbuzz-impl.c"
+#include "harfbuzz-open.c"