ReactOS 0.4.15-dev-8219-ge8b88cf
t42parse.h File Reference
#include "t42objs.h"
Include dependency graph for t42parse.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  T42_ParserRec_
 
struct  T42_Loader_
 

Typedefs

typedef FT_BEGIN_HEADER struct T42_ParserRec_ T42_ParserRec
 
typedef FT_BEGIN_HEADER struct T42_ParserRec_T42_Parser
 
typedef struct T42_Loader_ T42_LoaderRec
 
typedef struct T42_Loader_T42_Loader
 

Functions

 t42_parser_init (T42_Parser parser, FT_Stream stream, FT_Memory memory, PSAux_Service psaux)
 
 t42_parser_done (T42_Parser parser)
 
 t42_parse_dict (T42_Face face, T42_Loader loader, FT_Byte *base, FT_Long size)
 
 t42_loader_init (T42_Loader loader, T42_Face face)
 
 t42_loader_done (T42_Loader loader)
 

Typedef Documentation

◆ T42_Loader

◆ T42_LoaderRec

◆ T42_Parser

◆ T42_ParserRec

Function Documentation

◆ t42_loader_done()

t42_loader_done ( T42_Loader  loader)

Definition at line 1283 of file t42parse.c.

1284 {
1285 T42_Parser parser = &loader->parser;
1286
1287
1288 /* finalize tables */
1289 T1_Release_Table( &loader->encoding_table );
1290 T1_Release_Table( &loader->charstrings );
1291 T1_Release_Table( &loader->glyph_names );
1292 T1_Release_Table( &loader->swap_table );
1293
1294 /* finalize parser */
1296 }
PS_TableRec encoding_table
Definition: t42parse.h:47
PS_TableRec glyph_names
Definition: t42parse.h:51
T42_ParserRec parser
Definition: t42parse.h:44
PS_TableRec charstrings
Definition: t42parse.h:52
PS_TableRec swap_table
Definition: t42parse.h:53
Definition: import.c:81
#define T1_Release_Table(p)
Definition: t42parse.c:107
t42_parser_done(T42_Parser parser)
Definition: t42parse.c:220
FT_BEGIN_HEADER struct T42_ParserRec_ * T42_Parser

Referenced by T42_Open_Face().

◆ t42_loader_init()

t42_loader_init ( T42_Loader  loader,
T42_Face  face 
)

Definition at line 1266 of file t42parse.c.

1268 {
1269 FT_UNUSED( face );
1270
1271 FT_ZERO( loader );
1272 loader->num_glyphs = 0;
1273 loader->num_chars = 0;
1274
1275 /* initialize the tables -- simply set their `init' field to 0 */
1276 loader->encoding_table.init = 0;
1277 loader->charstrings.init = 0;
1278 loader->glyph_names.init = 0;
1279 }
#define FT_UNUSED(arg)
Definition: ftconfig.h:101
#define FT_ZERO(p)
Definition: ftmemory.h:237
GLenum GLuint GLint GLenum face
Definition: glext.h:7025
FT_ULong init
Definition: psaux.h:146
FT_Int num_chars
Definition: t42parse.h:46
FT_Int num_glyphs
Definition: t42parse.h:50

Referenced by T42_Open_Face().

◆ t42_parse_dict()

t42_parse_dict ( T42_Face  face,
T42_Loader  loader,
FT_Byte base,
FT_Long  size 
)

Definition at line 1135 of file t42parse.c.

1139 {
1140 T42_Parser parser = &loader->parser;
1141 FT_Byte* limit;
1142 FT_Int n_keywords = (FT_Int)( sizeof ( t42_keywords ) /
1143 sizeof ( t42_keywords[0] ) );
1144
1145
1146 parser->root.cursor = base;
1147 parser->root.limit = base + size;
1148 parser->root.error = FT_Err_Ok;
1149
1150 limit = parser->root.limit;
1151
1153
1154 while ( parser->root.cursor < limit )
1155 {
1156 FT_Byte* cur;
1157
1158
1159 cur = parser->root.cursor;
1160
1161 /* look for `FontDirectory' which causes problems for some fonts */
1162 if ( *cur == 'F' && cur + 25 < limit &&
1163 ft_strncmp( (char*)cur, "FontDirectory", 13 ) == 0 )
1164 {
1165 FT_Byte* cur2;
1166
1167
1168 /* skip the `FontDirectory' keyword */
1171 cur = cur2 = parser->root.cursor;
1172
1173 /* look up the `known' keyword */
1174 while ( cur < limit )
1175 {
1176 if ( *cur == 'k' && cur + 5 < limit &&
1177 ft_strncmp( (char*)cur, "known", 5 ) == 0 )
1178 break;
1179
1181 if ( parser->root.error )
1182 goto Exit;
1184 cur = parser->root.cursor;
1185 }
1186
1187 if ( cur < limit )
1188 {
1190
1191
1192 /* skip the `known' keyword and the token following it */
1194 T1_ToToken( parser, &token );
1195
1196 /* if the last token was an array, skip it! */
1197 if ( token.type == T1_TOKEN_TYPE_ARRAY )
1198 cur2 = parser->root.cursor;
1199 }
1200 parser->root.cursor = cur2;
1201 }
1202
1203 /* look for immediates */
1204 else if ( *cur == '/' && cur + 2 < limit )
1205 {
1206 FT_UInt len;
1207
1208
1209 cur++;
1210
1211 parser->root.cursor = cur;
1213 if ( parser->root.error )
1214 goto Exit;
1215
1216 len = (FT_UInt)( parser->root.cursor - cur );
1217
1218 if ( len > 0 && len < 22 && parser->root.cursor < limit )
1219 {
1220 int i;
1221
1222
1223 /* now compare the immediate name to the keyword table */
1224
1225 /* loop through all known keywords */
1226 for ( i = 0; i < n_keywords; i++ )
1227 {
1229 FT_Byte *name = (FT_Byte*)keyword->ident;
1230
1231
1232 if ( !name )
1233 continue;
1234
1235 if ( cur[0] == name[0] &&
1236 len == ft_strlen( (const char *)name ) &&
1237 ft_memcmp( cur, name, len ) == 0 )
1238 {
1239 /* we found it -- run the parsing callback! */
1241 loader,
1242 keyword );
1243 if ( parser->root.error )
1244 return parser->root.error;
1245 break;
1246 }
1247 }
1248 }
1249 }
1250 else
1251 {
1253 if ( parser->root.error )
1254 goto Exit;
1255 }
1256
1258 }
1259
1260 Exit:
1261 return parser->root.error;
1262 }
return FT_Err_Ok
Definition: ftbbox.c:511
#define ft_memcmp
Definition: ftstdlib.h:81
#define ft_strncmp
Definition: ftstdlib.h:89
#define ft_strlen
Definition: ftstdlib.h:88
unsigned char FT_Byte
Definition: fttypes.h:154
unsigned int FT_UInt
Definition: fttypes.h:231
signed int FT_Int
Definition: fttypes.h:220
FxCollectionEntry * cur
GLsizeiptr size
Definition: glext.h:5919
GLint limit
Definition: glext.h:10326
GLenum GLsizei len
Definition: glext.h:6722
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat token
Definition: glfuncs.h:210
if(dx< 0)
Definition: linetemp.h:194
@ T1_TOKEN_TYPE_ARRAY
Definition: psaux.h:180
struct T1_FieldRec_ * T1_Field
Definition: psaux.h:171
static void Exit(void)
Definition: sock.c:1330
Definition: name.c:39
unsigned int error
Definition: inffile.c:97
#define T1_ToToken(p, t)
Definition: t42parse.c:124
#define T1_Skip_Spaces(p)
Definition: t42parse.c:114
#define T1_Skip_PS_Token(p)
Definition: t42parse.c:115
static const T1_FieldRec t42_keywords[]
Definition: t42parse.c:55
static FT_Error t42_load_keyword(T42_Face face, T42_Loader loader, T1_Field field)
Definition: t42parse.c:1080

Referenced by T42_Open_Face().

◆ t42_parser_done()

t42_parser_done ( T42_Parser  parser)

Definition at line 220 of file t42parse.c.

221 {
222 FT_Memory memory = parser->root.memory;
223
224
225 /* free the base dictionary only when we have a disk stream */
226 if ( !parser->in_memory )
227 FT_FREE( parser->base_dict );
228
229 parser->root.funcs.done( &parser->root );
230 }
#define FT_FREE(ptr)
Definition: ftmemory.h:329
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
Definition: ftsystem.h:66
static char memory[1024 *256]
Definition: process.c:116

Referenced by t42_loader_done().

◆ t42_parser_init()

t42_parser_init ( T42_Parser  parser,
FT_Stream  stream,
FT_Memory  memory,
PSAux_Service  psaux 
)

Definition at line 136 of file t42parse.c.

140 {
143
144
145 psaux->ps_parser_funcs->init( &parser->root, NULL, NULL, memory );
146
147 parser->stream = stream;
148 parser->base_len = 0;
149 parser->base_dict = NULL;
150 parser->in_memory = 0;
151
152 /*******************************************************************/
153 /* */
154 /* Here a short summary of what is going on: */
155 /* */
156 /* When creating a new Type 42 parser, we try to locate and load */
157 /* the base dictionary, loading the whole font into memory. */
158 /* */
159 /* When `loading' the base dictionary, we only set up pointers */
160 /* in the case of a memory-based stream. Otherwise, we allocate */
161 /* and load the base dictionary in it. */
162 /* */
163 /* parser->in_memory is set if we have a memory stream. */
164 /* */
165
166 if ( FT_STREAM_SEEK( 0L ) ||
167 FT_FRAME_ENTER( 17 ) )
168 goto Exit;
169
170 if ( ft_memcmp( stream->cursor, "%!PS-TrueTypeFont", 17 ) != 0 )
171 {
172 FT_TRACE2(( " not a Type42 font\n" ));
173 error = FT_THROW( Unknown_File_Format );
174 }
175
177
178 if ( error || FT_STREAM_SEEK( 0 ) )
179 goto Exit;
180
182
183 /* now, try to load `size' bytes of the `base' dictionary we */
184 /* found previously */
185
186 /* if it is a memory-based resource, set up pointers */
187 if ( !stream->read )
188 {
189 parser->base_dict = (FT_Byte*)stream->base + stream->pos;
190 parser->base_len = size;
191 parser->in_memory = 1;
192
193 /* check that the `size' field is valid */
194 if ( FT_STREAM_SKIP( size ) )
195 goto Exit;
196 }
197 else
198 {
199 /* read segment in memory */
200 if ( FT_ALLOC( parser->base_dict, size ) ||
201 FT_STREAM_READ( parser->base_dict, size ) )
202 goto Exit;
203
204 parser->base_len = size;
205 }
206
207 parser->root.base = parser->base_dict;
208 parser->root.cursor = parser->base_dict;
209 parser->root.limit = parser->root.cursor + parser->base_len;
210
211 Exit:
212 if ( error && !parser->in_memory )
213 FT_FREE( parser->base_dict );
214
215 return error;
216 }
#define NULL
Definition: types.h:112
#define FT_THROW(e)
Definition: ftdebug.h:213
#define FT_TRACE2(varformat)
Definition: ftdebug.h:159
#define FT_ALLOC(ptr, size)
Definition: ftmemory.h:303
#define FT_FRAME_ENTER(size)
Definition: ftstream.h:512
#define FT_STREAM_SEEK(position)
Definition: ftstream.h:489
#define FT_FRAME_EXIT()
Definition: ftstream.h:517
#define FT_STREAM_SKIP(distance)
Definition: ftstream.h:493
#define FT_STREAM_READ(buffer, count)
Definition: ftstream.h:497
int FT_Error
Definition: fttypes.h:300
signed long FT_Long
Definition: fttypes.h:242
#define error(str)
Definition: mkdosfs.c:1605
#define L(x)
Definition: ntvdm.h:50
const PS_Parser_FuncsRec * ps_parser_funcs
Definition: psaux.h:1282
void(* init)(PS_Parser parser, FT_Byte *base, FT_Byte *limit, FT_Memory memory)
Definition: psaux.h:366
Definition: parse.h:23
ULARGE_INTEGER pos
Definition: request.c:4380
unsigned int size
Definition: parse.h:27

Referenced by T42_Open_Face().