]>
git.wh0rd.org - fontconfig.git/blob - src/ftglue.h
1 /* ftglue.c: Glue code for compiling the OpenType code from
2 * FreeType 1 using only the public API of FreeType 2
4 * By David Turner, The FreeType Project (www.freetype.org)
6 * This code is explicitely put in the public domain
8 * ==========================================================================
10 * the OpenType parser codes was originally written as an extension to
11 * FreeType 1.x. As such, its source code was embedded within the library,
12 * and used many internal FreeType functions to deal with memory and
15 * When it was 'salvaged' for Pango and Qt, the code was "ported" to FreeType 2,
16 * which basically means that some macro tricks were performed in order to
17 * directly access FT2 _internal_ functions.
19 * these functions were never part of FT2 public API, and _did_ change between
20 * various releases. This created chaos for many users: when they upgraded the
21 * FreeType library on their system, they couldn't run Gnome anymore since
22 * Pango refused to link.
24 * Very fortunately, it's possible to completely avoid this problem because
25 * the FT_StreamRec and FT_MemoryRec structure types, which describe how
26 * memory and stream implementations interface with the rest of the font
27 * library, have always been part of the public API, and never changed.
29 * What we do thus is re-implement, within the OpenType parser, the few
30 * functions that depend on them. This only adds one or two kilobytes of
31 * code, and ensures that the parser can work with _any_ version
32 * of FreeType installed on your system. How sweet... !
34 * Note that we assume that Pango doesn't use any other internal functions
35 * from FreeType. It used to in old versions, but this should no longer
36 * be the case. (crossing my fingers).
39 * - The FreeType Project (www.freetype.org)
41 * PS: This "glue" code is explicitely put in the public domain
43 #ifndef __OPENTYPE_FTGLUE_H__
44 #define __OPENTYPE_FTGLUE_H__
49 #include FT_FREETYPE_H
54 #define SET_ERR(c) ( (error = (c)) != 0 )
57 #define FTGLUE_API(x) extern FcPrivate x
61 #define FTGLUE_APIDEF(x) x
64 /* stream macros used by the OpenType parser */
65 #define FILE_Pos() ftglue_stream_pos( stream )
66 #define FILE_Seek(pos) SET_ERR( ftglue_stream_seek( stream, pos ) )
67 #define ACCESS_Frame(size) SET_ERR( ftglue_stream_frame_enter( stream, size ) )
68 #define FORGET_Frame() ftglue_stream_frame_exit( stream )
70 #define GET_Byte() (*stream->cursor++)
71 #define GET_Short() (stream->cursor += 2, (FT_Short)( \
72 (*(((FT_Byte*)stream->cursor)-2) << 8) | \
73 *(((FT_Byte*)stream->cursor)-1) \
75 #define GET_Long() (stream->cursor += 4, (FT_Long)( \
76 (*(((FT_Byte*)stream->cursor)-4) << 24) | \
77 (*(((FT_Byte*)stream->cursor)-3) << 16) | \
78 (*(((FT_Byte*)stream->cursor)-2) << 8) | \
79 *(((FT_Byte*)stream->cursor)-1) \
82 #define GET_Char() ((FT_Char)GET_Byte())
83 #define GET_UShort() ((FT_UShort)GET_Short())
84 #define GET_ULong() ((FT_ULong)GET_Long())
85 #define GET_Tag4() GET_ULong()
87 #define FT_SET_ERROR( expression ) \
88 ( ( error = (expression) ) != 0 )
91 ftglue_stream_pos( FT_Stream stream
);
93 FTGLUE_API( FT_Error
)
94 ftglue_stream_seek( FT_Stream stream
,
97 FTGLUE_API( FT_Error
)
98 ftglue_stream_frame_enter( FT_Stream stream
,
102 ftglue_stream_frame_exit( FT_Stream stream
);
104 FTGLUE_API( FT_Error
)
105 ftglue_face_goto_table( FT_Face face
,
111 #endif /* __OPENTYPE_FTGLUE_H__ */