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 =
FT_THROW( 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] );
271 if ( temp_scale != 0x10000L )
273 temp[0] =
FT_DivFix( temp[0], temp_scale );
274 temp[1] =
FT_DivFix( temp[1], temp_scale );
275 temp[2] =
FT_DivFix( temp[2], temp_scale );
276 temp[4] =
FT_DivFix( temp[4], temp_scale );
277 temp[5] =
FT_DivFix( temp[5], temp_scale );
281 matrix->
xx = temp[0];
282 matrix->
yx = temp[1];
283 matrix->
xy = temp[2];
284 matrix->
yy = temp[3];
287 offset->
x = temp[4] >> 16;
288 offset->
y = temp[5] >> 16;
304 cur = parser->root.cursor;
307 FT_ERROR((
"t42_parse_encoding: out of bounds\n" ));
308 parser->root.error =
FT_THROW( Invalid_File_Format );
329 parser->root.cursor++;
335 if ( parser->root.cursor >= limit )
343 char_table, count, memory ) ) )
345 parser->root.error =
error;
350 for ( n = 0; n <
count; n++ )
352 char* notdef = (
char *)
".notdef";
381 while ( parser->root.cursor < limit )
383 cur = parser->root.cursor;
386 if ( *cur ==
'd' && cur + 3 < limit )
388 if ( cur[1] ==
'e' &&
390 t42_is_space( cur[3] ) )
410 if ( only_immediates )
418 cur = parser->root.cursor;
420 if ( *cur ==
'/' && cur + 2 < limit && n < count )
427 parser->root.cursor = cur;
429 if ( parser->root.error )
432 len = parser->root.cursor - cur;
434 parser->root.error =
T1_Add_Table( char_table, charcode,
436 if ( parser->root.error )
438 char_table->elements[charcode][
len] =
'\0';
446 if ( parser->root.error )
454 parser->root.cursor = cur;
461 if ( cur + 17 < limit &&
462 ft_strncmp( (
const char*)cur,
"StandardEncoding", 16 ) == 0 )
465 else if ( cur + 15 < limit &&
466 ft_strncmp( (
const char*)cur,
"ExpertEncoding", 14 ) == 0 )
469 else if ( cur + 18 < limit &&
470 ft_strncmp( (
const char*)cur,
"ISOLatin1Encoding", 17 ) == 0 )
475 FT_ERROR((
"t42_parse_encoding: invalid token\n" ));
476 parser->root.error =
FT_THROW( Invalid_File_Format );
503 FT_Long n, string_size, old_string_size, real_size;
507 T42_Load_Status status;
526 if ( parser->root.cursor >= limit || *parser->root.cursor++ !=
'[' )
528 FT_ERROR((
"t42_parse_sfnts: can't find begin of sfnts vector\n" ));
529 error =
FT_THROW( Invalid_File_Format );
539 while ( parser->root.cursor < limit )
541 cur = parser->root.cursor;
545 parser->root.cursor++;
549 else if ( *cur ==
'<' )
552 if ( parser->root.error )
556 string_size = (
FT_Long)( ( parser->root.cursor - cur - 2 + 1 ) / 2 );
557 if (
FT_REALLOC( string_buf, old_string_size, string_size ) )
562 parser->root.cursor = cur;
563 (
void)
T1_ToBytes( parser, string_buf, string_size, &real_size, 1 );
564 old_string_size = string_size;
565 string_size = real_size;
573 "can't handle mixed binary and hex strings\n" ));
574 error =
FT_THROW( Invalid_File_Format );
579 if ( string_size < 0 )
581 FT_ERROR((
"t42_parse_sfnts: invalid string size\n" ));
582 error =
FT_THROW( Invalid_File_Format );
587 if ( parser->root.error )
590 string_buf = parser->root.cursor + 1;
592 if ( limit - parser->root.cursor < string_size )
594 FT_ERROR((
"t42_parse_sfnts: too many binary data\n" ));
595 error =
FT_THROW( Invalid_File_Format );
599 parser->root.cursor += string_size + 1;
604 FT_ERROR((
"t42_parse_sfnts: invalid data in sfnts array\n" ));
605 error =
FT_THROW( Invalid_File_Format );
611 if ( ( string_size & 1 ) && string_buf[string_size - 1] == 0 )
616 FT_ERROR((
"t42_parse_sfnts: invalid string\n" ));
617 error =
FT_THROW( Invalid_File_Format );
621 for ( n = 0; n < string_size; n++ )
629 face->ttf_data[count++] = string_buf[
n];
634 num_tables = 16 * face->ttf_data[4] + face->ttf_data[5];
636 ttf_size = 12 + 16 * num_tables;
638 if (
FT_REALLOC( face->ttf_data, 12, ttf_size ) )
645 if ( count < ttf_size )
647 face->ttf_data[count++] = string_buf[
n];
656 for ( i = 0; i < num_tables; i++ )
658 FT_Byte*
p = face->ttf_data + 12 + 16 * i + 12;
664 ttf_size += ( len + 3 ) & ~3;
668 face->ttf_size = ttf_size;
671 if (
FT_REALLOC( face->ttf_data, 12 + 16 * num_tables,
679 if ( count >= ttf_size )
681 FT_ERROR((
"t42_parse_sfnts: too many binary data\n" ));
682 error =
FT_THROW( Invalid_File_Format );
685 face->ttf_data[count++] = string_buf[
n];
693 error =
FT_THROW( Invalid_File_Format );
696 parser->root.error =
error;
705 t42_parse_charstrings(
T42_Face face,
726 if ( parser->root.cursor >=
limit )
728 FT_ERROR((
"t42_parse_charstrings: out of bounds\n" ));
729 error =
FT_THROW( Invalid_File_Format );
736 if ( parser->root.error )
739 else if ( *parser->root.cursor ==
'<' )
747 if ( parser->root.error )
750 cur = parser->root.cursor;
752 while ( parser->root.cursor <
limit )
754 if ( *parser->root.cursor ==
'/' )
756 else if ( *parser->root.cursor ==
'>' )
759 parser->root.cursor = cur;
763 if ( parser->root.error )
770 FT_ERROR((
"t42_parse_charstrings: invalid token\n" ));
771 error =
FT_THROW( Invalid_File_Format );
775 if ( parser->root.cursor >=
limit )
777 FT_ERROR((
"t42_parse_charstrings: out of bounds\n" ));
778 error =
FT_THROW( Invalid_File_Format );
812 cur = parser->root.cursor;
821 t42_is_space( cur[3] ) )
827 if ( parser->root.error )
835 if ( cur + 1 >=
limit )
837 FT_ERROR((
"t42_parse_charstrings: out of bounds\n" ));
838 error =
FT_THROW( Invalid_File_Format );
843 len = parser->root.cursor - cur;
850 name_table->elements[
n][
len] =
'\0';
855 (
const char*)(name_table->elements[
n]) ) == 0 )
863 cur = parser->root.cursor;
866 if ( parser->root.cursor >=
limit )
868 FT_ERROR((
"t42_parse_charstrings: out of bounds\n" ));
869 error =
FT_THROW( Invalid_File_Format );
873 len = parser->root.cursor - cur;
879 code_table->elements[
n][
len] =
'\0';
891 FT_ERROR((
"t42_parse_charstrings: no /.notdef glyph\n" ));
892 error =
FT_THROW( Invalid_File_Format );
898 (
const char*)name_table->elements[0] ) )
908 name_table->elements[0],
909 name_table->lengths [0] );
915 code_table->elements[0],
916 code_table->lengths [0] );
922 name_table->elements[notdef_index],
923 name_table->lengths [notdef_index] );
929 code_table->elements[notdef_index],
930 code_table->lengths [notdef_index] );
935 swap_table->elements[0],
936 swap_table->lengths [0] );
941 swap_table->elements[1],
942 swap_table->lengths [1] );
947 swap_table->elements[2],
948 swap_table->lengths [2] );
953 swap_table->elements[3],
954 swap_table->lengths [3] );
963 parser->root.error =
error;
982 error = loader->
parser.root.error;
992 dummy_object = &face->type1.font_info;
996 dummy_object = &face->type1.font_extra;
1000 dummy_object = &face->type1.font_bbox;
1004 dummy_object = &face->type1;
1007 objects = &dummy_object;
1012 objects, max_objects, 0 );
1015 objects, max_objects, 0 );
1030 FT_Int n_keywords = (
FT_Int)(
sizeof ( t42_keywords ) /
1031 sizeof ( t42_keywords[0] ) );
1034 parser->root.cursor = base;
1035 parser->root.limit = base +
size;
1038 limit = parser->root.limit;
1042 while ( parser->root.cursor < limit )
1047 cur = parser->root.cursor;
1050 if ( *cur ==
'F' && cur + 25 < limit &&
1051 ft_strncmp( (
char*)cur,
"FontDirectory", 13 ) == 0 )
1059 cur = cur2 = parser->root.cursor;
1062 while ( cur < limit )
1064 if ( *cur ==
'k' && cur + 5 < limit &&
1069 if ( parser->root.error )
1072 cur = parser->root.cursor;
1086 cur2 = parser->root.cursor;
1088 parser->root.cursor = cur2;
1092 else if ( *cur ==
'/' && cur + 2 < limit )
1099 parser->root.cursor = cur;
1101 if ( parser->root.error )
1104 len = parser->root.cursor - cur;
1114 for ( i = 0; i < n_keywords; i++ )
1123 if ( cur[0] == name[0] &&
1128 parser->root.error = t42_load_keyword( face,
1131 if ( parser->root.error )
1132 return parser->root.error;
1141 if ( parser->root.error )
1149 return parser->root.error;
1160 loader->num_glyphs = 0;
1161 loader->num_chars = 0;
1164 loader->encoding_table.init = 0;
1165 loader->charstrings.init = 0;
1166 loader->glyph_names.init = 0;
#define FT_ALLOC(ptr, size)
FT_DivFix(FT_Long a, FT_Long b)
#define T1_Add_Table(p, i, o, l)
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
return FT_THROW(Missing_Property)
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
#define T1_ToFixedArray(p, m, f, t)
typedef void(APIENTRY *GLDEBUGPROCARB)(GLenum source
FT_BEGIN_HEADER typedef unsigned char FT_Bool
#define T1_Skip_Spaces(p)
FT_BEGIN_HEADER struct T42_FaceRec_ * T42_Face
GLenum GLuint GLint GLenum face
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)
#define FT_STREAM_SKIP(distance)
struct T1_FieldRec_ * T1_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)
#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)
GLuint const GLchar * name
if(!abbox) return FT_THROW(Invalid_Argument)
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)
T1_FieldLocation location
GLuint GLuint GLsizei count
#define FT_FRAME_ENTER(size)
T1_FIELD_DICT_FONTDICT T1_FIELD_DICT_FONTDICT italic_angle
FT_Error(* init)(PS_Table table, FT_Int count, FT_Memory memory)
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
GLuint GLuint GLfloat weight
#define FT_STREAM_READ(buffer, count)
#define T1_FIELD_BBOX(_ident, _fname, _dict)
#define T1_FIELD_STRING(_ident, _fname, _dict)