1 /* Copyright (C) 2001-2012 Artifex Software, Inc.
2    All Rights Reserved.
3 
4    This software is provided AS-IS with no warranty, either express or
5    implied.
6 
7    This software is distributed under license and may not be copied,
8    modified or distributed except as expressly authorized under the terms
9    of the license contained in the file LICENSE in this distribution.
10 
11    Refer to licensing information at http://www.artifex.com or contact
12    Artifex Software, Inc.,  7 Mt. Lassen Drive - Suite A-134, San Rafael,
13    CA  94903, U.S.A., +1(415)492-9861, for further information.
14 */
15 
16 
17 
18 /* Changes after FreeType: cut out the TrueType instruction interpreter. */
19 
20 /*******************************************************************
21  *
22  *  ttload.h                                                    1.1
23  *
24  *    TrueType Tables Loader.
25  *
26  *  Copyright 1996-1998 by
27  *  David Turner, Robert Wilhelm, and Werner Lemberg.
28  *
29  *  This file is part of the FreeType project, and may only be used
30  *  modified and distributed under the terms of the FreeType project
31  *  license, LICENSE.TXT.  By continuing to use, modify, or distribute
32  *  this file you indicate that you have read the license and
33  *  understand and accept it fully.
34  *
35  *
36  *  Changes between 1.1 and 1.0 :
37  *
38  *  - add function Load_TrueType_Any used by TT_Get_Font_Data
39  *
40  ******************************************************************/
41 
42 #ifndef TTLOAD_H
43 #define TTLOAD_H
44 
45 #include "ttcommon.h"
46 
47 #ifdef __cplusplus
48   extern "C" {
49 #endif
50 
51   Int  LookUp_TrueType_Table( PFace  face,
52                               Long   tag  );
53 
54   TT_Error  Load_TrueType_Directory        ( PFace  face,
55                                              int    faceIndex );
56 
57   TT_Error  Load_TrueType_MaxProfile       ( PFace  face );
58   TT_Error  Load_TrueType_Gasp             ( PFace  face );
59   TT_Error  Load_TrueType_Header           ( PFace  face );
60   TT_Error  Load_TrueType_Horizontal_Header( PFace  face );
61   TT_Error  Load_TrueType_Locations        ( PFace  face );
62   TT_Error  Load_TrueType_Names            ( PFace  face );
63   TT_Error  Load_TrueType_CVT              ( PFace  face );
64   TT_Error  Load_TrueType_CMap             ( PFace  face );
65   TT_Error  Load_TrueType_HMTX             ( PFace  face );
66   TT_Error  Load_TrueType_Programs         ( PFace  face );
67   TT_Error  Load_TrueType_OS2              ( PFace  face );
68   TT_Error  Load_TrueType_PostScript       ( PFace  face );
69   TT_Error  Load_TrueType_Hdmx             ( PFace  face );
70 
71   TT_Error  Load_TrueType_Any( PFace  face,
72                                Long   tag,
73                                Long   offset,
74                                void*  buffer,
75                                Long*  length );
76 
77   TT_Error  Free_TrueType_Names( PFace  face );
78   TT_Error  Free_TrueType_Hdmx ( PFace  face );
79 
80 /* The following macros are defined to simplify the writing of */
81 /* the various table and glyph loaders.                        */
82 
83 /* For examples see the code in ttload.c, ttgload.c etc.       */
84 
85 #define USE_Stream( original, duplicate ) \
86           ( error = TT_Use_Stream( original, &duplicate ) )
87 
88 #define DONE_Stream( _stream ) \
89           TT_Done_Stream( &_stream )
90 
91 /* Define a file frame -- use it only when needed */
92 #define DEFINE_A_FRAME   TFileFrame  frame = TT_Null_FileFrame
93 
94 /* Define a stream -- use it only when needed */
95 #define DEFINE_A_STREAM  TT_Stream   stream
96 
97 #define GET_Byte()    ttfReader__Byte  (r)
98 #define GET_UShort()  ttfReader__UShort(r)
99 #define GET_Short()   ttfReader__Short (r)
100 #define GET_Long()    ttfReader__Int (r)
101 #define GET_ULong()   ttfReader__UInt(r)
102 
103 #ifdef TT_CONFIG_REENTRANT  /* re-entrant implementation */
104 
105 /* The following macros define the necessary local */
106 /* variables used to access streams and frames.    */
107 
108 /* Define stream locals with frame */
109 #define DEFINE_STREAM_LOCALS  \
110           TT_Error  error;    \
111           DEFINE_A_STREAM;    \
112           DEFINE_A_FRAME
113 
114 /* Define stream locals without frame */
115 #define DEFINE_STREAM_LOCALS_WO_FRAME  \
116           TT_Error  error;             \
117           DEFINE_A_STREAM
118 
119 /* Define locals with a predefined stream in reentrant mode -- see ttload.c */
120 #define DEFINE_LOAD_LOCALS( STREAM )  \
121           TT_Error  error;            \
122           DEFINE_A_STREAM = (STREAM); \
123           DEFINE_A_FRAME
124 
125 /* Define locals without frame with a predefined stream - see ttload.c */
126 #define DEFINE_LOAD_LOCALS_WO_FRAME( STREAM ) \
127           TT_Error      error;                \
128           DEFINE_A_STREAM = (STREAM)
129 
130 /* Define all locals necessary to access a font file */
131 #define DEFINE_ALL_LOCALS  \
132           TT_Error  error; \
133           DEFINE_A_STREAM; \
134           DEFINE_A_FRAME
135 
136 #define ACCESS_Frame( _size_ ) \
137           ( error = TT_Access_Frame( stream, &frame, _size_ ) )
138 #define CHECK_ACCESS_Frame( _size_ ) \
139           ( error = TT_Check_And_Access_Frame( stream, &frame, _size_ ) )
140 #define FORGET_Frame() \
141           ( error = TT_Forget_Frame( &frame ) )
142 
143 #define FILE_Pos()    TT_File_Pos ( stream )
144 
145 #define FILE_Seek( _position_ ) \
146           ( error = TT_Seek_File( stream, _position_ ) )
147 #define FILE_Skip( _distance_ ) \
148           ( error = TT_Skip_File( stream, _distance_ ) )
149 #define FILE_Read( buffer, count ) \
150           ( error = TT_Read_File ( stream, buffer, count ) )
151 #define FILE_Read_At( pos, buffer, count ) \
152           ( error = TT_Read_At_File( stream, pos, buffer, count ) )
153 
154 #else   /* thread-safe implementation */
155 
156 /* Define stream locals with frame -- nothing in thread-safe mode */
157 #define DEFINE_STREAM_LOCALS  \
158           TT_Error  error
159 
160 /* Define stream locals without frame -- nothing in thread-safe mode */
161 #define DEFINE_STREAM_LOCALS_WO_FRAME \
162           TT_Error  error
163 
164 /* Define locals with a predefined stream in reentrant mode -- see ttload.c */
165 #define DEFINE_LOAD_LOCALS( STREAM ) \
166           TT_Error  error
167 
168 /* Define locals without frame with a predefined stream - see ttload.c */
169 #define DEFINE_LOAD_LOCALS_WO_FRAME( STREAM ) \
170           TT_Error  error
171 
172 /* Define all locals necessary to access a font file */
173 #define DEFINE_ALL_LOCALS  \
174           TT_Error  error; \
175           DEFINE_A_STREAM
176 
177 #define ACCESS_Frame( _size_ ) \
178           ( error = TT_Access_Frame( _size_ ) )
179 #define CHECK_ACCESS_Frame( _size_ ) \
180           ( error = TT_Check_And_Access_Frame( _size_ ) )
181 #define FORGET_Frame() \
182           ( error = TT_Forget_Frame() )
183 
184 #define GET_Tag4()    TT_Get_Long  ()
185 
186 #define FILE_Pos()    TT_File_Pos()
187 
188 #define FILE_Seek( _position_ ) \
189           ( error = TT_Seek_File( _position_ ) )
190 #define FILE_Skip( _distance_ ) \
191           ( error = TT_Skip_File( _distance_ ) )
192 #define FILE_Read( buffer, count ) \
193           ( error = TT_Read_File ( buffer, count ) )
194 #define FILE_Read_At( pos, buffer, count ) \
195           ( error = TT_Read_At_File( pos, buffer, count ) )
196 
197 #endif /* TT_CONFIG_REENTRANT */
198 
199 #ifdef __cplusplus
200   }
201 #endif
202 
203 #endif /* TTLOAD_H */
204 
205 /* END */
206