summaryrefslogtreecommitdiffstats
path: root/src/psaux/psobjs.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/psaux/psobjs.c')
-rw-r--r--src/psaux/psobjs.c141
1 files changed, 98 insertions, 43 deletions
diff --git a/src/psaux/psobjs.c b/src/psaux/psobjs.c
index 06df6e6..dd976d3 100644
--- a/src/psaux/psobjs.c
+++ b/src/psaux/psobjs.c
@@ -4,7 +4,7 @@
/* */
/* Auxiliary functions for PostScript fonts (body). */
/* */
-/* Copyright 1996-2012 by */
+/* Copyright 1996-2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -113,8 +113,8 @@
static FT_Error
- reallocate_t1_table( PS_Table table,
- FT_Long new_size )
+ reallocate_t1_table( PS_Table table,
+ FT_Offset new_size )
{
FT_Memory memory = table->memory;
FT_Byte* old_base = table->block;
@@ -138,7 +138,7 @@
table->capacity = new_size;
- return PSaux_Err_Ok;
+ return FT_Err_Ok;
}
@@ -173,13 +173,13 @@
if ( idx < 0 || idx >= table->max_elems )
{
FT_ERROR(( "ps_table_add: invalid index\n" ));
- return PSaux_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
}
if ( length < 0 )
{
FT_ERROR(( "ps_table_add: invalid length\n" ));
- return PSaux_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
}
/* grow the base block if needed */
@@ -216,7 +216,7 @@
FT_MEM_COPY( table->block + table->cursor, object, length );
table->cursor += length;
- return PSaux_Err_Ok;
+ return FT_Err_Ok;
}
@@ -341,7 +341,7 @@
{
FT_Byte* cur = *acur;
FT_Int embed = 0;
- FT_Error error = PSaux_Err_Invalid_File_Format;
+ FT_Error error = FT_ERR( Invalid_File_Format );
unsigned int i;
@@ -397,7 +397,7 @@
embed--;
if ( embed == 0 )
{
- error = PSaux_Err_Ok;
+ error = FT_Err_Ok;
break;
}
}
@@ -416,7 +416,7 @@
FT_Byte* limit )
{
FT_Byte* cur = *acur;
- FT_Error err = PSaux_Err_Ok;
+ FT_Error err = FT_Err_Ok;
while ( ++cur < limit )
@@ -433,7 +433,7 @@
if ( cur < limit && *cur != '>' )
{
FT_ERROR(( "skip_string: missing closing delimiter `>'\n" ));
- err = PSaux_Err_Invalid_File_Format;
+ err = FT_THROW( Invalid_File_Format );
}
else
cur++;
@@ -456,12 +456,12 @@
{
FT_Byte* cur;
FT_Int embed = 0;
- FT_Error error = PSaux_Err_Ok;
+ FT_Error error = FT_Err_Ok;
FT_ASSERT( **acur == '{' );
- for ( cur = *acur; cur < limit && error == PSaux_Err_Ok; ++cur )
+ for ( cur = *acur; cur < limit && error == FT_Err_Ok; ++cur )
{
switch ( *cur )
{
@@ -494,7 +494,7 @@
end:
if ( embed != 0 )
- error = PSaux_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
*acur = cur;
@@ -519,7 +519,7 @@
FT_Byte* cur = parser->cursor;
FT_Byte* limit = parser->limit;
- FT_Error error = PSaux_Err_Ok;
+ FT_Error error = FT_Err_Ok;
skip_spaces( &cur, limit ); /* this also skips comments */
@@ -567,7 +567,7 @@
{
FT_ERROR(( "ps_parser_skip_PS_token:"
" unexpected closing delimiter `>'\n" ));
- error = PSaux_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Exit;
}
cur++;
@@ -597,7 +597,7 @@
" but invalid at this point\n",
*cur ));
- error = PSaux_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
}
parser->error = error;
@@ -644,7 +644,7 @@
token->type = T1_TOKEN_TYPE_STRING;
token->start = cur;
- if ( skip_literal_string( &cur, limit ) == PSaux_Err_Ok )
+ if ( skip_literal_string( &cur, limit ) == FT_Err_Ok )
token->limit = cur;
break;
@@ -653,7 +653,7 @@
token->type = T1_TOKEN_TYPE_ARRAY;
token->start = cur;
- if ( skip_procedure( &cur, limit ) == PSaux_Err_Ok )
+ if ( skip_procedure( &cur, limit ) == FT_Err_Ok )
token->limit = cur;
break;
@@ -1027,12 +1027,13 @@
FT_UInt max_objects,
FT_ULong* pflags )
{
- T1_TokenRec token;
- FT_Byte* cur;
- FT_Byte* limit;
- FT_UInt count;
- FT_UInt idx;
- FT_Error error;
+ T1_TokenRec token;
+ FT_Byte* cur;
+ FT_Byte* limit;
+ FT_UInt count;
+ FT_UInt idx;
+ FT_Error error;
+ T1_FieldType type;
/* this also skips leading whitespace */
@@ -1045,8 +1046,10 @@
cur = token.start;
limit = token.limit;
+ type = field->type;
+
/* we must detect arrays in /FontBBox */
- if ( field->type == T1_FIELD_TYPE_BBOX )
+ if ( type == T1_FIELD_TYPE_BBOX )
{
T1_TokenRec token2;
FT_Byte* old_cur = parser->cursor;
@@ -1062,17 +1065,21 @@
parser->limit = old_limit;
if ( token2.type == T1_TOKEN_TYPE_ARRAY )
+ {
+ type = T1_FIELD_TYPE_MM_BBOX;
goto FieldArray;
+ }
}
else if ( token.type == T1_TOKEN_TYPE_ARRAY )
{
+ count = max_objects;
+
FieldArray:
/* if this is an array and we have no blend, an error occurs */
if ( max_objects == 0 )
goto Fail;
- count = max_objects;
- idx = 1;
+ idx = 1;
/* don't include delimiters */
cur++;
@@ -1088,7 +1095,7 @@
skip_spaces( &cur, limit );
- switch ( field->type )
+ switch ( type )
{
case T1_FIELD_TYPE_BOOL:
val = ps_tobool( &cur, limit );
@@ -1160,7 +1167,7 @@
" "
" but found token of type %d instead\n",
token.type ));
- error = PSaux_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Exit;
}
@@ -1197,7 +1204,7 @@
{
FT_ERROR(( "ps_parser_load_field:"
" expected four integers in bounding box\n" ));
- error = PSaux_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Exit;
}
@@ -1208,6 +1215,54 @@
}
break;
+ case T1_FIELD_TYPE_MM_BBOX:
+ {
+ FT_Memory memory = parser->memory;
+ FT_Fixed* temp;
+ FT_Int result;
+ FT_UInt i;
+
+
+ if ( FT_NEW_ARRAY( temp, max_objects * 4 ) )
+ goto Exit;
+
+ for ( i = 0; i < 4; i++ )
+ {
+ result = ps_tofixedarray( &cur, limit, max_objects,
+ temp + i * max_objects, 0 );
+ if ( result < 0 )
+ {
+ FT_ERROR(( "ps_parser_load_field:"
+ " expected %d integers in the %s subarray\n"
+ " "
+ " of /FontBBox in the /Blend dictionary\n",
+ max_objects,
+ i == 0 ? "first"
+ : ( i == 1 ? "second"
+ : ( i == 2 ? "third"
+ : "fourth" ) ) ));
+ error = FT_THROW( Invalid_File_Format );
+ goto Exit;
+ }
+
+ skip_spaces( &cur, limit );
+ }
+
+ for ( i = 0; i < max_objects; i++ )
+ {
+ FT_BBox* bbox = (FT_BBox*)objects[i];
+
+
+ bbox->xMin = FT_RoundFix( temp[i ] );
+ bbox->yMin = FT_RoundFix( temp[i + max_objects] );
+ bbox->xMax = FT_RoundFix( temp[i + 2 * max_objects] );
+ bbox->yMax = FT_RoundFix( temp[i + 3 * max_objects] );
+ }
+
+ FT_FREE( temp );
+ }
+ break;
+
default:
/* an error occurred */
goto Fail;
@@ -1221,13 +1276,13 @@
FT_UNUSED( pflags );
#endif
- error = PSaux_Err_Ok;
+ error = FT_Err_Ok;
Exit:
return error;
Fail:
- error = PSaux_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Exit;
}
@@ -1245,7 +1300,7 @@
T1_TokenRec elements[T1_MAX_TABLE_ELEMENTS];
T1_Token token;
FT_Int num_elements;
- FT_Error error = PSaux_Err_Ok;
+ FT_Error error = FT_Err_Ok;
FT_Byte* old_cursor;
FT_Byte* old_limit;
T1_FieldRec fieldrec = *(T1_Field)field;
@@ -1260,7 +1315,7 @@
T1_MAX_TABLE_ELEMENTS, &num_elements );
if ( num_elements < 0 )
{
- error = PSaux_Err_Ignore;
+ error = FT_ERR( Ignore );
goto Exit;
}
if ( (FT_UInt)num_elements > field->array_max )
@@ -1317,7 +1372,7 @@
FT_Long* pnum_bytes,
FT_Bool delimiters )
{
- FT_Error error = PSaux_Err_Ok;
+ FT_Error error = FT_Err_Ok;
FT_Byte* cur;
@@ -1332,7 +1387,7 @@
if ( *cur != '<' )
{
FT_ERROR(( "ps_parser_to_bytes: Missing starting delimiter `<'\n" ));
- error = PSaux_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Exit;
}
@@ -1349,7 +1404,7 @@
if ( cur < parser->limit && *cur != '>' )
{
FT_ERROR(( "ps_parser_to_bytes: Missing closing delimiter `>'\n" ));
- error = PSaux_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Exit;
}
@@ -1419,7 +1474,7 @@
FT_Byte* limit,
FT_Memory memory )
{
- parser->error = PSaux_Err_Ok;
+ parser->error = FT_Err_Ok;
parser->base = base;
parser->limit = limit;
parser->cursor = base;
@@ -1592,13 +1647,13 @@
if ( !outline )
{
FT_ERROR(( "t1_builder_add_contour: no outline to add points to\n" ));
- return PSaux_Err_Invalid_File_Format;
+ return FT_THROW( Invalid_File_Format );
}
if ( !builder->load_points )
{
outline->n_contours++;
- return PSaux_Err_Ok;
+ return FT_Err_Ok;
}
error = FT_GLYPHLOADER_CHECK_POINTS( builder->loader, 0, 1 );
@@ -1621,13 +1676,13 @@
FT_Pos x,
FT_Pos y )
{
- FT_Error error = PSaux_Err_Invalid_File_Format;
+ FT_Error error = FT_ERR( Invalid_File_Format );
/* test whether we are building a new contour */
if ( builder->parse_state == T1_Parse_Have_Path )
- error = PSaux_Err_Ok;
+ error = FT_Err_Ok;
else
{
builder->parse_state = T1_Parse_Have_Path;