ReactOS 0.4.16-dev-1067-ge98bba2
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 1298 of file t42parse.c.

1299 {
1300 T42_Parser parser = &loader->parser;
1301
1302
1303 /* finalize tables */
1304 T1_Release_Table( &loader->encoding_table );
1305 T1_Release_Table( &loader->charstrings );
1306 T1_Release_Table( &loader->glyph_names );
1307 T1_Release_Table( &loader->swap_table );
1308
1309 /* finalize parser */
1311 }
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 1281 of file t42parse.c.

1283 {
1284 FT_UNUSED( face );
1285
1286 FT_ZERO( loader );
1287 loader->num_glyphs = 0;
1288 loader->num_chars = 0;
1289
1290 /* initialize the tables -- simply set their `init' field to 0 */
1291 loader->encoding_table.init = 0;
1292 loader->charstrings.init = 0;
1293 loader->glyph_names.init = 0;
1294 }
#define FT_UNUSED(arg)
Definition: ftconfig.h:100
#define FT_ZERO(p)
Definition: ftmemory.h:237
GLenum GLuint GLint GLenum face
Definition: glext.h:7025
FT_ULong init
Definition: psaux.h:156
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 1150 of file t42parse.c.

1154 {
1155 T42_Parser parser = &loader->parser;
1156 FT_Byte* limit;
1157 FT_Int n_keywords = (FT_Int)( sizeof ( t42_keywords ) /
1158 sizeof ( t42_keywords[0] ) );
1159
1160
1161 parser->root.cursor = base;
1162 parser->root.limit = base + size;
1163 parser->root.error = FT_Err_Ok;
1164
1165 limit = parser->root.limit;
1166
1168
1169 while ( parser->root.cursor < limit )
1170 {
1171 FT_Byte* cur;
1172
1173
1174 cur = parser->root.cursor;
1175
1176 /* look for `FontDirectory' which causes problems for some fonts */
1177 if ( *cur == 'F' && cur + 25 < limit &&
1178 ft_strncmp( (char*)cur, "FontDirectory", 13 ) == 0 )
1179 {
1180 FT_Byte* cur2;
1181
1182
1183 /* skip the `FontDirectory' keyword */
1186 cur = cur2 = parser->root.cursor;
1187
1188 /* look up the `known' keyword */
1189 while ( cur < limit )
1190 {
1191 if ( *cur == 'k' && cur + 5 < limit &&
1192 ft_strncmp( (char*)cur, "known", 5 ) == 0 )
1193 break;
1194
1196 if ( parser->root.error )
1197 goto Exit;
1199 cur = parser->root.cursor;
1200 }
1201
1202 if ( cur < limit )
1203 {
1205
1206
1207 /* skip the `known' keyword and the token following it */
1209 T1_ToToken( parser, &token );
1210
1211 /* if the last token was an array, skip it! */
1212 if ( token.type == T1_TOKEN_TYPE_ARRAY )
1213 cur2 = parser->root.cursor;
1214 }
1215 parser->root.cursor = cur2;
1216 }
1217
1218 /* look for immediates */
1219 else if ( *cur == '/' && cur + 2 < limit )
1220 {
1221 FT_UInt len;
1222
1223
1224 cur++;
1225
1226 parser->root.cursor = cur;
1228 if ( parser->root.error )
1229 goto Exit;
1230
1231 len = (FT_UInt)( parser->root.cursor - cur );
1232
1233 if ( len > 0 && len < 22 && parser->root.cursor < limit )
1234 {
1235 int i;
1236
1237
1238 /* now compare the immediate name to the keyword table */
1239
1240 /* loop through all known keywords */
1241 for ( i = 0; i < n_keywords; i++ )
1242 {
1244 FT_Byte *name = (FT_Byte*)keyword->ident;
1245
1246
1247 if ( !name )
1248 continue;
1249
1250 if ( cur[0] == name[0] &&
1251 len == ft_strlen( (const char *)name ) &&
1252 ft_memcmp( cur, name, len ) == 0 )
1253 {
1254 /* we found it -- run the parsing callback! */
1256 loader,
1257 keyword );
1258 if ( parser->root.error )
1259 return parser->root.error;
1260 break;
1261 }
1262 }
1263 }
1264 }
1265 else
1266 {
1268 if ( parser->root.error )
1269 goto Exit;
1270 }
1271
1273 }
1274
1275 Exit:
1276 return parser->root.error;
1277 }
return FT_Err_Ok
Definition: ftbbox.c:527
#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:190
struct T1_FieldRec_ * T1_Field
Definition: psaux.h:181
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:1095

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:328
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
Definition: ftsystem.h:65
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:241
#define FT_TRACE2(varformat)
Definition: ftdebug.h:187
#define FT_ALLOC(ptr, size)
Definition: ftmemory.h:302
#define FT_FRAME_ENTER(size)
Definition: ftstream.h:537
#define FT_STREAM_SEEK(position)
Definition: ftstream.h:514
#define FT_FRAME_EXIT()
Definition: ftstream.h:542
#define FT_STREAM_SKIP(distance)
Definition: ftstream.h:518
#define FT_STREAM_READ(buffer, count)
Definition: ftstream.h:522
int FT_Error
Definition: fttypes.h:299
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:1349
void(* init)(PS_Parser parser, FT_Byte *base, FT_Byte *limit, FT_Memory memory)
Definition: psaux.h:376
Definition: parse.h:23
ULARGE_INTEGER pos
Definition: request.c:4380
unsigned int size
Definition: parse.h:27

Referenced by T42_Open_Face().