20 #include FT_INTERNAL_POSTSCRIPT_AUX_H 21 #include FT_INTERNAL_DEBUG_H 22 #include FT_INTERNAL_CALC_H 37 #define FT_COMPONENT trace_psobjs 76 table->memory = memory;
81 table->max_elems =
count;
82 table->init = 0xDEADBEEFUL;
107 for ( ; offset <
limit; offset++ )
127 table->block = old_base;
135 shift_elements(
table, old_base );
139 table->capacity = new_size;
173 if ( idx < 0 || idx >=
table->max_elems )
175 FT_ERROR((
"ps_table_add: invalid index\n" ));
176 return FT_THROW( Invalid_Argument );
181 FT_ERROR((
"ps_table_add: invalid length\n" ));
182 return FT_THROW( Invalid_Argument );
197 while ( new_size < table->cursor +
length )
201 new_size += ( new_size >> 2 ) + 1;
205 error = reallocate_t1_table(
table, new_size );
209 if ( in_offset >= 0 )
210 object =
table->block + in_offset;
254 shift_elements(
table, old_base );
297 while ( cur < limit )
315 while ( cur < limit )
321 skip_comment( &cur, limit );
332 #define IS_OCTAL_DIGIT( c ) ( '0' <= (c) && (c) <= '7' ) 339 skip_literal_string(
FT_Byte* *acur,
348 while ( cur < limit )
384 for ( i = 0; i < 3 && cur <
limit; ++
i )
422 while ( ++cur < limit )
425 skip_spaces( &cur, limit );
433 if ( cur < limit && *cur != '>
' ) 435 FT_ERROR(( "skip_string: missing closing delimiter `>'\
n" )); 436 err = FT_THROW( Invalid_File_Format ); 446 /* first character must be the opening brace that */ 447 /* starts the procedure */ 449 /* NB: [ and ] need not match: */ 450 /* `/foo {[} def' is a valid PostScript fragment, */ 451 /* even within a Type1 font */ 454 skip_procedure( FT_Byte* *acur, 459 FT_Error error = FT_Err_Ok; 462 FT_ASSERT( **acur == '{' ); 464 for ( cur = *acur; cur < limit && error == FT_Err_Ok; ++cur ) 482 error = skip_literal_string( &cur, limit ); 486 error = skip_string( &cur, limit ); 490 skip_comment( &cur, limit ); 497 error = FT_THROW( Invalid_File_Format ); 505 /***********************************************************************/ 507 /* All exported parsing routines handle leading whitespace and stop at */ 508 /* the first character which isn't part of the just handled token. */ 510 /***********************************************************************/ 514 ps_parser_skip_PS_token( PS_Parser parser ) 516 /* Note: PostScript allows any non-delimiting, non-whitespace */ 517 /* character in a name (PS Ref Manual, 3rd ed, p31). */ 518 /* PostScript delimiters are (, ), <, >, [, ], {, }, /, and %. */ 520 FT_Byte* cur = parser->cursor; 521 FT_Byte* limit = parser->limit; 522 FT_Error error = FT_Err_Ok; 525 skip_spaces( &cur, limit ); /* this also skips comments */ 529 /* self-delimiting, single-character tokens */ 530 if ( *cur == '[' || *cur == ']' ) 536 /* skip balanced expressions (procedures and strings) */ 538 if ( *cur == '{' ) /* {...} */ 540 error = skip_procedure( &cur, limit ); 544 if ( *cur == '(' ) /* (...) */ 546 error = skip_literal_string( &cur, limit ); 550 if ( *cur == '<' ) /* <...> */ 552 if ( cur + 1 < limit && *(cur + 1) == '<' ) /* << */ 558 error = skip_string( &cur, limit ); 566 if ( cur >= limit || *cur != '>' ) /* >> */ 570 error = FT_THROW( Invalid_File_Format ); 581 while ( cur < limit ) 583 /* *cur might be invalid (e.g., ')
' or '}
'), but this */ 584 /* is handled by the test `cur == parser->cursor' below */
592 if ( cur < limit && cur == parser->cursor )
594 FT_ERROR((
"ps_parser_skip_PS_token:" 595 " current token is `%c' which is self-delimiting\n" 597 " but invalid at this point\n",
603 parser->error =
error;
604 parser->cursor = cur;
611 skip_spaces( &parser->cursor, parser->limit );
634 cur = parser->cursor;
635 limit = parser->limit;
667 token->start = cur++;
670 parser->cursor = cur;
672 cur = parser->cursor;
674 while ( cur < limit && !parser->
error )
680 else if ( *cur ==
']' )
685 token->limit = ++cur;
690 parser->cursor = cur;
694 cur = parser->cursor;
703 cur = parser->cursor;
704 if ( !parser->error )
714 parser->cursor = cur;
737 FT_Byte* old_cursor = parser->cursor;
738 FT_Byte* old_limit = parser->limit;
744 parser->cursor = master.
start + 1;
745 parser->limit = master.
limit - 1;
747 while ( parser->cursor < parser->limit )
756 if ( tokens !=
NULL && cur < limit )
762 *pnum_tokens = (
FT_Int)( cur - tokens );
764 parser->cursor = old_cursor;
765 parser->
limit = old_limit;
775 ps_tocoordarray(
FT_Byte* *acur,
802 while ( cur <
limit )
809 skip_spaces( &cur,
limit );
821 if ( coords !=
NULL && count >= max_coords )
826 *( coords !=
NULL ? &coords[
count] : &dummy ) =
829 if ( old_cur == cur )
852 ps_tofixedarray(
FT_Byte* *acur,
880 while ( cur <
limit )
887 skip_spaces( &cur,
limit );
907 if ( old_cur == cur )
948 while ( cur <
limit && ( *cur ==
' ' || *cur ==
'\t' ) )
950 if ( cur + 1 >=
limit )
960 for ( ; cur <
limit; cur++ )
965 else if ( *cur ==
')' )
974 if ( cur >= limit ||
FT_ALLOC( result, len + 1 ) )
996 if ( cur + 3 < limit &&
1005 else if ( cur + 4 < limit &&
1055 FT_Byte* old_cur = parser->cursor;
1060 parser->cursor = token.
start + 1;
1061 parser->limit = token.
limit - 1;
1064 parser->cursor = old_cur;
1065 parser->limit = old_limit;
1075 count = max_objects;
1079 if ( max_objects == 0 )
1096 skip_spaces( &cur,
limit );
1117 switch ( field->size )
1166 " expected a name or string\n" 1168 " but found token of type %d instead\n",
1178 FT_TRACE0((
"ps_parser_load_field: overwriting field %s\n",
1201 result = ps_tofixedarray( &cur,
limit, 4, temp, 0 );
1206 " expected four integers in bounding box\n" ));
1229 for ( i = 0; i < 4; i++ )
1231 result = ps_tofixedarray( &cur,
limit, max_objects,
1232 temp + i * max_objects, 0 );
1236 " expected %d integers in the %s subarray\n" 1238 " of /FontBBox in the /Blend dictionary\n",
1241 : ( i == 1 ?
"second" 1242 : ( i == 2 ?
"third" 1248 skip_spaces( &cur,
limit );
1251 for ( i = 0; i < max_objects; i++ )
1274 *pflags |= 1L << field->flag_bit;
1290 #define T1_MAX_TABLE_ELEMENTS 32 1316 if ( num_elements < 0 )
1318 error =
FT_ERR( Ignore );
1321 if ( (
FT_UInt)num_elements > field->array_max )
1322 num_elements = field->array_max;
1324 old_cursor = parser->cursor;
1325 old_limit = parser->limit;
1335 for ( ; num_elements > 0; num_elements--, token++ )
1337 parser->cursor = token->
start;
1338 parser->limit = token->
limit;
1345 *pflags |= 1L << field->flag_bit;
1350 parser->cursor = old_cursor;
1351 parser->limit = old_limit;
1380 cur = parser->cursor;
1382 if ( cur >= parser->limit )
1389 FT_ERROR((
"ps_parser_to_bytes: Missing starting delimiter `<'\n" ));
1404 if ( cur < parser->
limit && *cur !=
'>' )
1406 FT_ERROR((
"ps_parser_to_bytes: Missing closing delimiter `>'\n" ));
1414 parser->cursor = cur;
1436 return ps_tocoordarray( &parser->cursor, parser->limit,
1448 return ps_tofixedarray( &parser->cursor, parser->limit,
1449 max_values,
values, power_ten );
1465 return ps_tobool( &parser->
cursor, parser->
limit );
1478 parser->
base = base;
1529 builder->load_points = 1;
1531 builder->face =
face;
1532 builder->glyph = glyph;
1533 builder->memory =
face->memory;
1540 builder->loader = loader;
1541 builder->base = &loader->base.outline;
1542 builder->current = &loader->current.outline;
1545 builder->hints_globals =
size->internal;
1546 builder->hints_funcs = 0;
1549 builder->hints_funcs = glyph->internal->glyph_hints;
1555 builder->left_bearing.x = 0;
1556 builder->left_bearing.y = 0;
1557 builder->advance.x = 0;
1558 builder->advance.y = 0;
1584 glyph->
outline = *builder->base;
1607 if ( builder->load_points )
1649 FT_ERROR((
"t1_builder_add_contour: no outline to add points to\n" ));
1650 return FT_THROW( Invalid_File_Format );
1653 if ( !builder->load_points )
1723 if ( p1->
x == p2->
x && p1->
y == p2->
y )
GLenum GLuint GLenum GLsizei length
#define FT_ALLOC(ptr, size)
FT_BEGIN_HEADER typedef signed long FT_Pos
t1_builder_done(T1_Builder builder)
t1_builder_add_point1(T1_Builder builder, FT_Pos x, FT_Pos y)
PS_Conv_ToFixed(FT_Byte **cursor, FT_Byte *limit, FT_Long power_ten)
#define FT_CURVE_TAG_CUBIC
GLint GLint GLint GLint GLint GLint y
enum T1_FieldType_ T1_FieldType
GLdouble GLdouble GLdouble GLdouble q
ps_parser_load_field_table(PS_Parser parser, const T1_Field field, void **objects, FT_UInt max_objects, FT_ULong *pflags)
t1_builder_start_point(T1_Builder builder, FT_Pos x, FT_Pos y)
ps_parser_done(PS_Parser parser)
return FT_THROW(Missing_Property)
PS_Conv_EexecDecode(FT_Byte **cursor, FT_Byte *limit, FT_Byte *buffer, FT_Offset n, FT_UShort *seed)
ps_parser_to_fixed(PS_Parser parser, FT_Int power_ten)
#define IS_PS_NEWLINE(ch)
ps_parser_skip_PS_token(PS_Parser parser)
GLint GLint GLint GLint GLint x
ps_parser_to_fixed_array(PS_Parser parser, FT_Int max_values, FT_Fixed *values, FT_Int power_ten)
ps_parser_to_token(PS_Parser parser, T1_Token token)
FT_BEGIN_HEADER typedef unsigned char FT_Bool
ps_table_new(PS_Table table, FT_Int count, FT_Memory memory)
GLenum GLuint GLint GLenum face
FT_CALLBACK_TABLE_DEF const T1_Builder_FuncsRec t1_builder_funcs
typedefFT_BEGIN_HEADER struct FT_GlyphLoaderRec_ * FT_GlyphLoader
#define FT_ERROR(varformat)
ps_table_add(PS_Table table, FT_Int idx, void *object, FT_PtrDist length)
#define FT_PAD_CEIL(x, n)
FT_CALLBACK_TABLE_DEF const PS_Parser_FuncsRec ps_parser_funcs
struct T1_FieldRec_ * T1_Field
ps_parser_skip_spaces(PS_Parser parser)
ps_table_release(PS_Table table)
ps_parser_load_field(PS_Parser parser, const T1_Field field, void **objects, FT_UInt max_objects, FT_ULong *pflags)
ps_parser_to_int(PS_Parser parser)
PS_Conv_ASCIIHexDecode(FT_Byte **cursor, FT_Byte *limit, FT_Byte *buffer, FT_Offset n)
#define IS_OCTAL_DIGIT(c)
ps_table_done(PS_Table table)
t1_builder_close_contour(T1_Builder builder)
GLboolean GLenum GLenum GLvoid * values
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
#define FT_NEW_ARRAY(ptr, count)
t1_decrypt(FT_Byte *buffer, FT_Offset length, FT_UShort seed)
if(!abbox) return FT_THROW(Invalid_Argument)
typedefFT_BEGIN_HEADER struct PS_TableRec_ * PS_Table
ps_parser_to_bytes(PS_Parser parser, FT_Byte *bytes, FT_Offset max_bytes, FT_Long *pnum_bytes, FT_Bool delimiters)
ps_parser_to_coord_array(PS_Parser parser, FT_Int max_coords, FT_Short *coords)
#define T1_MAX_TABLE_ELEMENTS
FT_GlyphLoader_Rewind(FT_GlyphLoader loader)
#define unexpected(table, a0)
t1_builder_add_point(T1_Builder builder, FT_Pos x, FT_Pos y, FT_Byte flag)
ps_parser_init(PS_Parser parser, FT_Byte *base, FT_Byte *limit, FT_Memory memory)
t1_builder_add_contour(T1_Builder builder)
GLuint GLuint GLsizei count
t1_builder_init(T1_Builder builder, FT_Face face, FT_Size size, FT_GlyphSlot glyph, FT_Bool hinting)
FT_TRACE0(("cff_property_set: missing property `%s'\, property_name))
#define FT_MEM_COPY(dest, source, count)
png_infop png_uint_32 flag
PS_Conv_ToInt(FT_Byte **cursor, FT_Byte *limit)
GLenum GLsizei GLenum GLenum const GLvoid * table
#define FT_GLYPHLOADER_CHECK_POINTS(_loader, _points, _contours)
ps_parser_to_token_array(PS_Parser parser, T1_Token tokens, FT_UInt max_tokens, FT_Int *pnum_tokens)
t1_builder_check_points(T1_Builder builder, FT_Int count)
FT_CALLBACK_TABLE_DEF const PS_Table_FuncsRec ps_table_funcs