ReactOS  0.4.14-dev-376-gaedba84
t42parse.c File Reference
#include "t42parse.h"
#include "t42error.h"
Include dependency graph for t42parse.c:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define FT_COMPONENT   trace_t42
 
#define FT_STRUCTURE   T1_FontInfo
 
#define T1CODE   T1_FIELD_LOCATION_FONT_INFO
 
#define FT_STRUCTURE   PS_FontExtraRec
 
#define T1CODE   T1_FIELD_LOCATION_FONT_EXTRA
 
#define FT_STRUCTURE   T1_FontRec
 
#define T1CODE   T1_FIELD_LOCATION_FONT_DICT
 
#define FT_STRUCTURE   FT_BBox
 
#define T1CODE   T1_FIELD_LOCATION_BBOX
 
#define T1_Add_Table(p, i, o, l)   (p)->funcs.add( (p), i, o, l )
 
#define T1_Release_Table(p)
 
#define T1_Skip_Spaces(p)   (p)->root.funcs.skip_spaces( &(p)->root )
 
#define T1_Skip_PS_Token(p)   (p)->root.funcs.skip_PS_token( &(p)->root )
 
#define T1_ToInt(p)   (p)->root.funcs.to_int( &(p)->root )
 
#define T1_ToBytes(p, b, m, n, d)   (p)->root.funcs.to_bytes( &(p)->root, b, m, n, d )
 
#define T1_ToFixedArray(p, m, f, t)   (p)->root.funcs.to_fixed_array( &(p)->root, m, f, t )
 
#define T1_ToToken(p, t)   (p)->root.funcs.to_token( &(p)->root, t )
 
#define T1_Load_Field(p, f, o, m, pf)   (p)->root.funcs.load_field( &(p)->root, f, o, m, pf )
 
#define T1_Load_Field_Table(p, f, o, m, pf)   (p)->root.funcs.load_field_table( &(p)->root, f, o, m, pf )
 

Typedefs

typedef enum T42_Load_Status_ T42_Load_Status
 

Enumerations

enum  T42_Load_Status_ { BEFORE_START, BEFORE_TABLE_DIR, OTHER_TABLES }
 

Functions

static void t42_parse_font_matrix (T42_Face face, T42_Loader loader)
 
static void t42_parse_encoding (T42_Face face, T42_Loader loader)
 
static void t42_parse_charstrings (T42_Face face, T42_Loader loader)
 
static void t42_parse_sfnts (T42_Face face, T42_Loader loader)
 
 t42_parser_init (T42_Parser parser, FT_Stream stream, FT_Memory memory, PSAux_Service psaux)
 
 t42_parser_done (T42_Parser parser)
 
static int t42_is_space (FT_Byte c)
 
static FT_Error t42_load_keyword (T42_Face face, T42_Loader loader, T1_Field field)
 
 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)
 

Variables

static const T1_FieldRec t42_keywords []
 

Macro Definition Documentation

◆ FT_COMPONENT

#define FT_COMPONENT   trace_t42

Definition at line 33 of file t42parse.c.

◆ FT_STRUCTURE [1/4]

#define FT_STRUCTURE   T1_FontInfo

◆ FT_STRUCTURE [2/4]

#define FT_STRUCTURE   PS_FontExtraRec

◆ FT_STRUCTURE [3/4]

#define FT_STRUCTURE   T1_FontRec

◆ FT_STRUCTURE [4/4]

#define FT_STRUCTURE   FT_BBox

◆ T1_Add_Table

#define T1_Add_Table (   p,
  i,
  o,
  l 
)    (p)->funcs.add( (p), i, o, l )

Definition at line 106 of file t42parse.c.

◆ T1_Load_Field

#define T1_Load_Field (   p,
  f,
  o,
  m,
  pf 
)    (p)->root.funcs.load_field( &(p)->root, f, o, m, pf )

Definition at line 127 of file t42parse.c.

◆ T1_Load_Field_Table

#define T1_Load_Field_Table (   p,
  f,
  o,
  m,
  pf 
)    (p)->root.funcs.load_field_table( &(p)->root, f, o, m, pf )

Definition at line 129 of file t42parse.c.

◆ T1_Release_Table

#define T1_Release_Table (   p)
Value:
do \
{ \
if ( (p)->funcs.release ) \
(p)->funcs.release( p ); \
} while ( 0 )
static struct __wine_debug_functions funcs
Definition: debug.c:59
GLfloat GLfloat p
Definition: glext.h:8902

Definition at line 107 of file t42parse.c.

◆ T1_Skip_PS_Token

#define T1_Skip_PS_Token (   p)    (p)->root.funcs.skip_PS_token( &(p)->root )

Definition at line 115 of file t42parse.c.

◆ T1_Skip_Spaces

#define T1_Skip_Spaces (   p)    (p)->root.funcs.skip_spaces( &(p)->root )

Definition at line 114 of file t42parse.c.

◆ T1_ToBytes

#define T1_ToBytes (   p,
  b,
  m,
  n,
  d 
)    (p)->root.funcs.to_bytes( &(p)->root, b, m, n, d )

Definition at line 119 of file t42parse.c.

◆ T1_ToFixedArray

#define T1_ToFixedArray (   p,
  m,
  f,
  t 
)    (p)->root.funcs.to_fixed_array( &(p)->root, m, f, t )

Definition at line 122 of file t42parse.c.

◆ T1_ToInt

#define T1_ToInt (   p)    (p)->root.funcs.to_int( &(p)->root )

Definition at line 117 of file t42parse.c.

◆ T1_ToToken

#define T1_ToToken (   p,
  t 
)    (p)->root.funcs.to_token( &(p)->root, t )

Definition at line 124 of file t42parse.c.

◆ T1CODE [1/4]

◆ T1CODE [2/4]

◆ T1CODE [3/4]

◆ T1CODE [4/4]

Typedef Documentation

◆ T42_Load_Status

Enumeration Type Documentation

◆ T42_Load_Status_

Enumerator
BEFORE_START 
BEFORE_TABLE_DIR 
OTHER_TABLES 

Definition at line 519 of file t42parse.c.

520  {
521  BEFORE_START,
524 
525  } T42_Load_Status;
enum T42_Load_Status_ T42_Load_Status

Function Documentation

◆ t42_is_space()

static int t42_is_space ( FT_Byte  c)
static

Definition at line 234 of file t42parse.c.

235  {
236  return ( c == ' ' || c == '\t' ||
237  c == '\r' || c == '\n' || c == '\f' ||
238  c == '\0' );
239  }
const GLubyte * c
Definition: glext.h:8905

Referenced by t42_parse_charstrings(), and t42_parse_encoding().

◆ t42_load_keyword()

static FT_Error t42_load_keyword ( T42_Face  face,
T42_Loader  loader,
T1_Field  field 
)
static

Definition at line 1080 of file t42parse.c.

1083  {
1084  FT_Error error;
1085  void* dummy_object;
1086  void** objects;
1087  FT_UInt max_objects = 0;
1088 
1089 
1090  /* if the keyword has a dedicated callback, call it */
1091  if ( field->type == T1_FIELD_TYPE_CALLBACK )
1092  {
1093  field->reader( (FT_Face)face, loader );
1094  error = loader->parser.root.error;
1095  goto Exit;
1096  }
1097 
1098  /* now the keyword is either a simple field or a table of fields; */
1099  /* we are now going to take care of it */
1100 
1101  switch ( field->location )
1102  {
1104  dummy_object = &face->type1.font_info;
1105  break;
1106 
1108  dummy_object = &face->type1.font_extra;
1109  break;
1110 
1112  dummy_object = &face->type1.font_bbox;
1113  break;
1114 
1115  default:
1116  dummy_object = &face->type1;
1117  }
1118 
1119  objects = &dummy_object;
1120 
1123  error = T1_Load_Field_Table( &loader->parser, field,
1124  objects, max_objects, 0 );
1125  else
1126  error = T1_Load_Field( &loader->parser, field,
1127  objects, max_objects, 0 );
1128 
1129  Exit:
1130  return error;
1131  }
int FT_Error
Definition: fttypes.h:300
#define error(str)
Definition: mkdosfs.c:1605
static const CLSID * objects[]
Definition: apphelp.c:110
Definition: parser.c:43
static void Exit(void)
Definition: sock.c:1331
T42_ParserRec parser
Definition: t42parse.h:44
#define T1_Load_Field_Table(p, f, o, m, pf)
Definition: t42parse.c:129
unsigned int FT_UInt
Definition: fttypes.h:231
#define T1_Load_Field(p, f, o, m, pf)
Definition: t42parse.c:127
GLenum GLuint GLint GLenum face
Definition: glext.h:7025

Referenced by t42_parse_dict().

◆ 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_charstrings()

static void t42_parse_charstrings ( T42_Face  face,
T42_Loader  loader 
)
static

Definition at line 774 of file t42parse.c.

776  {
777  T42_Parser parser = &loader->parser;
778  PS_Table code_table = &loader->charstrings;
779  PS_Table name_table = &loader->glyph_names;
780  PS_Table swap_table = &loader->swap_table;
781  FT_Memory memory = parser->root.memory;
782  FT_Error error;
783 
784  PSAux_Service psaux = (PSAux_Service)face->psaux;
785 
786  FT_Byte* cur;
787  FT_Byte* limit = parser->root.limit;
788  FT_Int n;
789  FT_Int notdef_index = 0;
790  FT_Byte notdef_found = 0;
791 
792 
794 
795  if ( parser->root.cursor >= limit )
796  {
797  FT_ERROR(( "t42_parse_charstrings: out of bounds\n" ));
798  error = FT_THROW( Invalid_File_Format );
799  goto Fail;
800  }
801 
802  if ( ft_isdigit( *parser->root.cursor ) )
803  {
804  loader->num_glyphs = T1_ToInt( parser );
805  if ( parser->root.error )
806  return;
807  if ( loader->num_glyphs < 0 )
808  {
809  FT_ERROR(( "t42_parse_encoding: invalid number of glyphs\n" ));
810  error = FT_THROW( Invalid_File_Format );
811  goto Fail;
812  }
813 
814  /* we certainly need more than 4 bytes per glyph */
815  if ( loader->num_glyphs > ( limit - parser->root.cursor ) >> 2 )
816  {
817  FT_TRACE0(( "t42_parse_charstrings: adjusting number of glyphs"
818  " (from %d to %d)\n",
819  loader->num_glyphs,
820  ( limit - parser->root.cursor ) >> 2 ));
821  loader->num_glyphs = ( limit - parser->root.cursor ) >> 2;
822  }
823 
824  }
825  else if ( *parser->root.cursor == '<' )
826  {
827  /* We have `<< ... >>'. Count the number of `/' in the dictionary */
828  /* to get its size. */
829  FT_Int count = 0;
830 
831 
833  if ( parser->root.error )
834  return;
836  cur = parser->root.cursor;
837 
838  while ( parser->root.cursor < limit )
839  {
840  if ( *parser->root.cursor == '/' )
841  count++;
842  else if ( *parser->root.cursor == '>' )
843  {
844  loader->num_glyphs = count;
845  parser->root.cursor = cur; /* rewind */
846  break;
847  }
849  if ( parser->root.error )
850  return;
852  }
853  }
854  else
855  {
856  FT_ERROR(( "t42_parse_charstrings: invalid token\n" ));
857  error = FT_THROW( Invalid_File_Format );
858  goto Fail;
859  }
860 
861  if ( parser->root.cursor >= limit )
862  {
863  FT_ERROR(( "t42_parse_charstrings: out of bounds\n" ));
864  error = FT_THROW( Invalid_File_Format );
865  goto Fail;
866  }
867 
868  /* initialize tables */
869 
870  /* contrary to Type1, we disallow multiple CharStrings arrays */
871  if ( swap_table->init )
872  {
873  FT_ERROR(( "t42_parse_charstrings:"
874  " only one CharStrings array allowed\n" ));
875  error = FT_THROW( Invalid_File_Format );
876  goto Fail;
877  }
878 
879  error = psaux->ps_table_funcs->init( code_table,
880  loader->num_glyphs,
881  memory );
882  if ( error )
883  goto Fail;
884 
885  error = psaux->ps_table_funcs->init( name_table,
886  loader->num_glyphs,
887  memory );
888  if ( error )
889  goto Fail;
890 
891  /* Initialize table for swapping index notdef_index and */
892  /* index 0 names and codes (if necessary). */
893 
894  error = psaux->ps_table_funcs->init( swap_table, 4, memory );
895  if ( error )
896  goto Fail;
897 
898  n = 0;
899 
900  for (;;)
901  {
902  /* We support two formats. */
903  /* */
904  /* `/glyphname' + index [+ `def'] */
905  /* `(glyphname)' [+ `cvn'] + index [+ `def'] */
906  /* */
907  /* The latter format gets created by the */
908  /* LilyPond typesetting program. */
909 
911 
912  cur = parser->root.cursor;
913  if ( cur >= limit )
914  break;
915 
916  /* We stop when we find an `end' keyword or '>' */
917  if ( *cur == 'e' &&
918  cur + 3 < limit &&
919  cur[1] == 'n' &&
920  cur[2] == 'd' &&
921  t42_is_space( cur[3] ) )
922  break;
923  if ( *cur == '>' )
924  break;
925 
927  if ( parser->root.cursor >= limit )
928  {
929  FT_ERROR(( "t42_parse_charstrings: out of bounds\n" ));
930  error = FT_THROW( Invalid_File_Format );
931  goto Fail;
932  }
933  if ( parser->root.error )
934  return;
935 
936  if ( *cur == '/' || *cur == '(' )
937  {
938  FT_UInt len;
939  FT_Bool have_literal = FT_BOOL( *cur == '(' );
940 
941 
942  if ( cur + ( have_literal ? 3 : 2 ) >= limit )
943  {
944  FT_ERROR(( "t42_parse_charstrings: out of bounds\n" ));
945  error = FT_THROW( Invalid_File_Format );
946  goto Fail;
947  }
948 
949  cur++; /* skip `/' */
950  len = (FT_UInt)( parser->root.cursor - cur );
951  if ( have_literal )
952  len--;
953 
954  error = T1_Add_Table( name_table, n, cur, len + 1 );
955  if ( error )
956  goto Fail;
957 
958  /* add a trailing zero to the name table */
959  name_table->elements[n][len] = '\0';
960 
961  /* record index of /.notdef */
962  if ( *cur == '.' &&
963  ft_strcmp( ".notdef",
964  (const char*)(name_table->elements[n]) ) == 0 )
965  {
966  notdef_index = n;
967  notdef_found = 1;
968  }
969 
971 
972  if ( have_literal )
974 
975  cur = parser->root.cursor;
976 
977  (void)T1_ToInt( parser );
978  if ( parser->root.cursor >= limit )
979  {
980  FT_ERROR(( "t42_parse_charstrings: out of bounds\n" ));
981  error = FT_THROW( Invalid_File_Format );
982  goto Fail;
983  }
984 
985  len = (FT_UInt)( parser->root.cursor - cur );
986 
987  error = T1_Add_Table( code_table, n, cur, len + 1 );
988  if ( error )
989  goto Fail;
990 
991  code_table->elements[n][len] = '\0';
992 
993  n++;
994  if ( n >= loader->num_glyphs )
995  break;
996  }
997  }
998 
999  loader->num_glyphs = n;
1000 
1001  if ( !notdef_found )
1002  {
1003  FT_ERROR(( "t42_parse_charstrings: no /.notdef glyph\n" ));
1004  error = FT_THROW( Invalid_File_Format );
1005  goto Fail;
1006  }
1007 
1008  /* if /.notdef does not occupy index 0, do our magic. */
1009  if ( ft_strcmp( (const char*)".notdef",
1010  (const char*)name_table->elements[0] ) )
1011  {
1012  /* Swap glyph in index 0 with /.notdef glyph. First, add index 0 */
1013  /* name and code entries to swap_table. Then place notdef_index */
1014  /* name and code entries into swap_table. Then swap name and code */
1015  /* entries at indices notdef_index and 0 using values stored in */
1016  /* swap_table. */
1017 
1018  /* Index 0 name */
1019  error = T1_Add_Table( swap_table, 0,
1020  name_table->elements[0],
1021  name_table->lengths [0] );
1022  if ( error )
1023  goto Fail;
1024 
1025  /* Index 0 code */
1026  error = T1_Add_Table( swap_table, 1,
1027  code_table->elements[0],
1028  code_table->lengths [0] );
1029  if ( error )
1030  goto Fail;
1031 
1032  /* Index notdef_index name */
1033  error = T1_Add_Table( swap_table, 2,
1034  name_table->elements[notdef_index],
1035  name_table->lengths [notdef_index] );
1036  if ( error )
1037  goto Fail;
1038 
1039  /* Index notdef_index code */
1040  error = T1_Add_Table( swap_table, 3,
1041  code_table->elements[notdef_index],
1042  code_table->lengths [notdef_index] );
1043  if ( error )
1044  goto Fail;
1045 
1046  error = T1_Add_Table( name_table, notdef_index,
1047  swap_table->elements[0],
1048  swap_table->lengths [0] );
1049  if ( error )
1050  goto Fail;
1051 
1052  error = T1_Add_Table( code_table, notdef_index,
1053  swap_table->elements[1],
1054  swap_table->lengths [1] );
1055  if ( error )
1056  goto Fail;
1057 
1058  error = T1_Add_Table( name_table, 0,
1059  swap_table->elements[2],
1060  swap_table->lengths [2] );
1061  if ( error )
1062  goto Fail;
1063 
1064  error = T1_Add_Table( code_table, 0,
1065  swap_table->elements[3],
1066  swap_table->lengths [3] );
1067  if ( error )
1068  goto Fail;
1069 
1070  }
1071 
1072  return;
1073 
1074  Fail:
1075  parser->root.error = error;
1076  }
int FT_Error
Definition: fttypes.h:300
#define T1_Add_Table(p, i, o, l)
Definition: t42parse.c:106
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
#define error(str)
Definition: mkdosfs.c:1605
#define T1_Skip_PS_Token(p)
Definition: t42parse.c:115
signed int FT_Int
Definition: fttypes.h:220
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLdouble n
Definition: glext.h:7729
static char memory[1024 *256]
Definition: process.c:116
FT_Byte ** elements
Definition: psaux.h:150
GLint limit
Definition: glext.h:10326
FT_BEGIN_HEADER typedef unsigned char FT_Bool
Definition: fttypes.h:108
#define T1_Skip_Spaces(p)
Definition: t42parse.c:114
#define ft_isdigit(x)
Definition: ftobjs.h:118
#define FT_ERROR(varformat)
Definition: ftdebug.h:181
unsigned char FT_Byte
Definition: fttypes.h:154
#define FT_THROW(e)
Definition: ftdebug.h:213
FT_ULong init
Definition: psaux.h:146
static int t42_is_space(FT_Byte c)
Definition: t42parse.c:234
#define FT_TRACE0(varformat)
Definition: ftdebug.h:157
PS_TableRec swap_table
Definition: t42parse.h:53
PS_TableRec glyph_names
Definition: t42parse.h:51
struct PSAux_ServiceRec_ * PSAux_Service
T42_ParserRec parser
Definition: t42parse.h:44
unsigned int error
Definition: inffile.c:97
const PS_Table_FuncsRec * ps_table_funcs
Definition: psaux.h:1281
FT_Int num_glyphs
Definition: t42parse.h:50
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
Definition: ftsystem.h:66
GLenum GLsizei len
Definition: glext.h:6722
#define FT_BOOL(x)
Definition: fttypes.h:578
Definition: hiveinit.c:368
FT_BEGIN_HEADER struct T42_ParserRec_ * T42_Parser
unsigned int FT_UInt
Definition: fttypes.h:231
Definition: import.c:86
#define T1_ToInt(p)
Definition: t42parse.c:117
PS_TableRec charstrings
Definition: t42parse.h:52
FT_Error(* init)(PS_Table table, FT_Int count, FT_Memory memory)
Definition: psaux.h:87
FT_UInt * lengths
Definition: psaux.h:151
GLenum GLuint GLint GLenum face
Definition: glext.h:7025
#define ft_strcmp
Definition: ftstdlib.h:86

◆ 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_parse_encoding()

static void t42_parse_encoding ( T42_Face  face,
T42_Loader  loader 
)
static

Definition at line 294 of file t42parse.c.

296  {
297  T42_Parser parser = &loader->parser;
298  FT_Byte* cur;
299  FT_Byte* limit = parser->root.limit;
300 
301  PSAux_Service psaux = (PSAux_Service)face->psaux;
302 
303 
305  cur = parser->root.cursor;
306  if ( cur >= limit )
307  {
308  FT_ERROR(( "t42_parse_encoding: out of bounds\n" ));
309  parser->root.error = FT_THROW( Invalid_File_Format );
310  return;
311  }
312 
313  /* if we have a number or `[', the encoding is an array, */
314  /* and we must load it now */
315  if ( ft_isdigit( *cur ) || *cur == '[' )
316  {
317  T1_Encoding encode = &face->type1.encoding;
318  FT_Int count, n;
319  PS_Table char_table = &loader->encoding_table;
320  FT_Memory memory = parser->root.memory;
321  FT_Error error;
322  FT_Bool only_immediates = 0;
323 
324 
325  /* read the number of entries in the encoding; should be 256 */
326  if ( *cur == '[' )
327  {
328  count = 256;
329  only_immediates = 1;
330  parser->root.cursor++;
331  }
332  else
333  count = (FT_Int)T1_ToInt( parser );
334 
335  /* only composite fonts (which we don't support) */
336  /* can have larger values */
337  if ( count > 256 )
338  {
339  FT_ERROR(( "t42_parse_encoding: invalid encoding array size\n" ));
340  parser->root.error = FT_THROW( Invalid_File_Format );
341  return;
342  }
343 
345  if ( parser->root.cursor >= limit )
346  return;
347 
348  /* PostScript happily allows overwriting of encoding arrays */
349  if ( encode->char_index )
350  {
351  FT_FREE( encode->char_index );
352  FT_FREE( encode->char_name );
353  T1_Release_Table( char_table );
354  }
355 
356  /* we use a T1_Table to store our charnames */
357  loader->num_chars = encode->num_chars = count;
358  if ( FT_NEW_ARRAY( encode->char_index, count ) ||
359  FT_NEW_ARRAY( encode->char_name, count ) ||
361  char_table, count, memory ) ) )
362  {
363  parser->root.error = error;
364  return;
365  }
366 
367  /* We need to `zero' out encoding_table.elements */
368  for ( n = 0; n < count; n++ )
369  {
370  char* notdef = (char *)".notdef";
371 
372 
373  (void)T1_Add_Table( char_table, n, notdef, 8 );
374  }
375 
376  /* Now we need to read records of the form */
377  /* */
378  /* ... charcode /charname ... */
379  /* */
380  /* for each entry in our table. */
381  /* */
382  /* We simply look for a number followed by an immediate */
383  /* name. Note that this ignores correctly the sequence */
384  /* that is often seen in type42 fonts: */
385  /* */
386  /* 0 1 255 { 1 index exch /.notdef put } for dup */
387  /* */
388  /* used to clean the encoding array before anything else. */
389  /* */
390  /* Alternatively, if the array is directly given as */
391  /* */
392  /* /Encoding [ ... ] */
393  /* */
394  /* we only read immediates. */
395 
396  n = 0;
398 
399  while ( parser->root.cursor < limit )
400  {
401  cur = parser->root.cursor;
402 
403  /* we stop when we encounter `def' or `]' */
404  if ( *cur == 'd' && cur + 3 < limit )
405  {
406  if ( cur[1] == 'e' &&
407  cur[2] == 'f' &&
408  t42_is_space( cur[3] ) )
409  {
410  FT_TRACE6(( "encoding end\n" ));
411  cur += 3;
412  break;
413  }
414  }
415  if ( *cur == ']' )
416  {
417  FT_TRACE6(( "encoding end\n" ));
418  cur++;
419  break;
420  }
421 
422  /* check whether we have found an entry */
423  if ( ft_isdigit( *cur ) || only_immediates )
424  {
425  FT_Int charcode;
426 
427 
428  if ( only_immediates )
429  charcode = n;
430  else
431  {
432  charcode = (FT_Int)T1_ToInt( parser );
434 
435  /* protect against invalid charcode */
436  if ( cur == parser->root.cursor )
437  {
438  parser->root.error = FT_THROW( Unknown_File_Format );
439  return;
440  }
441  }
442 
443  cur = parser->root.cursor;
444 
445  if ( cur + 2 < limit && *cur == '/' && n < count )
446  {
447  FT_UInt len;
448 
449 
450  cur++;
451 
452  parser->root.cursor = cur;
454  if ( parser->root.cursor >= limit )
455  return;
456  if ( parser->root.error )
457  return;
458 
459  len = (FT_UInt)( parser->root.cursor - cur );
460 
461  parser->root.error = T1_Add_Table( char_table, charcode,
462  cur, len + 1 );
463  if ( parser->root.error )
464  return;
465  char_table->elements[charcode][len] = '\0';
466 
467  n++;
468  }
469  else if ( only_immediates )
470  {
471  /* Since the current position is not updated for */
472  /* immediates-only mode we would get an infinite loop if */
473  /* we don't do anything here. */
474  /* */
475  /* This encoding array is not valid according to the */
476  /* type42 specification (it might be an encoding for a CID */
477  /* type42 font, however), so we conclude that this font is */
478  /* NOT a type42 font. */
479  parser->root.error = FT_THROW( Unknown_File_Format );
480  return;
481  }
482  }
483  else
484  {
486  if ( parser->root.error )
487  return;
488  }
489 
491  }
492 
493  face->type1.encoding_type = T1_ENCODING_TYPE_ARRAY;
494  parser->root.cursor = cur;
495  }
496 
497  /* Otherwise, we should have either `StandardEncoding', */
498  /* `ExpertEncoding', or `ISOLatin1Encoding' */
499  else
500  {
501  if ( cur + 17 < limit &&
502  ft_strncmp( (const char*)cur, "StandardEncoding", 16 ) == 0 )
503  face->type1.encoding_type = T1_ENCODING_TYPE_STANDARD;
504 
505  else if ( cur + 15 < limit &&
506  ft_strncmp( (const char*)cur, "ExpertEncoding", 14 ) == 0 )
507  face->type1.encoding_type = T1_ENCODING_TYPE_EXPERT;
508 
509  else if ( cur + 18 < limit &&
510  ft_strncmp( (const char*)cur, "ISOLatin1Encoding", 17 ) == 0 )
511  face->type1.encoding_type = T1_ENCODING_TYPE_ISOLATIN1;
512 
513  else
514  parser->root.error = FT_ERR( Ignore );
515  }
516  }
int FT_Error
Definition: fttypes.h:300
#define T1_Add_Table(p, i, o, l)
Definition: t42parse.c:106
#define ft_strncmp
Definition: ftstdlib.h:89
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
#define error(str)
Definition: mkdosfs.c:1605
#define T1_Skip_PS_Token(p)
Definition: t42parse.c:115
signed int FT_Int
Definition: fttypes.h:220
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLdouble n
Definition: glext.h:7729
FT_BEGIN_HEADER struct T1_EncodingRecRec_ * T1_Encoding
static char memory[1024 *256]
Definition: process.c:116
FT_Byte ** elements
Definition: psaux.h:150
GLint limit
Definition: glext.h:10326
FT_BEGIN_HEADER typedef unsigned char FT_Bool
Definition: fttypes.h:108
#define T1_Skip_Spaces(p)
Definition: t42parse.c:114
#define ft_isdigit(x)
Definition: ftobjs.h:118
#define FT_ERROR(varformat)
Definition: ftdebug.h:181
unsigned char FT_Byte
Definition: fttypes.h:154
#define FT_THROW(e)
Definition: ftdebug.h:213
PS_TableRec encoding_table
Definition: t42parse.h:47
#define FT_FREE(ptr)
Definition: ftmemory.h:329
static int t42_is_space(FT_Byte c)
Definition: t42parse.c:234
#define FT_ERR(e)
Definition: fttypes.h:586
#define T1_Release_Table(p)
Definition: t42parse.c:107
struct PSAux_ServiceRec_ * PSAux_Service
T42_ParserRec parser
Definition: t42parse.h:44
unsigned int error
Definition: inffile.c:97
const PS_Table_FuncsRec * ps_table_funcs
Definition: psaux.h:1281
FT_Int num_chars
Definition: t42parse.h:46
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
Definition: ftsystem.h:66
GLenum GLsizei len
Definition: glext.h:6722
#define FT_NEW_ARRAY(ptr, count)
Definition: ftmemory.h:333
#define FT_TRACE6(varformat)
Definition: ftdebug.h:163
FT_BEGIN_HEADER struct T42_ParserRec_ * T42_Parser
#define FT_SET_ERROR(expression)
Definition: ftmemory.h:42
unsigned int FT_UInt
Definition: fttypes.h:231
Definition: import.c:86
#define T1_ToInt(p)
Definition: t42parse.c:117
FT_Error(* init)(PS_Table table, FT_Int count, FT_Memory memory)
Definition: psaux.h:87
GLenum GLuint GLint GLenum face
Definition: glext.h:7025

◆ t42_parse_font_matrix()

static void t42_parse_font_matrix ( T42_Face  face,
T42_Loader  loader 
)
static

Definition at line 243 of file t42parse.c.

245  {
246  T42_Parser parser = &loader->parser;
247  FT_Matrix* matrix = &face->type1.font_matrix;
248  FT_Vector* offset = &face->type1.font_offset;
249  FT_Fixed temp[6];
250  FT_Fixed temp_scale;
251  FT_Int result;
252 
253 
254  result = T1_ToFixedArray( parser, 6, temp, 0 );
255 
256  if ( result < 6 )
257  {
258  parser->root.error = FT_THROW( Invalid_File_Format );
259  return;
260  }
261 
262  temp_scale = FT_ABS( temp[3] );
263 
264  if ( temp_scale == 0 )
265  {
266  FT_ERROR(( "t42_parse_font_matrix: invalid font matrix\n" ));
267  parser->root.error = FT_THROW( Invalid_File_Format );
268  return;
269  }
270 
271  /* atypical case */
272  if ( temp_scale != 0x10000L )
273  {
274  temp[0] = FT_DivFix( temp[0], temp_scale );
275  temp[1] = FT_DivFix( temp[1], temp_scale );
276  temp[2] = FT_DivFix( temp[2], temp_scale );
277  temp[4] = FT_DivFix( temp[4], temp_scale );
278  temp[5] = FT_DivFix( temp[5], temp_scale );
279  temp[3] = temp[3] < 0 ? -0x10000L : 0x10000L;
280  }
281 
282  matrix->xx = temp[0];
283  matrix->yx = temp[1];
284  matrix->xy = temp[2];
285  matrix->yy = temp[3];
286 
287  /* note that the offsets must be expressed in integer font units */
288  offset->x = temp[4] >> 16;
289  offset->y = temp[5] >> 16;
290  }
FT_DivFix(FT_Long a, FT_Long b)
Definition: ftcalc.c:608
signed int FT_Int
Definition: fttypes.h:220
GLuint GLenum matrix
Definition: glext.h:9407
#define FT_ABS(a)
Definition: ftobjs.h:74
GLintptr offset
Definition: glext.h:5920
#define T1_ToFixedArray(p, m, f, t)
Definition: t42parse.c:122
#define FT_ERROR(varformat)
Definition: ftdebug.h:181
#define FT_THROW(e)
Definition: ftdebug.h:213
T42_ParserRec parser
Definition: t42parse.h:44
unsigned int error
Definition: inffile.c:97
static const WCHAR L[]
Definition: oid.c:1250
FT_BEGIN_HEADER struct T42_ParserRec_ * T42_Parser
signed long FT_Fixed
Definition: fttypes.h:288
static calc_node_t temp
Definition: rpn_ieee.c:38
Definition: import.c:86
GLuint64EXT * result
Definition: glext.h:11304
GLenum GLuint GLint GLenum face
Definition: glext.h:7025

◆ t42_parse_sfnts()

static void t42_parse_sfnts ( T42_Face  face,
T42_Loader  loader 
)
static

Definition at line 529 of file t42parse.c.

531  {
532  T42_Parser parser = &loader->parser;
533  FT_Memory memory = parser->root.memory;
534  FT_Byte* cur;
535  FT_Byte* limit = parser->root.limit;
536  FT_Error error;
537  FT_Int num_tables = 0;
538  FT_Long count;
539 
540  FT_ULong n, string_size, old_string_size, real_size;
541  FT_Byte* string_buf = NULL;
542  FT_Bool allocated = 0;
543 
545 
546 
547  /* The format is */
548  /* */
549  /* /sfnts [ <hexstring> <hexstring> ... ] def */
550  /* */
551  /* or */
552  /* */
553  /* /sfnts [ */
554  /* <num_bin_bytes> RD <binary data> */
555  /* <num_bin_bytes> RD <binary data> */
556  /* ... */
557  /* ] def */
558  /* */
559  /* with exactly one space after the `RD' token. */
560 
562 
563  if ( parser->root.cursor >= limit || *parser->root.cursor++ != '[' )
564  {
565  FT_ERROR(( "t42_parse_sfnts: can't find begin of sfnts vector\n" ));
566  error = FT_THROW( Invalid_File_Format );
567  goto Fail;
568  }
569 
572  string_size = 0;
573  old_string_size = 0;
574  count = 0;
575 
576  while ( parser->root.cursor < limit )
577  {
578  FT_ULong size;
579 
580 
581  cur = parser->root.cursor;
582 
583  if ( *cur == ']' )
584  {
585  parser->root.cursor++;
586  goto Exit;
587  }
588 
589  else if ( *cur == '<' )
590  {
592  if ( parser->root.error )
593  goto Exit;
594 
595  /* don't include delimiters */
596  string_size = (FT_ULong)( ( parser->root.cursor - cur - 2 + 1 ) / 2 );
597  if ( !string_size )
598  {
599  FT_ERROR(( "t42_parse_sfnts: invalid data in sfnts array\n" ));
600  error = FT_THROW( Invalid_File_Format );
601  goto Fail;
602  }
603  if ( FT_REALLOC( string_buf, old_string_size, string_size ) )
604  goto Fail;
605 
606  allocated = 1;
607 
608  parser->root.cursor = cur;
609  (void)T1_ToBytes( parser, string_buf, string_size, &real_size, 1 );
610  old_string_size = string_size;
611  string_size = real_size;
612  }
613 
614  else if ( ft_isdigit( *cur ) )
615  {
616  FT_Long tmp;
617 
618 
619  if ( allocated )
620  {
621  FT_ERROR(( "t42_parse_sfnts: "
622  "can't handle mixed binary and hex strings\n" ));
623  error = FT_THROW( Invalid_File_Format );
624  goto Fail;
625  }
626 
627  tmp = T1_ToInt( parser );
628  if ( tmp < 0 )
629  {
630  FT_ERROR(( "t42_parse_sfnts: invalid string size\n" ));
631  error = FT_THROW( Invalid_File_Format );
632  goto Fail;
633  }
634  else
635  string_size = (FT_ULong)tmp;
636 
637  T1_Skip_PS_Token( parser ); /* `RD' */
638  if ( parser->root.error )
639  return;
640 
641  string_buf = parser->root.cursor + 1; /* one space after `RD' */
642 
643  if ( (FT_ULong)( limit - parser->root.cursor ) <= string_size )
644  {
645  FT_ERROR(( "t42_parse_sfnts: too much binary data\n" ));
646  error = FT_THROW( Invalid_File_Format );
647  goto Fail;
648  }
649  else
650  parser->root.cursor += string_size + 1;
651  }
652 
653  if ( !string_buf )
654  {
655  FT_ERROR(( "t42_parse_sfnts: invalid data in sfnts array\n" ));
656  error = FT_THROW( Invalid_File_Format );
657  goto Fail;
658  }
659 
660  /* A string can have a trailing zero (odd) byte for padding. */
661  /* Ignore it. */
662  if ( ( string_size & 1 ) && string_buf[string_size - 1] == 0 )
663  string_size--;
664 
665  if ( !string_size )
666  {
667  FT_ERROR(( "t42_parse_sfnts: invalid string\n" ));
668  error = FT_THROW( Invalid_File_Format );
669  goto Fail;
670  }
671 
672  /* The whole TTF is now loaded into `string_buf'. We are */
673  /* checking its contents while copying it to `ttf_data'. */
674 
675  size = (FT_ULong)( limit - parser->root.cursor );
676 
677  for ( n = 0; n < string_size; n++ )
678  {
679  switch ( status )
680  {
681  case BEFORE_START:
682  /* load offset table, 12 bytes */
683  if ( count < 12 )
684  {
685  face->ttf_data[count++] = string_buf[n];
686  continue;
687  }
688  else
689  {
690  num_tables = 16 * face->ttf_data[4] + face->ttf_data[5];
692  face->ttf_size = 12 + 16 * num_tables;
693 
694  if ( (FT_Long)size < face->ttf_size )
695  {
696  FT_ERROR(( "t42_parse_sfnts: invalid data in sfnts array\n" ));
697  error = FT_THROW( Invalid_File_Format );
698  goto Fail;
699  }
700 
701  if ( FT_REALLOC( face->ttf_data, 12, face->ttf_size ) )
702  goto Fail;
703  }
704  /* fall through */
705 
706  case BEFORE_TABLE_DIR:
707  /* the offset table is read; read the table directory */
708  if ( count < face->ttf_size )
709  {
710  face->ttf_data[count++] = string_buf[n];
711  continue;
712  }
713  else
714  {
715  int i;
716  FT_ULong len;
717 
718 
719  for ( i = 0; i < num_tables; i++ )
720  {
721  FT_Byte* p = face->ttf_data + 12 + 16 * i + 12;
722 
723 
724  len = FT_PEEK_ULONG( p );
725  if ( len > size ||
726  face->ttf_size > (FT_Long)( size - len ) )
727  {
728  FT_ERROR(( "t42_parse_sfnts:"
729  " invalid data in sfnts array\n" ));
730  error = FT_THROW( Invalid_File_Format );
731  goto Fail;
732  }
733 
734  /* Pad to a 4-byte boundary length */
735  face->ttf_size += (FT_Long)( ( len + 3 ) & ~3U );
736  }
737 
739 
740  if ( FT_REALLOC( face->ttf_data, 12 + 16 * num_tables,
741  face->ttf_size + 1 ) )
742  goto Fail;
743  }
744  /* fall through */
745 
746  case OTHER_TABLES:
747  /* all other tables are just copied */
748  if ( count >= face->ttf_size )
749  {
750  FT_ERROR(( "t42_parse_sfnts: too much binary data\n" ));
751  error = FT_THROW( Invalid_File_Format );
752  goto Fail;
753  }
754  face->ttf_data[count++] = string_buf[n];
755  }
756  }
757 
759  }
760 
761  /* if control reaches this point, the format was not valid */
762  error = FT_THROW( Invalid_File_Format );
763 
764  Fail:
765  parser->root.error = error;
766 
767  Exit:
768  if ( allocated )
769  FT_FREE( string_buf );
770  }
int FT_Error
Definition: fttypes.h:300
signed long FT_Long
Definition: fttypes.h:242
unsigned long FT_ULong
Definition: fttypes.h:253
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
#define error(str)
Definition: mkdosfs.c:1605
#define T1_Skip_PS_Token(p)
Definition: t42parse.c:115
signed int FT_Int
Definition: fttypes.h:220
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define U(x)
Definition: wordpad.c:44
enum T42_Load_Status_ T42_Load_Status
GLdouble n
Definition: glext.h:7729
static char memory[1024 *256]
Definition: process.c:116
GLint limit
Definition: glext.h:10326
FT_BEGIN_HEADER typedef unsigned char FT_Bool
Definition: fttypes.h:108
#define T1_Skip_Spaces(p)
Definition: t42parse.c:114
#define ft_isdigit(x)
Definition: ftobjs.h:118
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
#define FT_ERROR(varformat)
Definition: ftdebug.h:181
unsigned char FT_Byte
Definition: fttypes.h:154
#define FT_THROW(e)
Definition: ftdebug.h:213
smooth NULL
Definition: ftsmooth.c:416
#define FT_PEEK_ULONG(p)
Definition: ftstream.h:179
#define FT_FREE(ptr)
Definition: ftmemory.h:329
GLsizeiptr size
Definition: glext.h:5919
static void Exit(void)
Definition: sock.c:1331
T42_ParserRec parser
Definition: t42parse.h:44
unsigned int error
Definition: inffile.c:97
#define T1_ToBytes(p, b, m, n, d)
Definition: t42parse.c:119
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
Definition: ftsystem.h:66
GLenum GLsizei len
Definition: glext.h:6722
Definition: hiveinit.c:368
FT_BEGIN_HEADER struct T42_ParserRec_ * T42_Parser
#define FT_REALLOC(ptr, cursz, newsz)
Definition: ftmemory.h:306
Definition: import.c:86
#define T1_ToInt(p)
Definition: t42parse.c:117
GLfloat GLfloat p
Definition: glext.h:8902
static SERVICE_STATUS status
Definition: service.c:31
GLenum GLuint GLint GLenum face
Definition: glext.h:7025
Definition: ps.c:97

◆ 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().

Variable Documentation

◆ t42_keywords

const T1_FieldRec t42_keywords[]
static

Definition at line 55 of file t42parse.c.

Referenced by t42_parse_dict().