ReactOS 0.4.16-dev-2357-g35d0dfe
t42parse.h File Reference
#include "t42objs.h"
#include <freetype/internal/psaux.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 1293 of file t42parse.c.

1294 {
1295 T42_Parser parser = &loader->parser;
1296
1297
1298 /* finalize tables */
1299 T1_Release_Table( &loader->encoding_table );
1300 T1_Release_Table( &loader->charstrings );
1301 T1_Release_Table( &loader->glyph_names );
1302 T1_Release_Table( &loader->swap_table );
1303
1304 /* finalize parser */
1306 }
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 1276 of file t42parse.c.

1278 {
1279 FT_UNUSED( face );
1280
1281 FT_ZERO( loader );
1282 loader->num_glyphs = 0;
1283 loader->num_chars = 0;
1284
1285 /* initialize the tables -- simply set their `init' field to 0 */
1286 loader->encoding_table.init = 0;
1287 loader->charstrings.init = 0;
1288 loader->glyph_names.init = 0;
1289 }
#define FT_ZERO(p)
Definition: ftmemory.h:246
GLenum GLuint GLint GLenum face
Definition: glext.h:7025
#define FT_UNUSED(arg)
FT_ULong init
Definition: psaux.h:155
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 1145 of file t42parse.c.

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

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 if ( parser->root.funcs.done )
230 parser->root.funcs.done( &parser->root );
231 }
#define FT_FREE(ptr)
Definition: ftmemory.h:337
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
Definition: ftsystem.h:64
static char memory[1024 *256]
Definition: process.c:122

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 L(x)
Definition: resources.c:13
#define FT_THROW(e)
Definition: ftdebug.h:243
#define FT_TRACE2(varformat)
Definition: ftdebug.h:189
#define FT_ALLOC(ptr, size)
Definition: ftmemory.h:311
#define FT_FRAME_ENTER(size)
Definition: ftstream.h:548
#define FT_STREAM_SEEK(position)
Definition: ftstream.h:525
#define FT_FRAME_EXIT()
Definition: ftstream.h:553
#define FT_STREAM_SKIP(distance)
Definition: ftstream.h:529
#define FT_STREAM_READ(buffer, count)
Definition: ftstream.h:533
int FT_Error
Definition: fttypes.h:299
signed long FT_Long
Definition: fttypes.h:242
#define error(str)
Definition: mkdosfs.c:1605
const PS_Parser_FuncsRec * ps_parser_funcs
Definition: psaux.h:1348
void(* init)(PS_Parser parser, FT_Byte *base, FT_Byte *limit, FT_Memory memory)
Definition: psaux.h:375
Definition: parse.h:23
ULARGE_INTEGER pos
Definition: request.c:4380
unsigned int size
Definition: parse.h:27

Referenced by T42_Open_Face().