Blame src/ftglue.h

Packit 352660
/* ftglue.c: Glue code for compiling the OpenType code from
Packit 352660
 *           FreeType 1 using only the public API of FreeType 2
Packit 352660
 *
Packit 352660
 * By David Turner, The FreeType Project (www.freetype.org)
Packit 352660
 *
Packit 352660
 * This code is explicitely put in the public domain
Packit 352660
 *
Packit 352660
 * ==========================================================================
Packit 352660
 *
Packit 352660
 * the OpenType parser codes was originally written as an extension to
Packit 352660
 * FreeType 1.x. As such, its source code was embedded within the library,
Packit 352660
 * and used many internal FreeType functions to deal with memory and
Packit 352660
 * stream i/o.
Packit 352660
 *
Packit 352660
 * When it was 'salvaged' for Pango and Qt, the code was "ported" to FreeType 2,
Packit 352660
 * which basically means that some macro tricks were performed in order to
Packit 352660
 * directly access FT2 _internal_ functions.
Packit 352660
 *
Packit 352660
 * these functions were never part of FT2 public API, and _did_ change between
Packit 352660
 * various releases. This created chaos for many users: when they upgraded the
Packit 352660
 * FreeType library on their system, they couldn't run Gnome anymore since
Packit 352660
 * Pango refused to link.
Packit 352660
 *
Packit 352660
 * Very fortunately, it's possible to completely avoid this problem because
Packit 352660
 * the FT_StreamRec and FT_MemoryRec structure types, which describe how
Packit 352660
 * memory and stream implementations interface with the rest of the font
Packit 352660
 * library, have always been part of the public API, and never changed.
Packit 352660
 *
Packit 352660
 * What we do thus is re-implement, within the OpenType parser, the few
Packit 352660
 * functions that depend on them. This only adds one or two kilobytes of
Packit 352660
 * code, and ensures that the parser can work with _any_ version
Packit 352660
 * of FreeType installed on your system. How sweet... !
Packit 352660
 *
Packit 352660
 * Note that we assume that Pango doesn't use any other internal functions
Packit 352660
 * from FreeType. It used to in old versions, but this should no longer
Packit 352660
 * be the case. (crossing my fingers).
Packit 352660
 *
Packit 352660
 *  - David Turner
Packit 352660
 *  - The FreeType Project  (www.freetype.org)
Packit 352660
 *
Packit 352660
 * PS: This "glue" code is explicitely put in the public domain
Packit 352660
 */
Packit 352660
#ifndef __OPENTYPE_FTGLUE_H__
Packit 352660
#define __OPENTYPE_FTGLUE_H__
Packit 352660
Packit 352660
#include "fcint.h"
Packit 352660
Packit 352660
#include <ft2build.h>
Packit 352660
#include FT_FREETYPE_H
Packit 352660
Packit 352660
FT_BEGIN_HEADER
Packit 352660
Packit 352660
Packit 352660
#define  SET_ERR(c)   ( (error = (c)) != 0 )
Packit 352660
Packit 352660
#ifndef FTGLUE_API
Packit 352660
#define FTGLUE_API(x)  extern FcPrivate x
Packit 352660
#endif
Packit 352660
Packit 352660
#ifndef FTGLUE_APIDEF
Packit 352660
#define FTGLUE_APIDEF(x)  x
Packit 352660
#endif
Packit 352660
Packit 352660
/* stream macros used by the OpenType parser */
Packit 352660
#define  FILE_Pos()      ftglue_stream_pos( stream )
Packit 352660
#define  FILE_Seek(pos)  SET_ERR( ftglue_stream_seek( stream, pos ) )
Packit 352660
#define  ACCESS_Frame(size)  SET_ERR( ftglue_stream_frame_enter( stream, size ) )
Packit 352660
#define  FORGET_Frame()      ftglue_stream_frame_exit( stream )
Packit 352660
Packit 352660
#define  GET_Byte()      (*stream->cursor++)
Packit 352660
#define  GET_Short()     (stream->cursor += 2, (FT_Short)( \
Packit 352660
				((FT_ULong)*(((FT_Byte*)stream->cursor)-2) << 8) | \
Packit 352660
				 (FT_ULong)*(((FT_Byte*)stream->cursor)-1) \
Packit 352660
			 ))
Packit 352660
#define  GET_Long()      (stream->cursor += 4, (FT_Long)( \
Packit 352660
				((FT_ULong)*(((FT_Byte*)stream->cursor)-4) << 24) | \
Packit 352660
				((FT_ULong)*(((FT_Byte*)stream->cursor)-3) << 16) | \
Packit 352660
				((FT_ULong)*(((FT_Byte*)stream->cursor)-2) << 8) | \
Packit 352660
				 (FT_ULong)*(((FT_Byte*)stream->cursor)-1) \
Packit 352660
			 ))
Packit 352660
Packit 352660
#define  GET_Char()      ((FT_Char)GET_Byte())
Packit 352660
#define  GET_UShort()    ((FT_UShort)GET_Short())
Packit 352660
#define  GET_ULong()     ((FT_ULong)GET_Long())
Packit 352660
#define  GET_Tag4()      GET_ULong()
Packit 352660
Packit 352660
#define FT_SET_ERROR( expression ) \
Packit 352660
          ( ( error = (expression) ) != 0 )
Packit 352660
Packit 352660
FTGLUE_API( FT_Long )
Packit 352660
ftglue_stream_pos( FT_Stream   stream );
Packit 352660
Packit 352660
FTGLUE_API( FT_Error )
Packit 352660
ftglue_stream_seek( FT_Stream   stream,
Packit 352660
                    FT_Long     pos );
Packit 352660
Packit 352660
FTGLUE_API( FT_Error )
Packit 352660
ftglue_stream_frame_enter( FT_Stream   stream,
Packit 352660
                           FT_ULong    size );
Packit 352660
Packit 352660
FTGLUE_API( void )
Packit 352660
ftglue_stream_frame_exit( FT_Stream  stream );
Packit 352660
Packit 352660
FTGLUE_API( FT_Error )
Packit 352660
ftglue_face_goto_table( FT_Face    face,
Packit 352660
                        FT_ULong   tag,
Packit 352660
                        FT_Stream  stream );
Packit 352660
Packit 352660
FT_END_HEADER
Packit 352660
Packit 352660
#endif /* __OPENTYPE_FTGLUE_H__ */