summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/freetype/src/psaux
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/freetype/src/psaux')
-rw-r--r--src/3rdparty/freetype/src/psaux/afmparse.c52
-rw-r--r--src/3rdparty/freetype/src/psaux/afmparse.h3
-rw-r--r--src/3rdparty/freetype/src/psaux/psauxerr.h3
-rw-r--r--src/3rdparty/freetype/src/psaux/psauxmod.c2
-rw-r--r--src/3rdparty/freetype/src/psaux/psauxmod.h2
-rw-r--r--src/3rdparty/freetype/src/psaux/psconv.c227
-rw-r--r--src/3rdparty/freetype/src/psaux/psconv.h10
-rw-r--r--src/3rdparty/freetype/src/psaux/psobjs.c174
-rw-r--r--src/3rdparty/freetype/src/psaux/t1cmap.c30
-rw-r--r--src/3rdparty/freetype/src/psaux/t1decode.c238
10 files changed, 495 insertions, 246 deletions
diff --git a/src/3rdparty/freetype/src/psaux/afmparse.c b/src/3rdparty/freetype/src/psaux/afmparse.c
index 91a17e2362..6a40e110dc 100644
--- a/src/3rdparty/freetype/src/psaux/afmparse.c
+++ b/src/3rdparty/freetype/src/psaux/afmparse.c
@@ -4,7 +4,7 @@
/* */
/* AFM parser (body). */
/* */
-/* Copyright 2006, 2007, 2008, 2009 by */
+/* Copyright 2006-2010, 2012, 2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -17,6 +17,7 @@
#include <ft2build.h>
#include FT_FREETYPE_H
+#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_POSTSCRIPT_AUX_H
#include "afmparse.h"
@@ -119,7 +120,6 @@
afm_stream_read_one( AFM_Stream stream )
{
char* str;
- int ch;
afm_stream_skip_spaces( stream );
@@ -130,7 +130,9 @@
while ( 1 )
{
- ch = AFM_GETC();
+ int ch = AFM_GETC();
+
+
if ( AFM_IS_SPACE( ch ) )
break;
else if ( AFM_IS_NEWLINE( ch ) )
@@ -159,7 +161,6 @@
afm_stream_read_string( AFM_Stream stream )
{
char* str;
- int ch;
afm_stream_skip_spaces( stream );
@@ -171,7 +172,9 @@
/* scan to eol */
while ( 1 )
{
- ch = AFM_GETC();
+ int ch = AFM_GETC();
+
+
if ( AFM_IS_NEWLINE( ch ) )
{
stream->status = AFM_STREAM_STATUS_EOL;
@@ -527,7 +530,7 @@
FT_Byte* base,
FT_Byte* limit )
{
- AFM_Stream stream;
+ AFM_Stream stream = NULL;
FT_Error error;
@@ -545,7 +548,7 @@
parser->FontInfo = NULL;
parser->get_index = NULL;
- return PSaux_Err_Ok;
+ return FT_Err_Ok;
}
@@ -572,10 +575,10 @@
{
*aint = val.u.i;
- return PSaux_Err_Ok;
+ return FT_Err_Ok;
}
else
- return PSaux_Err_Syntax_Error;
+ return FT_THROW( Syntax_Error );
}
@@ -631,16 +634,13 @@
tk->max_ptsize = shared_vals[3].u.f;
tk->max_kern = shared_vals[4].u.f;
- /* is this correct? */
- if ( tk->degree < 0 && tk->min_kern > 0 )
- tk->min_kern = -tk->min_kern;
break;
case AFM_TOKEN_ENDTRACKKERN:
case AFM_TOKEN_ENDKERNDATA:
case AFM_TOKEN_ENDFONTMETRICS:
fi->NumTrackKern = n + 1;
- return PSaux_Err_Ok;
+ return FT_Err_Ok;
case AFM_TOKEN_UNKNOWN:
break;
@@ -651,7 +651,7 @@
}
Fail:
- return PSaux_Err_Syntax_Error;
+ return FT_THROW( Syntax_Error );
}
@@ -754,9 +754,9 @@
case AFM_TOKEN_ENDFONTMETRICS:
fi->NumKernPair = n + 1;
ft_qsort( fi->KernPairs, fi->NumKernPair,
- sizeof( AFM_KernPairRec ),
+ sizeof ( AFM_KernPairRec ),
afm_compare_kern_pairs );
- return PSaux_Err_Ok;
+ return FT_Err_Ok;
case AFM_TOKEN_UNKNOWN:
break;
@@ -767,7 +767,7 @@
}
Fail:
- return PSaux_Err_Syntax_Error;
+ return FT_THROW( Syntax_Error );
}
@@ -798,7 +798,7 @@
case AFM_TOKEN_ENDKERNDATA:
case AFM_TOKEN_ENDFONTMETRICS:
- return PSaux_Err_Ok;
+ return FT_Err_Ok;
case AFM_TOKEN_UNKNOWN:
break;
@@ -809,7 +809,7 @@
}
Fail:
- return PSaux_Err_Syntax_Error;
+ return FT_THROW( Syntax_Error );
}
@@ -835,11 +835,11 @@
if ( token == end_section || token == AFM_TOKEN_ENDFONTMETRICS )
- return PSaux_Err_Ok;
+ return FT_Err_Ok;
}
Fail:
- return PSaux_Err_Syntax_Error;
+ return FT_THROW( Syntax_Error );
}
@@ -848,19 +848,19 @@
{
FT_Memory memory = parser->memory;
AFM_FontInfo fi = parser->FontInfo;
- FT_Error error = PSaux_Err_Syntax_Error;
+ FT_Error error = FT_ERR( Syntax_Error );
char* key;
FT_Offset len;
FT_Int metrics_sets = 0;
if ( !fi )
- return PSaux_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
key = afm_parser_next_key( parser, 1, &len );
if ( !key || len != 16 ||
ft_strncmp( key, "StartFontMetrics", 16 ) != 0 )
- return PSaux_Err_Unknown_File_Format;
+ return FT_THROW( Unknown_File_Format );
while ( ( key = afm_parser_next_key( parser, 1, &len ) ) != 0 )
{
@@ -875,7 +875,7 @@
if ( metrics_sets != 0 && metrics_sets != 2 )
{
- error = PSaux_Err_Unimplemented_Feature;
+ error = FT_THROW( Unimplemented_Feature );
goto Fail;
}
@@ -941,7 +941,7 @@
/* fall through since we only support kern data */
case AFM_TOKEN_ENDFONTMETRICS:
- return PSaux_Err_Ok;
+ return FT_Err_Ok;
default:
break;
diff --git a/src/3rdparty/freetype/src/psaux/afmparse.h b/src/3rdparty/freetype/src/psaux/afmparse.h
index de2a530b2f..35d96046c5 100644
--- a/src/3rdparty/freetype/src/psaux/afmparse.h
+++ b/src/3rdparty/freetype/src/psaux/afmparse.h
@@ -56,7 +56,8 @@ FT_BEGIN_HEADER
typedef struct AFM_ValueRec_
{
enum AFM_ValueType_ type;
- union {
+ union
+ {
char* s;
FT_Fixed f;
FT_Int i;
diff --git a/src/3rdparty/freetype/src/psaux/psauxerr.h b/src/3rdparty/freetype/src/psaux/psauxerr.h
index d0baa3cbb9..d52375f8cb 100644
--- a/src/3rdparty/freetype/src/psaux/psauxerr.h
+++ b/src/3rdparty/freetype/src/psaux/psauxerr.h
@@ -4,7 +4,7 @@
/* */
/* PS auxiliary module error codes (specification only). */
/* */
-/* Copyright 2001 by */
+/* Copyright 2001, 2012 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -30,6 +30,7 @@
#undef __FTERRORS_H__
+#undef FT_ERR_PREFIX
#define FT_ERR_PREFIX PSaux_Err_
#define FT_ERR_BASE FT_Mod_Err_PSaux
diff --git a/src/3rdparty/freetype/src/psaux/psauxmod.c b/src/3rdparty/freetype/src/psaux/psauxmod.c
index 4c3579f7b8..4b1249d49b 100644
--- a/src/3rdparty/freetype/src/psaux/psauxmod.c
+++ b/src/3rdparty/freetype/src/psaux/psauxmod.c
@@ -123,7 +123,7 @@
const FT_Module_Class psaux_module_class =
{
0,
- sizeof( FT_ModuleRec ),
+ sizeof ( FT_ModuleRec ),
"psaux",
0x20000L,
0x20000L,
diff --git a/src/3rdparty/freetype/src/psaux/psauxmod.h b/src/3rdparty/freetype/src/psaux/psauxmod.h
index 35e042dbce..1217236924 100644
--- a/src/3rdparty/freetype/src/psaux/psauxmod.h
+++ b/src/3rdparty/freetype/src/psaux/psauxmod.h
@@ -28,7 +28,7 @@ FT_BEGIN_HEADER
#ifdef FT_CONFIG_OPTION_PIC
#error "this module does not support PIC yet"
-#endif
+#endif
FT_EXPORT_VAR( const FT_Module_Class ) psaux_driver_class;
diff --git a/src/3rdparty/freetype/src/psaux/psconv.c b/src/3rdparty/freetype/src/psaux/psconv.c
index 1531d8f0fb..22e8cf2d14 100644
--- a/src/3rdparty/freetype/src/psaux/psconv.c
+++ b/src/3rdparty/freetype/src/psaux/psconv.c
@@ -4,7 +4,7 @@
/* */
/* Some convenience conversions (body). */
/* */
-/* Copyright 2006, 2008, 2009 by */
+/* Copyright 2006, 2008, 2009, 2012-2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -18,11 +18,22 @@
#include <ft2build.h>
#include FT_INTERNAL_POSTSCRIPT_AUX_H
+#include FT_INTERNAL_DEBUG_H
#include "psconv.h"
#include "psauxerr.h"
+ /*************************************************************************/
+ /* */
+ /* The macro FT_COMPONENT is used in trace mode. It is an implicit */
+ /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
+ /* messages during execution. */
+ /* */
+#undef FT_COMPONENT
+#define FT_COMPONENT trace_psconv
+
+
/* The following array is used by various functions to quickly convert */
/* digits (both decimal and non-decimal) into numbers. */
@@ -69,18 +80,29 @@
#endif /* 'A' == 193 */
- FT_LOCAL_DEF( FT_Int )
+ FT_LOCAL_DEF( FT_Long )
PS_Conv_Strtol( FT_Byte** cursor,
FT_Byte* limit,
- FT_Int base )
+ FT_Long base )
{
FT_Byte* p = *cursor;
- FT_Int num = 0;
- FT_Bool sign = 0;
+ FT_Long num = 0;
+ FT_Bool sign = 0;
+ FT_Bool have_overflow = 0;
+
+ FT_Long num_limit;
+ FT_Char c_limit;
- if ( p == limit || base < 2 || base > 36 )
+
+ if ( p >= limit )
+ goto Bad;
+
+ if ( base < 2 || base > 36 )
+ {
+ FT_TRACE4(( "!!!INVALID BASE:!!!" ));
return 0;
+ }
if ( *p == '-' || *p == '+' )
{
@@ -88,9 +110,12 @@
p++;
if ( p == limit )
- return 0;
+ goto Bad;
}
+ num_limit = 0x7FFFFFFFL / base;
+ c_limit = (FT_Char)( 0x7FFFFFFFL % base );
+
for ( ; p < limit; p++ )
{
FT_Char c;
@@ -99,59 +124,89 @@
if ( IS_PS_SPACE( *p ) || *p OP 0x80 )
break;
- c = ft_char_table[*p & 0x7f];
+ c = ft_char_table[*p & 0x7F];
if ( c < 0 || c >= base )
break;
- num = num * base + c;
+ if ( num > num_limit || ( num == num_limit && c > c_limit ) )
+ have_overflow = 1;
+ else
+ num = num * base + c;
+ }
+
+ *cursor = p;
+
+ if ( have_overflow )
+ {
+ num = 0x7FFFFFFFL;
+ FT_TRACE4(( "!!!OVERFLOW:!!!" ));
}
if ( sign )
num = -num;
- *cursor = p;
-
return num;
+
+ Bad:
+ FT_TRACE4(( "!!!END OF DATA:!!!" ));
+ return 0;
}
- FT_LOCAL_DEF( FT_Int )
+ FT_LOCAL_DEF( FT_Long )
PS_Conv_ToInt( FT_Byte** cursor,
FT_Byte* limit )
{
- FT_Byte* p;
- FT_Int num;
+ FT_Byte* p = *cursor;
+ FT_Byte* curp;
+
+ FT_Long num;
- num = PS_Conv_Strtol( cursor, limit, 10 );
- p = *cursor;
+ curp = p;
+ num = PS_Conv_Strtol( &p, limit, 10 );
+
+ if ( p == curp )
+ return 0;
if ( p < limit && *p == '#' )
{
- *cursor = p + 1;
+ p++;
- return PS_Conv_Strtol( cursor, limit, num );
+ curp = p;
+ num = PS_Conv_Strtol( &p, limit, num );
+
+ if ( p == curp )
+ return 0;
}
- else
- return num;
+
+ *cursor = p;
+
+ return num;
}
FT_LOCAL_DEF( FT_Fixed )
PS_Conv_ToFixed( FT_Byte** cursor,
FT_Byte* limit,
- FT_Int power_ten )
+ FT_Long power_ten )
{
FT_Byte* p = *cursor;
- FT_Fixed integral;
- FT_Long decimal = 0, divider = 1;
- FT_Bool sign = 0;
+ FT_Byte* curp;
+ FT_Fixed integral = 0;
+ FT_Long decimal = 0;
+ FT_Long divider = 1;
- if ( p == limit )
- return 0;
+ FT_Bool sign = 0;
+ FT_Bool have_overflow = 0;
+ FT_Bool have_underflow = 0;
+
+
+ if ( p >= limit )
+ goto Bad;
if ( *p == '-' || *p == '+' )
{
@@ -159,13 +214,23 @@
p++;
if ( p == limit )
- return 0;
+ goto Bad;
}
+ /* read the integer part */
if ( *p != '.' )
- integral = PS_Conv_ToInt( &p, limit ) << 16;
- else
- integral = 0;
+ {
+ curp = p;
+ integral = PS_Conv_ToInt( &p, limit );
+
+ if ( p == curp )
+ return 0;
+
+ if ( integral > 0x7FFF )
+ have_overflow = 1;
+ else
+ integral = (FT_Fixed)( (FT_UInt32)integral << 16 );
+ }
/* read the decimal part */
if ( p < limit && *p == '.' )
@@ -180,23 +245,20 @@
if ( IS_PS_SPACE( *p ) || *p OP 0x80 )
break;
- c = ft_char_table[*p & 0x7f];
+ c = ft_char_table[*p & 0x7F];
if ( c < 0 || c >= 10 )
break;
- if ( !integral && power_ten > 0 )
+ /* only add digit if we don't overflow */
+ if ( divider < 0xCCCCCCCL && decimal < 0xCCCCCCCL )
{
- power_ten--;
decimal = decimal * 10 + c;
- }
- else
- {
- if ( divider < 10000000L )
- {
- decimal = decimal * 10 + c;
+
+ if ( !integral && power_ten > 0 )
+ power_ten--;
+ else
divider *= 10;
- }
}
}
}
@@ -204,33 +266,94 @@
/* read exponent, if any */
if ( p + 1 < limit && ( *p == 'e' || *p == 'E' ) )
{
+ FT_Long exponent;
+
+
p++;
- power_ten += PS_Conv_ToInt( &p, limit );
+
+ curp = p;
+ exponent = PS_Conv_ToInt( &p, limit );
+
+ if ( curp == p )
+ return 0;
+
+ /* arbitrarily limit exponent */
+ if ( exponent > 1000 )
+ have_overflow = 1;
+ else if ( exponent < -1000 )
+ have_underflow = 1;
+ else
+ power_ten += exponent;
}
+ *cursor = p;
+
+ if ( !integral && !decimal )
+ return 0;
+
+ if ( have_overflow )
+ goto Overflow;
+ if ( have_underflow )
+ goto Underflow;
+
while ( power_ten > 0 )
{
+ if ( integral >= 0xCCCCCCCL )
+ goto Overflow;
integral *= 10;
- decimal *= 10;
+
+ if ( decimal >= 0xCCCCCCCL )
+ {
+ if ( divider == 1 )
+ goto Overflow;
+ divider /= 10;
+ }
+ else
+ decimal *= 10;
+
power_ten--;
}
while ( power_ten < 0 )
{
integral /= 10;
- divider *= 10;
+ if ( divider < 0xCCCCCCCL )
+ divider *= 10;
+ else
+ decimal /= 10;
+
+ if ( !integral && !decimal )
+ goto Underflow;
+
power_ten++;
}
if ( decimal )
- integral += FT_DivFix( decimal, divider );
+ {
+ decimal = FT_DivFix( decimal, divider );
+ /* it's not necessary to check this addition for overflow */
+ /* due to the structure of the real number representation */
+ integral += decimal;
+ }
+ Exit:
if ( sign )
integral = -integral;
- *cursor = p;
-
return integral;
+
+ Bad:
+ FT_TRACE4(( "!!!END OF DATA:!!!" ));
+ return 0;
+
+ Overflow:
+ integral = 0x7FFFFFFFL;
+ FT_TRACE4(( "!!!OVERFLOW:!!!" ));
+ goto Exit;
+
+ Underflow:
+ FT_TRACE4(( "!!!UNDERFLOW:!!!" ));
+ return 0;
}
@@ -346,7 +469,11 @@
#if 1
- p = *cursor;
+ p = *cursor;
+
+ if ( p >= limit )
+ return 0;
+
if ( n > (FT_UInt)( limit - p ) )
n = (FT_UInt)( limit - p );
@@ -394,7 +521,7 @@
if ( *p OP 0x80 )
break;
- c = ft_char_table[*p & 0x7f];
+ c = ft_char_table[*p & 0x7F];
if ( (unsigned)c >= 16 )
break;
@@ -434,6 +561,10 @@
#if 1
p = *cursor;
+
+ if ( p >= limit )
+ return 0;
+
if ( n > (FT_UInt)(limit - p) )
n = (FT_UInt)(limit - p);
diff --git a/src/3rdparty/freetype/src/psaux/psconv.h b/src/3rdparty/freetype/src/psaux/psconv.h
index 84854ba0d1..d91c762210 100644
--- a/src/3rdparty/freetype/src/psaux/psconv.h
+++ b/src/3rdparty/freetype/src/psaux/psconv.h
@@ -4,7 +4,7 @@
/* */
/* Some convenience conversions (specification). */
/* */
-/* Copyright 2006 by */
+/* Copyright 2006, 2012 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -26,20 +26,20 @@
FT_BEGIN_HEADER
- FT_LOCAL( FT_Int )
+ FT_LOCAL( FT_Long )
PS_Conv_Strtol( FT_Byte** cursor,
FT_Byte* limit,
- FT_Int base );
+ FT_Long base );
- FT_LOCAL( FT_Int )
+ FT_LOCAL( FT_Long )
PS_Conv_ToInt( FT_Byte** cursor,
FT_Byte* limit );
FT_LOCAL( FT_Fixed )
PS_Conv_ToFixed( FT_Byte** cursor,
FT_Byte* limit,
- FT_Int power_ten );
+ FT_Long power_ten );
#if 0
FT_LOCAL( FT_UInt )
diff --git a/src/3rdparty/freetype/src/psaux/psobjs.c b/src/3rdparty/freetype/src/psaux/psobjs.c
index fe8398ae38..7ec3b4cf5f 100644
--- a/src/3rdparty/freetype/src/psaux/psobjs.c
+++ b/src/3rdparty/freetype/src/psaux/psobjs.c
@@ -4,7 +4,7 @@
/* */
/* Auxiliary functions for PostScript fonts (body). */
/* */
-/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
+/* Copyright 1996-2014 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,25 +173,25 @@
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 */
if ( table->cursor + length > table->capacity )
{
- FT_Error error;
- FT_Offset new_size = table->capacity;
- FT_Long in_offset;
+ FT_Error error;
+ FT_Offset new_size = table->capacity;
+ FT_PtrDist in_offset;
- in_offset = (FT_Long)((FT_Byte*)object - table->block);
- if ( (FT_ULong)in_offset >= table->capacity )
+ in_offset = (FT_Byte*)object - table->block;
+ if ( in_offset < 0 || (FT_Offset)in_offset >= table->capacity )
in_offset = -1;
while ( new_size < table->cursor + length )
@@ -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++;
@@ -589,7 +589,7 @@
}
Exit:
- if ( cur == parser->cursor )
+ if ( cur < limit && cur == parser->cursor )
{
FT_ERROR(( "ps_parser_skip_PS_token:"
" current token is `%c' which is self-delimiting\n"
@@ -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;
@@ -847,6 +847,8 @@
/* first character must be a delimiter or a part of a number */
/* NB: `values' can be NULL if we just want to skip the */
/* array; in this case we ignore `max_values' */
+ /* */
+ /* return number of successfully parsed values */
static FT_Int
ps_tofixedarray( FT_Byte* *acur,
@@ -1027,12 +1029,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 +1048,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 +1067,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 +1097,7 @@
skip_spaces( &cur, limit );
- switch ( field->type )
+ switch ( type )
{
case T1_FIELD_TYPE_BOOL:
val = ps_tobool( &cur, limit );
@@ -1160,7 +1169,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;
}
@@ -1193,11 +1202,11 @@
result = ps_tofixedarray( &cur, limit, 4, temp, 0 );
- if ( result < 0 )
+ if ( result < 4 )
{
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 +1217,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_UInt)result < max_objects )
+ {
+ 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 +1278,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 +1302,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 +1317,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 )
@@ -1281,7 +1338,15 @@
{
parser->cursor = token->start;
parser->limit = token->limit;
- ps_parser_load_field( parser, &fieldrec, objects, max_objects, 0 );
+
+ error = ps_parser_load_field( parser,
+ &fieldrec,
+ objects,
+ max_objects,
+ 0 );
+ if ( error )
+ break;
+
fieldrec.offset += fieldrec.size;
}
@@ -1317,7 +1382,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 +1397,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 +1414,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 +1484,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;
@@ -1588,10 +1653,17 @@
FT_Error error;
+ /* this might happen in invalid fonts */
+ if ( !outline )
+ {
+ FT_ERROR(( "t1_builder_add_contour: no outline to add points to\n" ));
+ 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 );
@@ -1614,14 +1686,14 @@
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;
- else if ( builder->parse_state == T1_Parse_Have_Moveto )
+ error = FT_Err_Ok;
+ else
{
builder->parse_state = T1_Parse_Have_Path;
error = t1_builder_add_contour( builder );
diff --git a/src/3rdparty/freetype/src/psaux/t1cmap.c b/src/3rdparty/freetype/src/psaux/t1cmap.c
index f933e4da88..fb1353ae0f 100644
--- a/src/3rdparty/freetype/src/psaux/t1cmap.c
+++ b/src/3rdparty/freetype/src/psaux/t1cmap.c
@@ -4,7 +4,7 @@
/* */
/* Type 1 character map support (body). */
/* */
-/* Copyright 2002, 2003, 2006, 2007 by */
+/* Copyright 2002, 2003, 2006, 2007, 2012 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -120,8 +120,12 @@
FT_CALLBACK_DEF( FT_Error )
- t1_cmap_standard_init( T1_CMapStd cmap )
+ t1_cmap_standard_init( T1_CMapStd cmap,
+ FT_Pointer pointer )
{
+ FT_UNUSED( pointer );
+
+
t1_cmap_std_init( cmap, 0 );
return 0;
}
@@ -142,8 +146,12 @@
FT_CALLBACK_DEF( FT_Error )
- t1_cmap_expert_init( T1_CMapStd cmap )
+ t1_cmap_expert_init( T1_CMapStd cmap,
+ FT_Pointer pointer )
{
+ FT_UNUSED( pointer );
+
+
t1_cmap_std_init( cmap, 1 );
return 0;
}
@@ -172,11 +180,14 @@
FT_CALLBACK_DEF( FT_Error )
- t1_cmap_custom_init( T1_CMapCustom cmap )
+ t1_cmap_custom_init( T1_CMapCustom cmap,
+ FT_Pointer pointer )
{
T1_Face face = (T1_Face)FT_CMAP_FACE( cmap );
T1_Encoding encoding = &face->type1.encoding;
+ FT_UNUSED( pointer );
+
cmap->first = encoding->code_first;
cmap->count = (FT_UInt)( encoding->code_last - cmap->first );
@@ -264,25 +275,28 @@
/*************************************************************************/
FT_CALLBACK_DEF( const char * )
- t1_get_glyph_name( T1_Face face,
- FT_UInt idx )
+ psaux_get_glyph_name( T1_Face face,
+ FT_UInt idx )
{
return face->type1.glyph_names[idx];
}
FT_CALLBACK_DEF( FT_Error )
- t1_cmap_unicode_init( PS_Unicodes unicodes )
+ t1_cmap_unicode_init( PS_Unicodes unicodes,
+ FT_Pointer pointer )
{
T1_Face face = (T1_Face)FT_CMAP_FACE( unicodes );
FT_Memory memory = FT_FACE_MEMORY( face );
FT_Service_PsCMaps psnames = (FT_Service_PsCMaps)face->psnames;
+ FT_UNUSED( pointer );
+
return psnames->unicodes_init( memory,
unicodes,
face->type1.num_glyphs,
- (PS_GetGlyphNameFunc)&t1_get_glyph_name,
+ (PS_GetGlyphNameFunc)&psaux_get_glyph_name,
(PS_FreeGlyphNameFunc)NULL,
(FT_Pointer)face );
}
diff --git a/src/3rdparty/freetype/src/psaux/t1decode.c b/src/3rdparty/freetype/src/psaux/t1decode.c
index 31554ff1ba..d67a05ebca 100644
--- a/src/3rdparty/freetype/src/psaux/t1decode.c
+++ b/src/3rdparty/freetype/src/psaux/t1decode.c
@@ -4,8 +4,7 @@
/* */
/* PostScript Type 1 decoding routines (body). */
/* */
-/* Copyright 2000-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 */
-/* 2010 by */
+/* Copyright 2000-2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -28,6 +27,8 @@
#include "psauxerr.h"
+/* ensure proper sign extension */
+#define Fix2Int( f ) ( (FT_Int)(FT_Short)( (f) >> 16 ) )
/*************************************************************************/
/* */
@@ -198,13 +199,19 @@
#ifdef FT_CONFIG_OPTION_INCREMENTAL
T1_Face face = (T1_Face)decoder->builder.face;
-#endif
+#endif
if ( decoder->seac )
{
FT_ERROR(( "t1operator_seac: invalid nested seac\n" ));
- return PSaux_Err_Syntax_Error;
+ return FT_THROW( Syntax_Error );
+ }
+
+ if ( decoder->builder.metrics_only )
+ {
+ FT_ERROR(( "t1operator_seac: unexpected seac\n" ));
+ return FT_THROW( Syntax_Error );
}
/* seac weirdness */
@@ -221,7 +228,7 @@
{
FT_ERROR(( "t1operator_seac:"
" glyph names table not available in this font\n" ));
- return PSaux_Err_Syntax_Error;
+ return FT_THROW( Syntax_Error );
}
#ifdef FT_CONFIG_OPTION_INCREMENTAL
@@ -242,7 +249,7 @@
{
FT_ERROR(( "t1operator_seac:"
" invalid seac character code arguments\n" ));
- return PSaux_Err_Syntax_Error;
+ return FT_THROW( Syntax_Error );
}
/* if we are trying to load a composite glyph, do not load the */
@@ -373,15 +380,6 @@
#endif
- /* we don't want to touch the source code -- use macro trick */
-#define start_point t1_builder_start_point
-#define check_points t1_builder_check_points
-#define add_point t1_builder_add_point
-#define add_point1 t1_builder_add_point1
-#define add_contour t1_builder_add_contour
-#define close_contour t1_builder_close_contour
-
-
/* compute random seed from stack address of parameter */
seed = (FT_Fixed)( ( (FT_PtrDist)(char*)&seed ^
(FT_PtrDist)(char*)&decoder ^
@@ -405,10 +403,10 @@
FT_ASSERT( ( decoder->len_buildchar == 0 ) ==
( decoder->buildchar == NULL ) );
- if ( decoder->len_buildchar > 0 )
+ if ( decoder->buildchar && decoder->len_buildchar > 0 )
ft_memset( &decoder->buildchar[0],
0,
- sizeof( decoder->buildchar[0] ) * decoder->len_buildchar );
+ sizeof ( decoder->buildchar[0] ) * decoder->len_buildchar );
FT_TRACE4(( "\n"
"Start charstring\n" ));
@@ -417,7 +415,7 @@
limit = zone->limit = charstring_base + charstring_len;
ip = zone->cursor = zone->base;
- error = PSaux_Err_Ok;
+ error = FT_Err_Ok;
x = orig_x = builder->pos_x;
y = orig_y = builder->pos_y;
@@ -567,10 +565,10 @@
goto Syntax_Error;
}
- value = (FT_Int32)( ( (FT_Long)ip[0] << 24 ) |
- ( (FT_Long)ip[1] << 16 ) |
- ( (FT_Long)ip[2] << 8 ) |
- ip[3] );
+ value = (FT_Int32)( ( (FT_UInt32)ip[0] << 24 ) |
+ ( (FT_UInt32)ip[1] << 16 ) |
+ ( (FT_UInt32)ip[2] << 8 ) |
+ (FT_UInt32)ip[3] );
ip += 4;
/* According to the specification, values > 32000 or < -32000 must */
@@ -593,7 +591,7 @@
else
{
if ( !large_int )
- value <<= 16;
+ value = (FT_Int32)( (FT_UInt32)value << 16 );
}
break;
@@ -613,13 +611,13 @@
}
if ( ip[-2] < 251 )
- value = ( ( (FT_Int32)ip[-2] - 247 ) << 8 ) + ip[-1] + 108;
+ value = ( ( ip[-2] - 247 ) * 256 ) + ip[-1] + 108;
else
- value = -( ( ( (FT_Int32)ip[-2] - 251 ) << 8 ) + ip[-1] + 108 );
+ value = -( ( ( ip[-2] - 251 ) * 256 ) + ip[-1] + 108 );
}
if ( !large_int )
- value <<= 16;
+ value = (FT_Int32)( (FT_UInt32)value << 16 );
}
else
{
@@ -671,7 +669,7 @@
if ( large_int )
FT_TRACE4(( " %ld", value ));
else
- FT_TRACE4(( " %ld", (FT_Int32)( value >> 16 ) ));
+ FT_TRACE4(( " %ld", Fix2Int( value ) ));
#endif
*top++ = value;
@@ -693,8 +691,8 @@
top -= 2;
- subr_no = (FT_Int)( top[1] >> 16 );
- arg_cnt = (FT_Int)( top[0] >> 16 );
+ subr_no = Fix2Int( top[1] );
+ arg_cnt = Fix2Int( top[0] );
/***********************************************************/
/* */
@@ -733,14 +731,34 @@
switch ( subr_no )
{
+ case 0: /* end flex feature */
+ if ( arg_cnt != 3 )
+ goto Unexpected_OtherSubr;
+
+ if ( decoder->flex_state == 0 ||
+ decoder->num_flex_vectors != 7 )
+ {
+ FT_ERROR(( "t1_decoder_parse_charstrings:"
+ " unexpected flex end\n" ));
+ goto Syntax_Error;
+ }
+
+ /* the two `results' are popped by the following setcurrentpoint */
+ top[0] = x;
+ top[1] = y;
+ known_othersubr_result_cnt = 2;
+ break;
+
case 1: /* start flex feature */
if ( arg_cnt != 0 )
goto Unexpected_OtherSubr;
decoder->flex_state = 1;
decoder->num_flex_vectors = 0;
- if ( start_point( builder, x, y ) ||
- check_points( builder, 6 ) )
+ if ( ( error = t1_builder_start_point( builder, x, y ) )
+ != FT_Err_Ok ||
+ ( error = t1_builder_check_points( builder, 6 ) )
+ != FT_Err_Ok )
goto Fail;
break;
@@ -752,34 +770,25 @@
if ( arg_cnt != 0 )
goto Unexpected_OtherSubr;
+ if ( decoder->flex_state == 0 )
+ {
+ FT_ERROR(( "t1_decoder_parse_charstrings:"
+ " missing flex start\n" ));
+ goto Syntax_Error;
+ }
+
/* note that we should not add a point for index 0; */
/* this will move our current position to the flex */
/* point without adding any point to the outline */
idx = decoder->num_flex_vectors++;
if ( idx > 0 && idx < 7 )
- add_point( builder,
- x,
- y,
- (FT_Byte)( idx == 3 || idx == 6 ) );
+ t1_builder_add_point( builder,
+ x,
+ y,
+ (FT_Byte)( idx == 3 || idx == 6 ) );
}
break;
- case 0: /* end flex feature */
- if ( arg_cnt != 3 )
- goto Unexpected_OtherSubr;
-
- if ( decoder->flex_state == 0 ||
- decoder->num_flex_vectors != 7 )
- {
- FT_ERROR(( "t1_decoder_parse_charstrings:"
- " unexpected flex end\n" ));
- goto Syntax_Error;
- }
-
- /* the two `results' are popped by the following setcurrentpoint */
- known_othersubr_result_cnt = 2;
- break;
-
case 3: /* change hints */
if ( arg_cnt != 1 )
goto Unexpected_OtherSubr;
@@ -823,17 +832,18 @@
goto Syntax_Error;
}
- /* we want to compute: */
+ /* We want to compute */
+ /* */
+ /* a0*w0 + a1*w1 + ... + ak*wk */
/* */
- /* a0*w0 + a1*w1 + ... + ak*wk */
+ /* but we only have a0, a1-a0, a2-a0, ..., ak-a0. */
/* */
- /* but we only have the a0, a1-a0, a2-a0, .. ak-a0 */
- /* however, given that w0 + w1 + ... + wk == 1, we can */
- /* rewrite it easily as: */
+ /* However, given that w0 + w1 + ... + wk == 1, we can */
+ /* rewrite it easily as */
/* */
- /* a0 + (a1-a0)*w1 + (a2-a0)*w2 + .. + (ak-a0)*wk */
+ /* a0 + (a1-a0)*w1 + (a2-a0)*w2 + ... + (ak-a0)*wk */
/* */
- /* where k == num_designs-1 */
+ /* where k == num_designs-1. */
/* */
/* I guess that's why it's written in this `compact' */
/* form. */
@@ -867,7 +877,7 @@
if ( arg_cnt != 1 || blend == NULL )
goto Unexpected_OtherSubr;
- idx = (FT_Int)( top[0] >> 16 );
+ idx = Fix2Int( top[0] );
if ( idx < 0 ||
idx + blend->num_designs > decoder->len_buildchar )
@@ -876,7 +886,7 @@
ft_memcpy( &decoder->buildchar[idx],
blend->weight_vector,
blend->num_designs *
- sizeof( blend->weight_vector[0] ) );
+ sizeof ( blend->weight_vector[0] ) );
}
break;
@@ -935,7 +945,7 @@
if ( arg_cnt != 2 || blend == NULL )
goto Unexpected_OtherSubr;
- idx = (FT_Int)( top[1] >> 16 );
+ idx = Fix2Int( top[1] );
if ( idx < 0 || (FT_UInt) idx >= decoder->len_buildchar )
goto Unexpected_OtherSubr;
@@ -956,7 +966,7 @@
if ( arg_cnt != 1 || blend == NULL )
goto Unexpected_OtherSubr;
- idx = (FT_Int)( top[0] >> 16 );
+ idx = Fix2Int( top[0] );
if ( idx < 0 || (FT_UInt) idx >= decoder->len_buildchar )
goto Unexpected_OtherSubr;
@@ -1014,11 +1024,15 @@
break;
default:
- FT_ERROR(( "t1_decoder_parse_charstrings:"
- " unknown othersubr [%d %d], wish me luck\n",
- arg_cnt, subr_no ));
- unknown_othersubr_result_cnt = arg_cnt;
- break;
+ if ( arg_cnt >= 0 && subr_no >= 0 )
+ {
+ FT_ERROR(( "t1_decoder_parse_charstrings:"
+ " unknown othersubr [%d %d], wish me luck\n",
+ arg_cnt, subr_no ));
+ unknown_othersubr_result_cnt = arg_cnt;
+ break;
+ }
+ /* fall through */
Unexpected_OtherSubr:
FT_ERROR(( "t1_decoder_parse_charstrings:"
@@ -1075,7 +1089,7 @@
case op_endchar:
FT_TRACE4(( " endchar\n" ));
- close_contour( builder );
+ t1_builder_close_contour( builder );
/* close hints recording session */
if ( hinter )
@@ -1084,10 +1098,12 @@
goto Syntax_Error;
/* apply hints to the loaded glyph outline now */
- hinter->apply( hinter->hints,
- builder->current,
- (PSH_Globals)builder->hints_globals,
- decoder->hint_mode );
+ error = hinter->apply( hinter->hints,
+ builder->current,
+ (PSH_Globals)builder->hints_globals,
+ decoder->hint_mode );
+ if ( error )
+ goto Fail;
}
/* add current outline to the glyph slot */
@@ -1105,7 +1121,7 @@
FT_TRACE4(( "BuildCharArray = [ " ));
for ( i = 0; i < decoder->len_buildchar; ++i )
- FT_TRACE4(( "%d ", decoder->buildchar[ i ] ));
+ FT_TRACE4(( "%d ", decoder->buildchar[i] ));
FT_TRACE4(( "]\n" ));
}
@@ -1115,7 +1131,7 @@
FT_TRACE4(( "\n" ));
/* return now! */
- return PSaux_Err_Ok;
+ return FT_Err_Ok;
case op_hsbw:
FT_TRACE4(( " hsbw" ));
@@ -1135,7 +1151,7 @@
/* the glyph's metrics (lsb + advance width), not load the */
/* rest of it; so exit immediately */
if ( builder->metrics_only )
- return PSaux_Err_Ok;
+ return FT_Err_Ok;
break;
@@ -1144,8 +1160,8 @@
top[0],
top[1],
top[2],
- (FT_Int)( top[3] >> 16 ),
- (FT_Int)( top[4] >> 16 ) );
+ Fix2Int( top[3] ),
+ Fix2Int( top[4] ) );
case op_sbw:
FT_TRACE4(( " sbw" ));
@@ -1164,7 +1180,7 @@
/* the glyph's metrics (lsb + advance width), not load the */
/* rest of it; so exit immediately */
if ( builder->metrics_only )
- return PSaux_Err_Ok;
+ return FT_Err_Ok;
break;
@@ -1174,7 +1190,7 @@
/* if there is no path, `closepath' is a no-op */
if ( builder->parse_state == T1_Parse_Have_Path ||
builder->parse_state == T1_Parse_Have_Moveto )
- close_contour( builder );
+ t1_builder_close_contour( builder );
builder->parse_state = T1_Parse_Have_Width;
break;
@@ -1182,7 +1198,8 @@
case op_hlineto:
FT_TRACE4(( " hlineto" ));
- if ( start_point( builder, x, y ) )
+ if ( ( error = t1_builder_start_point( builder, x, y ) )
+ != FT_Err_Ok )
goto Fail;
x += top[0];
@@ -1203,30 +1220,34 @@
case op_hvcurveto:
FT_TRACE4(( " hvcurveto" ));
- if ( start_point( builder, x, y ) ||
- check_points( builder, 3 ) )
+ if ( ( error = t1_builder_start_point( builder, x, y ) )
+ != FT_Err_Ok ||
+ ( error = t1_builder_check_points( builder, 3 ) )
+ != FT_Err_Ok )
goto Fail;
x += top[0];
- add_point( builder, x, y, 0 );
+ t1_builder_add_point( builder, x, y, 0 );
x += top[1];
y += top[2];
- add_point( builder, x, y, 0 );
+ t1_builder_add_point( builder, x, y, 0 );
y += top[3];
- add_point( builder, x, y, 1 );
+ t1_builder_add_point( builder, x, y, 1 );
break;
case op_rlineto:
FT_TRACE4(( " rlineto" ));
- if ( start_point( builder, x, y ) )
+ if ( ( error = t1_builder_start_point( builder, x, y ) )
+ != FT_Err_Ok )
goto Fail;
x += top[0];
y += top[1];
Add_Line:
- if ( add_point1( builder, x, y ) )
+ if ( ( error = t1_builder_add_point1( builder, x, y ) )
+ != FT_Err_Ok )
goto Fail;
break;
@@ -1246,43 +1267,48 @@
case op_rrcurveto:
FT_TRACE4(( " rrcurveto" ));
- if ( start_point( builder, x, y ) ||
- check_points( builder, 3 ) )
+ if ( ( error = t1_builder_start_point( builder, x, y ) )
+ != FT_Err_Ok ||
+ ( error = t1_builder_check_points( builder, 3 ) )
+ != FT_Err_Ok )
goto Fail;
x += top[0];
y += top[1];
- add_point( builder, x, y, 0 );
+ t1_builder_add_point( builder, x, y, 0 );
x += top[2];
y += top[3];
- add_point( builder, x, y, 0 );
+ t1_builder_add_point( builder, x, y, 0 );
x += top[4];
y += top[5];
- add_point( builder, x, y, 1 );
+ t1_builder_add_point( builder, x, y, 1 );
break;
case op_vhcurveto:
FT_TRACE4(( " vhcurveto" ));
- if ( start_point( builder, x, y ) ||
- check_points( builder, 3 ) )
+ if ( ( error = t1_builder_start_point( builder, x, y ) )
+ != FT_Err_Ok ||
+ ( error = t1_builder_check_points( builder, 3 ) )
+ != FT_Err_Ok )
goto Fail;
y += top[0];
- add_point( builder, x, y, 0 );
+ t1_builder_add_point( builder, x, y, 0 );
x += top[1];
y += top[2];
- add_point( builder, x, y, 0 );
+ t1_builder_add_point( builder, x, y, 0 );
x += top[3];
- add_point( builder, x, y, 1 );
+ t1_builder_add_point( builder, x, y, 1 );
break;
case op_vlineto:
FT_TRACE4(( " vlineto" ));
- if ( start_point( builder, x, y ) )
+ if ( ( error = t1_builder_start_point( builder, x, y ) )
+ != FT_Err_Ok )
goto Fail;
y += top[0];
@@ -1319,7 +1345,7 @@
FT_TRACE4(( " callsubr" ));
- idx = (FT_Int)( top[0] >> 16 );
+ idx = Fix2Int( top[0] );
if ( idx < 0 || idx >= (FT_Int)decoder->num_subrs )
{
FT_ERROR(( "t1_decoder_parse_charstrings:"
@@ -1480,8 +1506,12 @@
goto Syntax_Error;
}
else
+ ...
#endif
- decoder->flex_state = 0;
+
+ x = top[0];
+ y = top[1];
+ decoder->flex_state = 0;
break;
case op_unknown15:
@@ -1517,10 +1547,10 @@
return error;
Syntax_Error:
- return PSaux_Err_Syntax_Error;
+ return FT_THROW( Syntax_Error );
Stack_Underflow:
- return PSaux_Err_Stack_Underflow;
+ return FT_THROW( Stack_Underflow );
}
@@ -1557,7 +1587,7 @@
{
FT_ERROR(( "t1_decoder_init:"
" the `psnames' module is not available\n" ));
- return PSaux_Err_Unimplemented_Feature;
+ return FT_THROW( Unimplemented_Feature );
}
decoder->psnames = psnames;
@@ -1577,7 +1607,7 @@
decoder->funcs = t1_decoder_funcs;
- return PSaux_Err_Ok;
+ return FT_Err_Ok;
}