ReactOS 0.4.16-dev-2357-g35d0dfe
t42parse.c File Reference
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   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   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 )
GLfloat GLfloat p
Definition: glext.h:8902
static struct __wine_debug_functions funcs
Definition: debug.c:48

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 522 of file t42parse.c.

523 {
527
@ BEFORE_TABLE_DIR
Definition: t42parse.c:525
@ OTHER_TABLES
Definition: t42parse.c:526
@ BEFORE_START
Definition: t42parse.c:524
enum T42_Load_Status_ T42_Load_Status

Function Documentation

◆ t42_is_space()

static int t42_is_space ( FT_Byte  c)
static

Definition at line 235 of file t42parse.c.

236 {
237 return ( c == ' ' || c == '\t' ||
238 c == '\r' || c == '\n' || c == '\f' ||
239 c == '\0' );
240 }
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 1090 of file t42parse.c.

1093 {
1095 void* dummy_object;
1096 void** objects;
1097 FT_UInt max_objects = 0;
1098
1099
1100 /* if the keyword has a dedicated callback, call it */
1102 {
1103 field->reader( (FT_Face)face, loader );
1104 error = loader->parser.root.error;
1105 goto Exit;
1106 }
1107
1108 /* now the keyword is either a simple field or a table of fields; */
1109 /* we are now going to take care of it */
1110
1111 switch ( field->location )
1112 {
1114 dummy_object = &face->type1.font_info;
1115 break;
1116
1118 dummy_object = &face->type1.font_extra;
1119 break;
1120
1122 dummy_object = &face->type1.font_bbox;
1123 break;
1124
1125 default:
1126 dummy_object = &face->type1;
1127 }
1128
1129 objects = &dummy_object;
1130
1134 objects, max_objects, 0 );
1135 else
1136 error = T1_Load_Field( &loader->parser, field,
1137 objects, max_objects, 0 );
1138
1139 Exit:
1140 return error;
1141 }
int FT_Error
Definition: fttypes.h:299
unsigned int FT_UInt
Definition: fttypes.h:231
GLenum GLuint GLint GLenum face
Definition: glext.h:7025
#define error(str)
Definition: mkdosfs.c:1605
static const CLSID * objects[]
Definition: apphelp.c:112
@ T1_FIELD_TYPE_INTEGER_ARRAY
Definition: psaux.h:220
@ T1_FIELD_TYPE_CALLBACK
Definition: psaux.h:222
@ T1_FIELD_TYPE_FIXED_ARRAY
Definition: psaux.h:221
@ T1_FIELD_LOCATION_FONT_EXTRA
Definition: psaux.h:234
@ T1_FIELD_LOCATION_BBOX
Definition: psaux.h:237
@ T1_FIELD_LOCATION_FONT_INFO
Definition: psaux.h:235
static void Exit(void)
Definition: sock.c:1330
T42_ParserRec parser
Definition: t42parse.h:44
Definition: parser.c:44
#define T1_Load_Field(p, f, o, m, pf)
Definition: t42parse.c:127
#define T1_Load_Field_Table(p, f, o, m, pf)
Definition: t42parse.c:129

Referenced by t42_parse_dict().

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

static void t42_parse_charstrings ( T42_Face  face,
T42_Loader  loader 
)
static

Definition at line 785 of file t42parse.c.

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

◆ 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
GLsizeiptr size
Definition: glext.h:5919
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
Definition: name.c:39
#define T1_ToToken(p, t)
Definition: t42parse.c:124
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_parse_encoding()

static void t42_parse_encoding ( T42_Face  face,
T42_Loader  loader 
)
static

Definition at line 302 of file t42parse.c.

304 {
305 T42_Parser parser = &loader->parser;
306 FT_Byte* cur;
307 FT_Byte* limit = parser->root.limit;
308
309 PSAux_Service psaux = (PSAux_Service)face->psaux;
310
311
313 cur = parser->root.cursor;
314 if ( cur >= limit )
315 {
316 FT_ERROR(( "t42_parse_encoding: out of bounds\n" ));
317 parser->root.error = FT_THROW( Invalid_File_Format );
318 return;
319 }
320
321 /* if we have a number or `[', the encoding is an array, */
322 /* and we must load it now */
323 if ( ft_isdigit( *cur ) || *cur == '[' )
324 {
325 T1_Encoding encode = &face->type1.encoding;
326 FT_Int count, n;
327 PS_Table char_table = &loader->encoding_table;
328 FT_Memory memory = parser->root.memory;
330 FT_Bool only_immediates = 0;
331
332
333 /* read the number of entries in the encoding; should be 256 */
334 if ( *cur == '[' )
335 {
336 count = 256;
337 only_immediates = 1;
338 parser->root.cursor++;
339 }
340 else
342
343 /* only composite fonts (which we don't support) */
344 /* can have larger values */
345 if ( count > 256 )
346 {
347 FT_ERROR(( "t42_parse_encoding: invalid encoding array size\n" ));
348 parser->root.error = FT_THROW( Invalid_File_Format );
349 return;
350 }
351
353 if ( parser->root.cursor >= limit )
354 return;
355
356 /* PostScript happily allows overwriting of encoding arrays */
357 if ( encode->char_index )
358 {
359 FT_FREE( encode->char_index );
360 FT_FREE( encode->char_name );
361 T1_Release_Table( char_table );
362 }
363
364 /* we use a T1_Table to store our charnames */
365 loader->num_chars = encode->num_chars = count;
366 if ( FT_NEW_ARRAY( encode->char_index, count ) ||
367 FT_NEW_ARRAY( encode->char_name, count ) ||
369 char_table, count, memory ) ) )
370 {
371 parser->root.error = error;
372 return;
373 }
374
375 /* We need to `zero' out encoding_table.elements */
376 for ( n = 0; n < count; n++ )
377 (void)T1_Add_Table( char_table, n, ".notdef", 8 );
378
379 /* Now we need to read records of the form */
380 /* */
381 /* ... charcode /charname ... */
382 /* */
383 /* for each entry in our table. */
384 /* */
385 /* We simply look for a number followed by an immediate */
386 /* name. Note that this ignores correctly the sequence */
387 /* that is often seen in type42 fonts: */
388 /* */
389 /* 0 1 255 { 1 index exch /.notdef put } for dup */
390 /* */
391 /* used to clean the encoding array before anything else. */
392 /* */
393 /* Alternatively, if the array is directly given as */
394 /* */
395 /* /Encoding [ ... ] */
396 /* */
397 /* we only read immediates. */
398
399 n = 0;
401
402 while ( parser->root.cursor < limit )
403 {
404 cur = parser->root.cursor;
405
406 /* we stop when we encounter `def' or `]' */
407 if ( *cur == 'd' && cur + 3 < limit )
408 {
409 if ( cur[1] == 'e' &&
410 cur[2] == 'f' &&
411 t42_is_space( cur[3] ) )
412 {
413 FT_TRACE6(( "encoding end\n" ));
414 cur += 3;
415 break;
416 }
417 }
418 if ( *cur == ']' )
419 {
420 FT_TRACE6(( "encoding end\n" ));
421 cur++;
422 break;
423 }
424
425 /* check whether we have found an entry */
426 if ( ft_isdigit( *cur ) || only_immediates )
427 {
428 FT_Int charcode;
429
430
431 if ( only_immediates )
432 charcode = n;
433 else
434 {
435 charcode = (FT_Int)T1_ToInt( parser );
437
438 /* protect against invalid charcode */
439 if ( cur == parser->root.cursor )
440 {
441 parser->root.error = FT_THROW( Unknown_File_Format );
442 return;
443 }
444 }
445
446 cur = parser->root.cursor;
447
448 if ( cur + 2 < limit && *cur == '/' && n < count )
449 {
450 FT_UInt len;
451
452
453 cur++;
454
455 parser->root.cursor = cur;
457 if ( parser->root.cursor >= limit )
458 return;
459 if ( parser->root.error )
460 return;
461
462 len = (FT_UInt)( parser->root.cursor - cur );
463
464 parser->root.error = T1_Add_Table( char_table, charcode,
465 cur, len + 1 );
466 if ( parser->root.error )
467 return;
468 char_table->elements[charcode][len] = '\0';
469
470 n++;
471 }
472 else if ( only_immediates )
473 {
474 /* Since the current position is not updated for */
475 /* immediates-only mode we would get an infinite loop if */
476 /* we don't do anything here. */
477 /* */
478 /* This encoding array is not valid according to the */
479 /* type42 specification (it might be an encoding for a CID */
480 /* type42 font, however), so we conclude that this font is */
481 /* NOT a type42 font. */
482 parser->root.error = FT_THROW( Unknown_File_Format );
483 return;
484 }
485 }
486 else
487 {
489 if ( parser->root.error )
490 return;
491 }
492
494 }
495
496 face->type1.encoding_type = T1_ENCODING_TYPE_ARRAY;
497 parser->root.cursor = cur;
498 }
499
500 /* Otherwise, we should have either `StandardEncoding', */
501 /* `ExpertEncoding', or `ISOLatin1Encoding' */
502 else
503 {
504 if ( cur + 17 < limit &&
505 ft_strncmp( (const char*)cur, "StandardEncoding", 16 ) == 0 )
506 face->type1.encoding_type = T1_ENCODING_TYPE_STANDARD;
507
508 else if ( cur + 15 < limit &&
509 ft_strncmp( (const char*)cur, "ExpertEncoding", 14 ) == 0 )
510 face->type1.encoding_type = T1_ENCODING_TYPE_EXPERT;
511
512 else if ( cur + 18 < limit &&
513 ft_strncmp( (const char*)cur, "ISOLatin1Encoding", 17 ) == 0 )
514 face->type1.encoding_type = T1_ENCODING_TYPE_ISOLATIN1;
515
516 else
517 parser->root.error = FT_ERR( Ignore );
518 }
519 }
#define FT_TRACE6(varformat)
Definition: ftdebug.h:193
#define FT_NEW_ARRAY(ptr, count)
Definition: ftmemory.h:341
#define FT_SET_ERROR(expression)
Definition: ftmemory.h:43
#define FT_FREE(ptr)
Definition: ftmemory.h:337
#define FT_ERR(e)
Definition: fttypes.h:599
@ T1_ENCODING_TYPE_ISOLATIN1
Definition: t1tables.h:568
@ T1_ENCODING_TYPE_STANDARD
Definition: t1tables.h:567
@ T1_ENCODING_TYPE_ARRAY
Definition: t1tables.h:566
@ T1_ENCODING_TYPE_EXPERT
Definition: t1tables.h:569
FT_BEGIN_HEADER struct T1_EncodingRecRec_ * T1_Encoding

◆ t42_parse_font_matrix()

static void t42_parse_font_matrix ( T42_Face  face,
T42_Loader  loader 
)
static

Definition at line 244 of file t42parse.c.

246 {
247 T42_Parser parser = &loader->parser;
248 FT_Matrix* matrix = &face->type1.font_matrix;
249 FT_Vector* offset = &face->type1.font_offset;
250 FT_Fixed temp[6];
251 FT_Fixed temp_scale;
253
254
255 result = T1_ToFixedArray( parser, 6, temp, 0 );
256
257 if ( result < 6 )
258 {
259 parser->root.error = FT_THROW( Invalid_File_Format );
260 return;
261 }
262
263 temp_scale = FT_ABS( temp[3] );
264
265 if ( temp_scale == 0 )
266 {
267 FT_ERROR(( "t42_parse_font_matrix: invalid font matrix\n" ));
268 parser->root.error = FT_THROW( Invalid_File_Format );
269 return;
270 }
271
272 /* atypical case */
273 if ( temp_scale != 0x10000L )
274 {
275 temp[0] = FT_DivFix( temp[0], temp_scale );
276 temp[1] = FT_DivFix( temp[1], temp_scale );
277 temp[2] = FT_DivFix( temp[2], temp_scale );
278 temp[4] = FT_DivFix( temp[4], temp_scale );
279 temp[5] = FT_DivFix( temp[5], temp_scale );
280 temp[3] = temp[3] < 0 ? -0x10000L : 0x10000L;
281 }
282
283 matrix->xx = temp[0];
284 matrix->yx = temp[1];
285 matrix->xy = temp[2];
286 matrix->yy = temp[3];
287
288 if ( !FT_Matrix_Check( matrix ) )
289 {
290 FT_ERROR(( "t42_parse_font_matrix: invalid font matrix\n" ));
291 parser->root.error = FT_THROW( Invalid_File_Format );
292 return;
293 }
294
295 /* note that the offsets must be expressed in integer font units */
296 offset->x = temp[4] >> 16;
297 offset->y = temp[5] >> 16;
298 }
FT_DivFix(FT_Long a, FT_Long b)
Definition: ftcalc.c:607
FT_Matrix_Check(const FT_Matrix *matrix)
Definition: ftcalc.c:750
#define FT_ABS(a)
Definition: ftobjs.h:73
signed long FT_Fixed
Definition: fttypes.h:287
GLintptr offset
Definition: glext.h:5920
GLuint GLenum matrix
Definition: glext.h:9407
GLuint64EXT * result
Definition: glext.h:11304
static calc_node_t temp
Definition: rpn_ieee.c:38
#define T1_ToFixedArray(p, m, f, t)
Definition: t42parse.c:122

◆ t42_parse_sfnts()

static void t42_parse_sfnts ( T42_Face  face,
T42_Loader  loader 
)
static

Definition at line 532 of file t42parse.c.

534 {
535 T42_Parser parser = &loader->parser;
536 FT_Memory memory = parser->root.memory;
537 FT_Byte* cur;
538 FT_Byte* limit = parser->root.limit;
540 FT_Int num_tables = 0;
542
543 FT_ULong n, string_size, old_string_size, real_size;
544 FT_Byte* string_buf = NULL;
545 FT_Bool allocated = 0;
546
548
549
550 /* The format is */
551 /* */
552 /* /sfnts [ <hexstring> <hexstring> ... ] def */
553 /* */
554 /* or */
555 /* */
556 /* /sfnts [ */
557 /* <num_bin_bytes> RD <binary data> */
558 /* <num_bin_bytes> RD <binary data> */
559 /* ... */
560 /* ] def */
561 /* */
562 /* with exactly one space after the `RD' token. */
563
565
566 if ( parser->root.cursor >= limit || *parser->root.cursor++ != '[' )
567 {
568 FT_ERROR(( "t42_parse_sfnts: can't find begin of sfnts vector\n" ));
569 error = FT_THROW( Invalid_File_Format );
570 goto Fail;
571 }
572
575 string_size = 0;
576 old_string_size = 0;
577 count = 0;
578
579 while ( parser->root.cursor < limit )
580 {
582
583
584 cur = parser->root.cursor;
585
586 if ( *cur == ']' )
587 {
588 parser->root.cursor++;
589 goto Exit;
590 }
591
592 else if ( *cur == '<' )
593 {
594 if ( string_buf && !allocated )
595 {
596 FT_ERROR(( "t42_parse_sfnts: "
597 "can't handle mixed binary and hex strings\n" ));
598 error = FT_THROW( Invalid_File_Format );
599 goto Fail;
600 }
601
603 if ( parser->root.error )
604 goto Exit;
605
606 /* don't include delimiters */
607 string_size = (FT_ULong)( ( parser->root.cursor - cur - 2 + 1 ) / 2 );
608 if ( !string_size )
609 {
610 FT_ERROR(( "t42_parse_sfnts: invalid data in sfnts array\n" ));
611 error = FT_THROW( Invalid_File_Format );
612 goto Fail;
613 }
614 if ( FT_REALLOC( string_buf, old_string_size, string_size ) )
615 goto Fail;
616
617 allocated = 1;
618
619 parser->root.cursor = cur;
620 (void)T1_ToBytes( parser, string_buf, string_size, &real_size, 1 );
621 old_string_size = string_size;
622 string_size = real_size;
623 }
624
625 else if ( ft_isdigit( *cur ) )
626 {
627 FT_Long tmp;
628
629
630 if ( allocated )
631 {
632 FT_ERROR(( "t42_parse_sfnts: "
633 "can't handle mixed binary and hex strings\n" ));
634 error = FT_THROW( Invalid_File_Format );
635 goto Fail;
636 }
637
638 tmp = T1_ToInt( parser );
639 if ( tmp < 0 )
640 {
641 FT_ERROR(( "t42_parse_sfnts: invalid string size\n" ));
642 error = FT_THROW( Invalid_File_Format );
643 goto Fail;
644 }
645 else
646 string_size = (FT_ULong)tmp;
647
648 T1_Skip_PS_Token( parser ); /* `RD' */
649 if ( parser->root.error )
650 return;
651
652 string_buf = parser->root.cursor + 1; /* one space after `RD' */
653
654 if ( (FT_ULong)( limit - parser->root.cursor ) <= string_size )
655 {
656 FT_ERROR(( "t42_parse_sfnts: too much binary data\n" ));
657 error = FT_THROW( Invalid_File_Format );
658 goto Fail;
659 }
660 else
661 parser->root.cursor += string_size + 1;
662 }
663
664 if ( !string_buf )
665 {
666 FT_ERROR(( "t42_parse_sfnts: invalid data in sfnts array\n" ));
667 error = FT_THROW( Invalid_File_Format );
668 goto Fail;
669 }
670
671 /* A string can have a trailing zero (odd) byte for padding. */
672 /* Ignore it. */
673 if ( ( string_size & 1 ) && string_buf[string_size - 1] == 0 )
674 string_size--;
675
676 if ( !string_size )
677 {
678 FT_ERROR(( "t42_parse_sfnts: invalid string\n" ));
679 error = FT_THROW( Invalid_File_Format );
680 goto Fail;
681 }
682
683 /* The whole TTF is now loaded into `string_buf'. We are */
684 /* checking its contents while copying it to `ttf_data'. */
685
686 size = (FT_ULong)( limit - parser->root.cursor );
687
688 for ( n = 0; n < string_size; n++ )
689 {
690 switch ( status )
691 {
692 case BEFORE_START:
693 /* load offset table, 12 bytes */
694 if ( count < 12 )
695 {
696 face->ttf_data[count++] = string_buf[n];
697 continue;
698 }
699 else
700 {
701 num_tables = 16 * face->ttf_data[4] + face->ttf_data[5];
703 face->ttf_size = 12 + 16 * num_tables;
704
705 if ( (FT_Long)size < face->ttf_size )
706 {
707 FT_ERROR(( "t42_parse_sfnts: invalid data in sfnts array\n" ));
708 error = FT_THROW( Invalid_File_Format );
709 goto Fail;
710 }
711
712 if ( FT_REALLOC( face->ttf_data, 12, face->ttf_size ) )
713 goto Fail;
714 }
715 /* fall through */
716
717 case BEFORE_TABLE_DIR:
718 /* the offset table is read; read the table directory */
719 if ( count < face->ttf_size )
720 {
721 face->ttf_data[count++] = string_buf[n];
722 continue;
723 }
724 else
725 {
726 int i;
728
729
730 for ( i = 0; i < num_tables; i++ )
731 {
732 FT_Byte* p = face->ttf_data + 12 + 16 * i + 12;
733
734
735 len = FT_PEEK_ULONG( p );
736 if ( len > size ||
737 face->ttf_size > (FT_Long)( size - len ) )
738 {
739 FT_ERROR(( "t42_parse_sfnts:"
740 " invalid data in sfnts array\n" ));
741 error = FT_THROW( Invalid_File_Format );
742 goto Fail;
743 }
744
745 /* Pad to a 4-byte boundary length */
746 face->ttf_size += (FT_Long)( ( len + 3 ) & ~3U );
747 }
748
750
751 if ( FT_REALLOC( face->ttf_data, 12 + 16 * num_tables,
752 face->ttf_size + 1 ) )
753 goto Fail;
754 }
755 /* fall through */
756
757 case OTHER_TABLES:
758 /* all other tables are just copied */
759 if ( count >= face->ttf_size )
760 {
761 FT_ERROR(( "t42_parse_sfnts: too much binary data\n" ));
762 error = FT_THROW( Invalid_File_Format );
763 goto Fail;
764 }
765 face->ttf_data[count++] = string_buf[n];
766 }
767 }
768
770 }
771
772 /* if control reaches this point, the format was not valid */
773 error = FT_THROW( Invalid_File_Format );
774
775 Fail:
776 parser->root.error = error;
777
778 Exit:
779 if ( allocated )
780 FT_FREE( string_buf );
781 }
#define NULL
Definition: types.h:112
#define FT_REALLOC(ptr, cursz, newsz)
Definition: ftmemory.h:314
#define FT_PEEK_ULONG(p)
Definition: ftstream.h:194
unsigned long FT_ULong
Definition: fttypes.h:253
signed long FT_Long
Definition: fttypes.h:242
Definition: ps.c:97
#define T1_ToBytes(p, b, m, n, d)
Definition: t42parse.c:119

◆ 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 }

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 L(x)
Definition: resources.c:13
#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
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().

Variable Documentation

◆ t42_keywords

const T1_FieldRec t42_keywords[]
static

Definition at line 55 of file t42parse.c.

Referenced by t42_parse_dict().