21 #include FT_INTERNAL_DEBUG_H
22 #include FT_INTERNAL_STREAM_H
23 #include FT_INTERNAL_POSTSCRIPT_AUX_H
33 #define FT_COMPONENT trace_t42
59 #define FT_STRUCTURE T1_FontInfo
61 #define T1CODE T1_FIELD_LOCATION_FONT_INFO
71 T1_FIELD_NUM (
"UnderlineThickness", underline_thickness, 0 )
74 #define FT_STRUCTURE PS_FontExtraRec
76 #define T1CODE T1_FIELD_LOCATION_FONT_EXTRA
81 #define FT_STRUCTURE T1_FontRec
83 #define T1CODE T1_FIELD_LOCATION_FONT_DICT
91 #define FT_STRUCTURE FT_BBox
93 #define T1CODE T1_FIELD_LOCATION_BBOX
106 #define T1_Add_Table( p, i, o, l ) (p)->funcs.add( (p), i, o, l )
107 #define T1_Done_Table( p ) \
110 if ( (p)->funcs.done ) \
111 (p)->funcs.done( p ); \
113 #define T1_Release_Table( p ) \
116 if ( (p)->funcs.release ) \
117 (p)->funcs.release( p ); \
120 #define T1_Skip_Spaces( p ) (p)->root.funcs.skip_spaces( &(p)->root )
121 #define T1_Skip_PS_Token( p ) (p)->root.funcs.skip_PS_token( &(p)->root )
123 #define T1_ToInt( p ) \
124 (p)->root.funcs.to_int( &(p)->root )
125 #define T1_ToBytes( p, b, m, n, d ) \
126 (p)->root.funcs.to_bytes( &(p)->root, b, m, n, d )
128 #define T1_ToFixedArray( p, m, f, t ) \
129 (p)->root.funcs.to_fixed_array( &(p)->root, m, f, t )
130 #define T1_ToToken( p, t ) \
131 (p)->root.funcs.to_token( &(p)->root, t )
133 #define T1_Load_Field( p, f, o, m, pf ) \
134 (p)->root.funcs.load_field( &(p)->root, f, o, m, pf )
135 #define T1_Load_Field_Table( p, f, o, m, pf ) \
136 (p)->root.funcs.load_field_table( &(p)->root, f, o, m, pf )
151 psaux->ps_parser_funcs->init( &parser->root, 0, 0, memory );
154 parser->base_len = 0;
155 parser->base_dict = 0;
156 parser->in_memory = 0;
176 if (
ft_memcmp( stream->cursor,
"%!PS-TrueTypeFont", 17 ) != 0 )
179 error = T42_Err_Unknown_File_Format;
195 parser->base_dict = (
FT_Byte*)stream->base + stream->pos;
196 parser->base_len = size;
197 parser->in_memory = 1;
206 if (
FT_ALLOC( parser->base_dict, size ) ||
210 parser->base_len =
size;
213 parser->root.base = parser->base_dict;
214 parser->root.cursor = parser->base_dict;
215 parser->root.limit = parser->root.cursor + parser->base_len;
218 if ( error && !parser->in_memory )
232 if ( !parser->in_memory )
235 parser->root.funcs.done( &parser->root );
242 return ( c ==
' ' || c ==
'\t' ||
243 c ==
'\r' || c ==
'\n' || c ==
'\f' ||
262 temp_scale =
FT_ABS( temp[3] );
269 temp_scale ) >> 16 );
272 if ( temp_scale != 0x10000L )
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 );
282 matrix->
xx = temp[0];
283 matrix->
yx = temp[1];
284 matrix->
xy = temp[2];
285 matrix->
yy = temp[3];
288 offset->
x = temp[4] >> 16;
289 offset->
y = temp[5] >> 16;
305 cur = parser->root.cursor;
308 FT_ERROR((
"t42_parse_encoding: out of bounds\n" ));
309 parser->root.error = T42_Err_Invalid_File_Format;
330 parser->root.cursor++;
336 if ( parser->root.cursor >= limit )
344 char_table, count, memory ) ) )
346 parser->root.error =
error;
351 for ( n = 0; n <
count; n++ )
353 char* notdef = (
char *)
".notdef";
382 while ( parser->root.cursor < limit )
384 cur = parser->root.cursor;
387 if ( *cur ==
'd' && cur + 3 < limit )
389 if ( cur[1] ==
'e' &&
411 if ( only_immediates )
419 cur = parser->root.cursor;
421 if ( *cur ==
'/' && cur + 2 < limit && n < count )
428 parser->root.cursor = cur;
430 if ( parser->root.error )
433 len = parser->root.cursor - cur;
435 parser->root.error =
T1_Add_Table( char_table, charcode,
437 if ( parser->root.error )
439 char_table->elements[charcode][
len] =
'\0';
447 if ( parser->root.error )
455 parser->root.cursor = cur;
462 if ( cur + 17 < limit &&
463 ft_strncmp( (
const char*)cur,
"StandardEncoding", 16 ) == 0 )
466 else if ( cur + 15 < limit &&
467 ft_strncmp( (
const char*)cur,
"ExpertEncoding", 14 ) == 0 )
470 else if ( cur + 18 < limit &&
471 ft_strncmp( (
const char*)cur,
"ISOLatin1Encoding", 17 ) == 0 )
476 FT_ERROR((
"t42_parse_encoding: invalid token\n" ));
477 parser->root.error = T42_Err_Invalid_File_Format;
504 FT_Long n, string_size, old_string_size, real_size;
527 if ( parser->root.cursor >= limit || *parser->root.cursor++ !=
'[' )
529 FT_ERROR((
"t42_parse_sfnts: can't find begin of sfnts vector\n" ));
530 error = T42_Err_Invalid_File_Format;
540 while ( parser->root.cursor < limit )
542 cur = parser->root.cursor;
546 parser->root.cursor++;
550 else if ( *cur ==
'<' )
553 if ( parser->root.error )
557 string_size = (
FT_Long)( ( parser->root.cursor - cur - 2 + 1 ) / 2 );
558 if (
FT_REALLOC( string_buf, old_string_size, string_size ) )
563 parser->root.cursor = cur;
564 (
void)
T1_ToBytes( parser, string_buf, string_size, &real_size, 1 );
565 old_string_size = string_size;
566 string_size = real_size;
574 "can't handle mixed binary and hex strings\n" ));
575 error = T42_Err_Invalid_File_Format;
580 if ( string_size < 0 )
582 FT_ERROR((
"t42_parse_sfnts: invalid string size\n" ));
583 error = T42_Err_Invalid_File_Format;
588 if ( parser->root.error )
591 string_buf = parser->root.cursor + 1;
593 if ( limit - parser->root.cursor < string_size )
595 FT_ERROR((
"t42_parse_sfnts: too many binary data\n" ));
596 error = T42_Err_Invalid_File_Format;
600 parser->root.cursor += string_size + 1;
605 FT_ERROR((
"t42_parse_sfnts: invalid data in sfnts array\n" ));
606 error = T42_Err_Invalid_File_Format;
612 if ( ( string_size & 1 ) && string_buf[string_size - 1] == 0 )
617 FT_ERROR((
"t42_parse_sfnts: invalid string\n" ));
618 error = T42_Err_Invalid_File_Format;
622 for ( n = 0; n < string_size; n++ )
630 face->ttf_data[count++] = string_buf[
n];
635 num_tables = 16 * face->ttf_data[4] + face->ttf_data[5];
637 ttf_size = 12 + 16 * num_tables;
639 if (
FT_REALLOC( face->ttf_data, 12, ttf_size ) )
646 if ( count < ttf_size )
648 face->ttf_data[count++] = string_buf[
n];
657 for ( i = 0; i < num_tables; i++ )
659 FT_Byte*
p = face->ttf_data + 12 + 16 * i + 12;
665 ttf_size += ( len + 3 ) & ~3;
669 face->ttf_size = ttf_size;
672 if (
FT_REALLOC( face->ttf_data, 12 + 16 * num_tables,
680 if ( count >= ttf_size )
682 FT_ERROR((
"t42_parse_sfnts: too many binary data\n" ));
683 error = T42_Err_Invalid_File_Format;
686 face->ttf_data[count++] = string_buf[
n];
694 error = T42_Err_Invalid_File_Format;
697 parser->root.error =
error;
727 if ( parser->root.cursor >=
limit )
729 FT_ERROR((
"t42_parse_charstrings: out of bounds\n" ));
730 error = T42_Err_Invalid_File_Format;
737 if ( parser->root.error )
740 else if ( *parser->root.cursor ==
'<' )
748 if ( parser->root.error )
751 cur = parser->root.cursor;
753 while ( parser->root.cursor <
limit )
755 if ( *parser->root.cursor ==
'/' )
757 else if ( *parser->root.cursor ==
'>' )
760 parser->root.cursor = cur;
764 if ( parser->root.error )
771 FT_ERROR((
"t42_parse_charstrings: invalid token\n" ));
772 error = T42_Err_Invalid_File_Format;
776 if ( parser->root.cursor >=
limit )
778 FT_ERROR((
"t42_parse_charstrings: out of bounds\n" ));
779 error = T42_Err_Invalid_File_Format;
813 cur = parser->root.cursor;
828 if ( parser->root.error )
836 if ( cur + 1 >=
limit )
838 FT_ERROR((
"t42_parse_charstrings: out of bounds\n" ));
839 error = T42_Err_Invalid_File_Format;
844 len = parser->root.cursor - cur;
851 name_table->elements[
n][
len] =
'\0';
856 (
const char*)(name_table->elements[
n]) ) == 0 )
864 cur = parser->root.cursor;
867 if ( parser->root.cursor >=
limit )
869 FT_ERROR((
"t42_parse_charstrings: out of bounds\n" ));
870 error = T42_Err_Invalid_File_Format;
874 len = parser->root.cursor - cur;
880 code_table->elements[
n][
len] =
'\0';
892 FT_ERROR((
"t42_parse_charstrings: no /.notdef glyph\n" ));
893 error = T42_Err_Invalid_File_Format;
899 (
const char*)name_table->elements[0] ) )
909 name_table->elements[0],
910 name_table->lengths [0] );
916 code_table->elements[0],
917 code_table->lengths [0] );
923 name_table->elements[notdef_index],
924 name_table->lengths [notdef_index] );
930 code_table->elements[notdef_index],
931 code_table->lengths [notdef_index] );
936 swap_table->elements[0],
937 swap_table->lengths [0] );
942 swap_table->elements[1],
943 swap_table->lengths [1] );
948 swap_table->elements[2],
949 swap_table->lengths [2] );
954 swap_table->elements[3],
955 swap_table->lengths [3] );
964 parser->root.error =
error;
983 error = loader->
parser.root.error;
993 dummy_object = &face->type1.font_info;
997 dummy_object = &face->type1.font_extra;
1001 dummy_object = &face->type1.font_bbox;
1005 dummy_object = &face->type1;
1008 objects = &dummy_object;
1013 objects, max_objects, 0 );
1016 objects, max_objects, 0 );
1031 FT_Int n_keywords = (
FT_Int)(
sizeof ( t42_keywords ) /
1032 sizeof ( t42_keywords[0] ) );
1035 parser->root.cursor = base;
1036 parser->root.limit = base +
size;
1037 parser->root.error = T42_Err_Ok;
1039 limit = parser->root.limit;
1043 while ( parser->root.cursor < limit )
1048 cur = parser->root.cursor;
1051 if ( *cur ==
'F' && cur + 25 < limit &&
1052 ft_strncmp( (
char*)cur,
"FontDirectory", 13 ) == 0 )
1060 cur = cur2 = parser->root.cursor;
1063 while ( cur < limit )
1065 if ( *cur ==
'k' && cur + 5 < limit &&
1070 if ( parser->root.error )
1073 cur = parser->root.cursor;
1087 cur2 = parser->root.cursor;
1089 parser->root.cursor = cur2;
1093 else if ( *cur ==
'/' && cur + 2 < limit )
1100 parser->root.cursor = cur;
1102 if ( parser->root.error )
1105 len = parser->root.cursor - cur;
1115 for ( i = 0; i < n_keywords; i++ )
1124 if ( cur[0] == name[0] &&
1132 if ( parser->root.error )
1133 return parser->root.error;
1142 if ( parser->root.error )
1150 return parser->root.error;
1161 loader->num_glyphs = 0;
1162 loader->num_chars = 0;
1165 loader->encoding_table.init = 0;
1166 loader->charstrings.init = 0;
1167 loader->glyph_names.init = 0;
static void t42_parse_encoding(T42_Face face, T42_Loader loader)
#define FT_ALLOC(ptr, size)
FT_DivFix(FT_Long a, FT_Long b)
static const T1_FieldRec t42_keywords[]
#define T1_Add_Table(p, i, o, l)
GLvoid **typedef void(GLAPIENTRY *PFNGLGETVERTEXATTRIBDVPROC)(GLuint
t42_parser_done(T42_Parser parser)
#define FT_MEM_ZERO(dest, count)
#define T1_Skip_PS_Token(p)
t42_parser_init(T42_Parser parser, FT_Stream stream, FT_Memory memory, PSAux_Service psaux)
T1_FIELD_DICT_FONTDICT T1_FIELD_DICT_FONTDICT T1_FIELD_DICT_FONTDICT underline_position
enum T42_Load_Status_ T42_Load_Status
FT_BEGIN_HEADER struct T1_EncodingRecRec_ * T1_Encoding
T1_FIELD_DICT_PRIVATE T1_FIELD_DICT_PRIVATE T1_FIELD_DICT_PRIVATE T1_FIELD_DICT_PRIVATE T1_FIELD_DICT_PRIVATE T1_FIELD_DICT_PRIVATE T1_FIELD_DICT_PRIVATE T1_FIELD_DICT_PRIVATE T1_FIELD_FIXED("ExpansionFactor", expansion_factor, T1_FIELD_DICT_PRIVATE) T1_FIELD_BOOL("ForceBold"
const PS_Table_FuncsRec * ps_table_funcs
EGLImageKHR EGLint * name
#define T1_ToFixedArray(p, m, f, t)
GLuint GLuint GLfloat weight
FT_BEGIN_HEADER typedef unsigned char FT_Bool
#define T1_Skip_Spaces(p)
FT_BEGIN_HEADER struct T42_FaceRec_ * T42_Face
static void t42_parse_charstrings(T42_Face face, T42_Loader loader)
T1_FIELD_DICT_FONTDICT T1_FIELD_DICT_FONTDICT T1_FIELD_DICT_FONTDICT T1_FIELD_BOOL("isFixedPitch", is_fixed_pitch, T1_FIELD_DICT_FONTDICT) T1_FIELD_NUM("UnderlinePosition"
#define FT_ERROR(varformat)
FT_Error(* init)(PS_Table table, FT_Int count, FT_Memory memory)
static int t42_is_space(FT_Byte c)
#define FT_STREAM_SKIP(distance)
struct T1_FieldRec_ * T1_Field
static FT_Error t42_load_keyword(T42_Face face, T42_Loader loader, T1_Field field)
#define T1_FIELD_NUM(_ident, _fname, _dict)
#define T1_FIELD_KEY(_ident, _fname, _dict)
#define T1_Release_Table(p)
#define T1_FIELD_CALLBACK(_ident, _name, _dict)
struct PSAux_ServiceRec_ * PSAux_Service
#define FT_TRACE2(varformat)
struct FT_FaceRec_ * FT_Face
PS_TableRec encoding_table
#define T1_ToBytes(p, b, m, n, d)
static void t42_parse_sfnts(T42_Face face, T42_Loader loader)
#define T1_Load_Field_Table(p, f, o, m, pf)
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
#define FT_NEW_ARRAY(ptr, count)
#define FT_STREAM_SEEK(position)
typedefFT_BEGIN_HEADER struct PS_TableRec_ * PS_Table
#define FT_TRACE6(varformat)
t42_parse_dict(T42_Face face, T42_Loader loader, FT_Byte *base, FT_Long size)
FT_BEGIN_HEADER struct T42_ParserRec_ * T42_Parser
#define FT_REALLOC(ptr, cursz, newsz)
#define FT_SET_ERROR(expression)
t42_loader_done(T42_Loader loader)
T1_Field_ParseFunc reader
#define T1_Load_Field(p, f, o, m, pf)
static void t42_parse_font_matrix(T42_Face face, T42_Loader loader)
T1_FieldLocation location
#define FT_FRAME_ENTER(size)
T1_FIELD_DICT_FONTDICT T1_FIELD_DICT_FONTDICT italic_angle
T1_FIELD_DICT_FONTDICT family_name
t42_loader_init(T42_Loader loader, T42_Face face)
T1_FIELD_DICT_FONTDICT T1_FIELD_DICT_FONTDICT T1_FIELD_DICT_FONTDICT T1_FIELD_DICT_FONTDICT fs_type
#define FT_STREAM_READ(buffer, count)
#define T1_FIELD_BBOX(_ident, _fname, _dict)
#define T1_FIELD_STRING(_ident, _fname, _dict)