ReactOS  0.4.14-dev-342-gdc047f9
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  }
t42_parser_done(T42_Parser parser)
Definition: t42parse.c:220
PS_TableRec encoding_table
Definition: t42parse.h:47
#define T1_Release_Table(p)
Definition: t42parse.c:107
PS_TableRec swap_table
Definition: t42parse.h:53
PS_TableRec glyph_names
Definition: t42parse.h:51
T42_ParserRec parser
Definition: t42parse.h:44
FT_BEGIN_HEADER struct T42_ParserRec_ * T42_Parser
Definition: import.c:86
PS_TableRec charstrings
Definition: t42parse.h:52

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  }
PS_TableRec encoding_table
Definition: t42parse.h:47
FT_ULong init
Definition: psaux.h:146
#define FT_ZERO(p)
Definition: ftmemory.h:237
PS_TableRec glyph_names
Definition: t42parse.h:51
FT_Int num_glyphs
Definition: t42parse.h:50
FT_Int num_chars
Definition: t42parse.h:46
PS_TableRec charstrings
Definition: t42parse.h:52
#define FT_UNUSED(arg)
Definition: ftconfig.h:101
GLenum GLuint GLint GLenum face
Definition: glext.h:7025

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 */
1170  T1_Skip_Spaces ( parser );
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;
1183  T1_Skip_Spaces ( parser );
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! */
1240  parser->root.error = t42_load_keyword( face,
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  }
static const T1_FieldRec t42_keywords[]
Definition: t42parse.c:55
#define ft_strncmp
Definition: ftstdlib.h:89
#define T1_Skip_PS_Token(p)
Definition: t42parse.c:115
signed int FT_Int
Definition: fttypes.h:220
#define T1_ToToken(p, t)
Definition: t42parse.c:124
return FT_Err_Ok
Definition: ftbbox.c:511
GLint limit
Definition: glext.h:10326
#define T1_Skip_Spaces(p)
Definition: t42parse.c:114
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
unsigned char FT_Byte
Definition: fttypes.h:154
GLuint base
Definition: 3dtext.c:35
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
struct T1_FieldRec_ * T1_Field
Definition: psaux.h:171
static FT_Error t42_load_keyword(T42_Face face, T42_Loader loader, T1_Field field)
Definition: t42parse.c:1080
GLsizeiptr size
Definition: glext.h:5919
if(!(yy_init))
Definition: macro.lex.yy.c:714
static void Exit(void)
Definition: sock.c:1331
T42_ParserRec parser
Definition: t42parse.h:44
unsigned int error
Definition: inffile.c:97
GLenum GLsizei len
Definition: glext.h:6722
FT_BEGIN_HEADER struct T42_ParserRec_ * T42_Parser
#define ft_memcmp
Definition: ftstdlib.h:81
unsigned int FT_UInt
Definition: fttypes.h:231
Definition: import.c:86
Definition: name.c:36
#define ft_strlen
Definition: ftstdlib.h:88
GLenum GLuint GLint GLenum face
Definition: glext.h:7025
GLuint const GLchar * name
Definition: glext.h:6031

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  }
static char memory[1024 *256]
Definition: process.c:116
#define FT_FREE(ptr)
Definition: ftmemory.h:329
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
Definition: ftsystem.h:66
Definition: import.c:86

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  {
142  FT_Long size;
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 
176  FT_FRAME_EXIT();
177 
178  if ( error || FT_STREAM_SEEK( 0 ) )
179  goto Exit;
180 
181  size = (FT_Long)stream->size;
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 FT_ALLOC(ptr, size)
Definition: ftmemory.h:303
int FT_Error
Definition: fttypes.h:300
signed long FT_Long
Definition: fttypes.h:242
void(* init)(PS_Parser parser, FT_Byte *base, FT_Byte *limit, FT_Memory memory)
Definition: psaux.h:366
#define error(str)
Definition: mkdosfs.c:1605
return FT_Err_Ok
Definition: ftbbox.c:511
static char memory[1024 *256]
Definition: process.c:116
unsigned char FT_Byte
Definition: fttypes.h:154
#define FT_THROW(e)
Definition: ftdebug.h:213
smooth NULL
Definition: ftsmooth.c:416
#define FT_FREE(ptr)
Definition: ftmemory.h:329
#define FT_STREAM_SKIP(distance)
Definition: ftstream.h:493
GLsizeiptr size
Definition: glext.h:5919
if(!(yy_init))
Definition: macro.lex.yy.c:714
static void Exit(void)
Definition: sock.c:1331
#define FT_TRACE2(varformat)
Definition: ftdebug.h:159
static const WCHAR L[]
Definition: oid.c:1250
unsigned int size
Definition: parse.h:27
Definition: parse.h:22
GLuint GLuint stream
Definition: glext.h:7522
#define FT_FRAME_EXIT()
Definition: ftstream.h:517
#define FT_STREAM_SEEK(position)
Definition: ftstream.h:489
ULARGE_INTEGER pos
Definition: request.c:4080
#define ft_memcmp
Definition: ftstdlib.h:81
Definition: import.c:86
#define FT_FRAME_ENTER(size)
Definition: ftstream.h:512
#define FT_STREAM_READ(buffer, count)
Definition: ftstream.h:497
const PS_Parser_FuncsRec * ps_parser_funcs
Definition: psaux.h:1282

Referenced by T42_Open_Face().