Eneboo - Documentación para desarrolladores
src/qt/src/3rdparty/opentype/ftglue.h
Ir a la documentación de este archivo.
00001 /* ftglue.c: Glue code for compiling the OpenType code from
00002  *           FreeType 1 using only the public API of FreeType 2
00003  *
00004  * By David Turner, The FreeType Project (www.freetype.org)
00005  *
00006  * This code is explicitely put in the public domain
00007  *
00008  * ==========================================================================
00009  *
00010  * the OpenType parser codes was originally written as an extension to
00011  * FreeType 1.x. As such, its source code was embedded within the library,
00012  * and used many internal FreeType functions to deal with memory and
00013  * stream i/o.
00014  *
00015  * When it was 'salvaged' for Pango and Qt, the code was "ported" to FreeType 2,
00016  * which basically means that some macro tricks were performed in order to
00017  * directly access FT2 _internal_ functions.
00018  *
00019  * these functions were never part of FT2 public API, and _did_ change between
00020  * various releases. This created chaos for many users: when they upgraded the
00021  * FreeType library on their system, they couldn't run Gnome anymore since
00022  * Pango refused to link.
00023  *
00024  * Very fortunately, it's possible to completely avoid this problem because
00025  * the FT_StreamRec and FT_MemoryRec structure types, which describe how
00026  * memory and stream implementations interface with the rest of the font
00027  * library, have always been part of the public API, and never changed.
00028  *
00029  * What we do thus is re-implement, within the OpenType parser, the few
00030  * functions that depend on them. This only adds one or two kilobytes of
00031  * code, and ensures that the parser can work with _any_ version
00032  * of FreeType installed on your system. How sweet... !
00033  *
00034  * Note that we assume that Pango doesn't use any other internal functions
00035  * from FreeType. It used to in old versions, but this should no longer
00036  * be the case. (crossing my fingers).
00037  *
00038  *  - David Turner
00039  *  - The FreeType Project  (www.freetype.org)
00040  *
00041  * PS: This "glue" code is explicitely put in the public domain
00042  */
00043 #ifndef __OPENTYPE_FTGLUE_H__
00044 #define __OPENTYPE_FTGLUE_H__
00045 
00046 #include <ft2build.h>
00047 #include FT_FREETYPE_H
00048 
00049 FT_BEGIN_HEADER
00050 
00051 #ifndef FALSE
00052 #define FALSE 0
00053 #endif
00054 #ifndef TRUE
00055 #define TRUE 1
00056 #endif
00057 
00058 /* utility macros */
00059 #define  TT_Err_Ok                   FT_Err_Ok
00060 #define  TT_Err_Invalid_Argument     FT_Err_Invalid_Argument
00061 #define  TT_Err_Invalid_Face_Handle  FT_Err_Invalid_Face_Handle
00062 #define  TT_Err_Table_Missing        FT_Err_Table_Missing
00063 
00064 #define  SET_ERR(c)   ( (error = (c)) != 0 )
00065 
00066 #ifndef FTGLUE_API
00067 #define FTGLUE_API(x)  extern x
00068 #endif
00069 
00070 #ifndef FTGLUE_APIDEF
00071 #define FTGLUE_APIDEF(x)  x
00072 #endif
00073 
00074 /* stream macros used by the OpenType parser */
00075 #define  FILE_Pos()      ftglue_stream_pos( stream )
00076 #define  FILE_Seek(pos)  SET_ERR( ftglue_stream_seek( stream, pos ) )
00077 #define  ACCESS_Frame(size)  SET_ERR( ftglue_stream_frame_enter( stream, size ) )
00078 #define  FORGET_Frame()      ftglue_stream_frame_exit( stream )
00079 
00080 #define  GET_Byte()      ftglue_stream_get_byte( stream )
00081 #define  GET_Short()     ftglue_stream_get_short( stream )
00082 #define  GET_Long()      ftglue_stream_get_long( stream )
00083 
00084 #define  GET_Char()      ((FT_Char)GET_Byte())
00085 #define  GET_UShort()    ((FT_UShort)GET_Short())
00086 #define  GET_ULong()     ((FT_ULong)GET_Long())
00087 #define  GET_Tag4()      GET_ULong()
00088 
00089 FTGLUE_API( FT_Long )
00090 ftglue_stream_pos( FT_Stream   stream );
00091 
00092 FTGLUE_API( FT_Error )
00093 ftglue_stream_seek( FT_Stream   stream,
00094                     FT_Long     pos );
00095 
00096 FTGLUE_API( FT_Error )
00097 ftglue_stream_frame_enter( FT_Stream   stream,
00098                            FT_ULong    size );
00099 
00100 FTGLUE_API( void )
00101 ftglue_stream_frame_exit( FT_Stream  stream );
00102 
00103 FTGLUE_API( FT_Byte )
00104 ftglue_stream_get_byte( FT_Stream  stream );
00105 
00106 FTGLUE_API( FT_Short )
00107 ftglue_stream_get_short( FT_Stream  stream );
00108 
00109 FTGLUE_API( FT_Long )
00110 ftglue_stream_get_long( FT_Stream   stream );
00111 
00112 FTGLUE_API( FT_Error )
00113 ftglue_face_goto_table( FT_Face    face,
00114                         FT_ULong   tag,
00115                         FT_Stream  stream );
00116 
00117 /* memory macros used by the OpenType parser */
00118 #define  ALLOC(_ptr,_size)   \
00119            ( (_ptr) = ftglue_alloc( memory, _size, &error ), error != 0 )
00120 
00121 #define  REALLOC(_ptr,_oldsz,_newsz)  \
00122            ( (_ptr) = ftglue_realloc( memory, (_ptr), (_oldsz), (_newsz), &error ), error != 0 )
00123 
00124 #define  FREE(_ptr)                    \
00125   do {                                 \
00126     if ( (_ptr) )                      \
00127     {                                  \
00128       ftglue_free( memory, _ptr );     \
00129       _ptr = NULL;                     \
00130     }                                  \
00131   } while (0)
00132 
00133 #define  ALLOC_ARRAY(_ptr,_count,_type)   \
00134            ALLOC(_ptr,(_count)*sizeof(_type))
00135 
00136 #define  REALLOC_ARRAY(_ptr,_oldcnt,_newcnt,_type) \
00137            REALLOC(_ptr,(_oldcnt)*sizeof(_type),(_newcnt)*sizeof(_type))
00138 
00139 #define  MEM_Copy(dest,source,count)   memcpy( (char*)(dest), (const char*)(source), (size_t)(count) )
00140 
00141 
00142 FTGLUE_API( FT_Pointer )
00143 ftglue_alloc( FT_Memory  memory,
00144               FT_ULong   size,
00145               FT_Error  *perror_ );
00146 
00147 FTGLUE_API( FT_Pointer )
00148 ftglue_realloc( FT_Memory   memory,
00149                 FT_Pointer  block,
00150                 FT_ULong    old_size,
00151                 FT_ULong    new_size,
00152                 FT_Error   *perror_ );
00153 
00154 FTGLUE_API( void )
00155 ftglue_free( FT_Memory   memory,
00156              FT_Pointer  block );
00157 
00158 /* */
00159 
00160 FT_END_HEADER
00161 
00162 #endif /* __OPENTYPE_FTGLUE_H__ */
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'