summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/freetype/src/type1
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/freetype/src/type1')
-rw-r--r--src/3rdparty/freetype/src/type1/t1afm.c28
-rw-r--r--src/3rdparty/freetype/src/type1/t1driver.c468
-rw-r--r--src/3rdparty/freetype/src/type1/t1driver.h2
-rw-r--r--src/3rdparty/freetype/src/type1/t1errors.h3
-rw-r--r--src/3rdparty/freetype/src/type1/t1gload.c90
-rw-r--r--src/3rdparty/freetype/src/type1/t1gload.h10
-rw-r--r--src/3rdparty/freetype/src/type1/t1load.c272
-rw-r--r--src/3rdparty/freetype/src/type1/t1objs.c84
-rw-r--r--src/3rdparty/freetype/src/type1/t1objs.h31
-rw-r--r--src/3rdparty/freetype/src/type1/t1parse.c76
-rw-r--r--src/3rdparty/freetype/src/type1/t1tokens.h2
11 files changed, 772 insertions, 294 deletions
diff --git a/src/3rdparty/freetype/src/type1/t1afm.c b/src/3rdparty/freetype/src/type1/t1afm.c
index ef343901a4..de9c1997c4 100644
--- a/src/3rdparty/freetype/src/type1/t1afm.c
+++ b/src/3rdparty/freetype/src/type1/t1afm.c
@@ -4,7 +4,7 @@
/* */
/* AFM support for Type 1 fonts (body). */
/* */
-/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
+/* Copyright 1996-2011, 2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -18,9 +18,10 @@
#include <ft2build.h>
#include "t1afm.h"
-#include "t1errors.h"
+#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_STREAM_H
#include FT_INTERNAL_POSTSCRIPT_AUX_H
+#include "t1errors.h"
/*************************************************************************/
@@ -107,7 +108,7 @@
FT_Stream stream,
AFM_FontInfo fi )
{
- FT_Error error = T1_Err_Ok;
+ FT_Error error = FT_Err_Ok;
FT_Memory memory = stream->memory;
FT_Byte* start;
FT_Byte* limit;
@@ -121,14 +122,13 @@
start = (FT_Byte*)stream->cursor;
limit = (FT_Byte*)stream->limit;
- p = start;
/* Figure out how long the width table is. */
/* This info is a little-endian short at offset 99. */
p = start + 99;
if ( p + 2 > limit )
{
- error = T1_Err_Unknown_File_Format;
+ error = FT_THROW( Unknown_File_Format );
goto Exit;
}
width_table_length = FT_PEEK_USHORT_LE( p );
@@ -148,7 +148,7 @@
if ( p + 2 > limit )
{
- error = T1_Err_Unknown_File_Format;
+ error = FT_THROW( Unknown_File_Format );
goto Exit;
}
@@ -156,7 +156,7 @@
p += 2;
if ( p + 4 * fi->NumKernPair > limit )
{
- error = T1_Err_Unknown_File_Format;
+ error = FT_THROW( Unknown_File_Format );
goto Exit;
}
@@ -235,10 +235,10 @@
FT_Stream stream )
{
PSAux_Service psaux;
- FT_Memory memory = stream->memory;
+ FT_Memory memory = stream->memory;
AFM_ParserRec parser;
- AFM_FontInfo fi;
- FT_Error error = T1_Err_Unknown_File_Format;
+ AFM_FontInfo fi = NULL;
+ FT_Error error = FT_ERR( Unknown_File_Format );
T1_Font t1_font = &( (T1_Face)t1_face )->type1;
@@ -251,7 +251,7 @@
fi->Descender = t1_font->font_bbox.yMin;
psaux = (PSAux_Service)( (T1_Face)t1_face )->psaux;
- if ( psaux && psaux->afm_parser_funcs )
+ if ( psaux->afm_parser_funcs )
{
error = psaux->afm_parser_funcs->init( &parser,
stream->memory,
@@ -269,7 +269,7 @@
}
}
- if ( error == T1_Err_Unknown_File_Format )
+ if ( FT_ERR_EQ( error, Unknown_File_Format ) )
{
FT_Byte* start = stream->cursor;
@@ -366,7 +366,7 @@
if ( !fi )
- return T1_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
for ( i = 0; i < fi->NumTrackKern; i++ )
{
@@ -389,7 +389,7 @@
}
}
- return T1_Err_Ok;
+ return FT_Err_Ok;
}
diff --git a/src/3rdparty/freetype/src/type1/t1driver.c b/src/3rdparty/freetype/src/type1/t1driver.c
index 8c398eee22..2602bdb6ff 100644
--- a/src/3rdparty/freetype/src/type1/t1driver.c
+++ b/src/3rdparty/freetype/src/type1/t1driver.c
@@ -4,7 +4,7 @@
/* */
/* Type 1 driver interface (body). */
/* */
-/* Copyright 1996-2001, 2002, 2003, 2004, 2006, 2007, 2009 by */
+/* Copyright 1996-2004, 2006, 2007, 2009, 2011, 2013, 2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -61,7 +61,7 @@
{
FT_STRCPYN( buffer, face->type1.glyph_names[glyph_index], buffer_max );
- return T1_Err_Ok;
+ return FT_Err_Ok;
}
@@ -69,13 +69,13 @@
t1_get_name_index( T1_Face face,
FT_String* glyph_name )
{
- FT_Int i;
- FT_String* gname;
+ FT_Int i;
for ( i = 0; i < face->type1.num_glyphs; i++ )
{
- gname = face->type1.glyph_names[i];
+ FT_String* gname = face->type1.glyph_names[i];
+
if ( !ft_strcmp( glyph_name, gname ) )
return (FT_UInt)i;
@@ -138,7 +138,7 @@
{
*afont_info = ((T1_Face)face)->type1.font_info;
- return T1_Err_Ok;
+ return FT_Err_Ok;
}
@@ -148,7 +148,7 @@
{
*afont_extra = ((T1_Face)face)->type1.font_extra;
- return T1_Err_Ok;
+ return FT_Err_Ok;
}
@@ -167,7 +167,399 @@
{
*afont_private = ((T1_Face)face)->type1.private_dict;
- return T1_Err_Ok;
+ return FT_Err_Ok;
+ }
+
+
+ static FT_Long
+ t1_ps_get_font_value( FT_Face face,
+ PS_Dict_Keys key,
+ FT_UInt idx,
+ void *value,
+ FT_Long value_len )
+ {
+ FT_Long retval = -1;
+ T1_Face t1face = (T1_Face)face;
+ T1_Font type1 = &t1face->type1;
+
+
+ switch ( key )
+ {
+ case PS_DICT_FONT_TYPE:
+ retval = sizeof ( type1->font_type );
+ if ( value && value_len >= retval )
+ *((FT_Byte *)value) = type1->font_type;
+ break;
+
+ case PS_DICT_FONT_MATRIX:
+ if ( idx < sizeof ( type1->font_matrix ) /
+ sizeof ( type1->font_matrix.xx ) )
+ {
+ FT_Fixed val = 0;
+
+
+ retval = sizeof ( val );
+ if ( value && value_len >= retval )
+ {
+ switch ( idx )
+ {
+ case 0:
+ val = type1->font_matrix.xx;
+ break;
+ case 1:
+ val = type1->font_matrix.xy;
+ break;
+ case 2:
+ val = type1->font_matrix.yx;
+ break;
+ case 3:
+ val = type1->font_matrix.yy;
+ break;
+ }
+ *((FT_Fixed *)value) = val;
+ }
+ }
+ break;
+
+ case PS_DICT_FONT_BBOX:
+ if ( idx < sizeof ( type1->font_bbox ) /
+ sizeof ( type1->font_bbox.xMin ) )
+ {
+ FT_Fixed val = 0;
+
+
+ retval = sizeof ( val );
+ if ( value && value_len >= retval )
+ {
+ switch ( idx )
+ {
+ case 0:
+ val = type1->font_bbox.xMin;
+ break;
+ case 1:
+ val = type1->font_bbox.yMin;
+ break;
+ case 2:
+ val = type1->font_bbox.xMax;
+ break;
+ case 3:
+ val = type1->font_bbox.yMax;
+ break;
+ }
+ *((FT_Fixed *)value) = val;
+ }
+ }
+ break;
+
+ case PS_DICT_PAINT_TYPE:
+ retval = sizeof ( type1->paint_type );
+ if ( value && value_len >= retval )
+ *((FT_Byte *)value) = type1->paint_type;
+ break;
+
+ case PS_DICT_FONT_NAME:
+ retval = (FT_Long)( ft_strlen( type1->font_name ) + 1 );
+ if ( value && value_len >= retval )
+ ft_memcpy( value, (void *)( type1->font_name ), retval );
+ break;
+
+ case PS_DICT_UNIQUE_ID:
+ retval = sizeof ( type1->private_dict.unique_id );
+ if ( value && value_len >= retval )
+ *((FT_Int *)value) = type1->private_dict.unique_id;
+ break;
+
+ case PS_DICT_NUM_CHAR_STRINGS:
+ retval = sizeof ( type1->num_glyphs );
+ if ( value && value_len >= retval )
+ *((FT_Int *)value) = type1->num_glyphs;
+ break;
+
+ case PS_DICT_CHAR_STRING_KEY:
+ if ( idx < (FT_UInt)type1->num_glyphs )
+ {
+ retval = (FT_Long)( ft_strlen( type1->glyph_names[idx] ) + 1 );
+ if ( value && value_len >= retval )
+ {
+ ft_memcpy( value, (void *)( type1->glyph_names[idx] ), retval );
+ ((FT_Char *)value)[retval - 1] = (FT_Char)'\0';
+ }
+ }
+ break;
+
+ case PS_DICT_CHAR_STRING:
+ if ( idx < (FT_UInt)type1->num_glyphs )
+ {
+ retval = (FT_Long)( type1->charstrings_len[idx] + 1 );
+ if ( value && value_len >= retval )
+ {
+ ft_memcpy( value, (void *)( type1->charstrings[idx] ),
+ retval - 1 );
+ ((FT_Char *)value)[retval - 1] = (FT_Char)'\0';
+ }
+ }
+ break;
+
+ case PS_DICT_ENCODING_TYPE:
+ retval = sizeof ( type1->encoding_type );
+ if ( value && value_len >= retval )
+ *((T1_EncodingType *)value) = type1->encoding_type;
+ break;
+
+ case PS_DICT_ENCODING_ENTRY:
+ if ( type1->encoding_type == T1_ENCODING_TYPE_ARRAY &&
+ idx < (FT_UInt)type1->encoding.num_chars )
+ {
+ retval = (FT_Long)( ft_strlen( type1->encoding.char_name[idx] ) + 1 );
+ if ( value && value_len >= retval )
+ {
+ ft_memcpy( value, (void *)( type1->encoding.char_name[idx] ),
+ retval - 1 );
+ ((FT_Char *)value)[retval - 1] = (FT_Char)'\0';
+ }
+ }
+ break;
+
+ case PS_DICT_NUM_SUBRS:
+ retval = sizeof ( type1->num_subrs );
+ if ( value && value_len >= retval )
+ *((FT_Int *)value) = type1->num_subrs;
+ break;
+
+ case PS_DICT_SUBR:
+ if ( idx < (FT_UInt)type1->num_subrs )
+ {
+ retval = (FT_Long)( type1->subrs_len[idx] + 1 );
+ if ( value && value_len >= retval )
+ {
+ ft_memcpy( value, (void *)( type1->subrs[idx] ), retval - 1 );
+ ((FT_Char *)value)[retval - 1] = (FT_Char)'\0';
+ }
+ }
+ break;
+
+ case PS_DICT_STD_HW:
+ retval = sizeof ( type1->private_dict.standard_width[0] );
+ if ( value && value_len >= retval )
+ *((FT_UShort *)value) = type1->private_dict.standard_width[0];
+ break;
+
+ case PS_DICT_STD_VW:
+ retval = sizeof ( type1->private_dict.standard_height[0] );
+ if ( value && value_len >= retval )
+ *((FT_UShort *)value) = type1->private_dict.standard_height[0];
+ break;
+
+ case PS_DICT_NUM_BLUE_VALUES:
+ retval = sizeof ( type1->private_dict.num_blue_values );
+ if ( value && value_len >= retval )
+ *((FT_Byte *)value) = type1->private_dict.num_blue_values;
+ break;
+
+ case PS_DICT_BLUE_VALUE:
+ if ( idx < type1->private_dict.num_blue_values )
+ {
+ retval = sizeof ( type1->private_dict.blue_values[idx] );
+ if ( value && value_len >= retval )
+ *((FT_Short *)value) = type1->private_dict.blue_values[idx];
+ }
+ break;
+
+ case PS_DICT_BLUE_SCALE:
+ retval = sizeof ( type1->private_dict.blue_scale );
+ if ( value && value_len >= retval )
+ *((FT_Fixed *)value) = type1->private_dict.blue_scale;
+ break;
+
+ case PS_DICT_BLUE_FUZZ:
+ retval = sizeof ( type1->private_dict.blue_fuzz );
+ if ( value && value_len >= retval )
+ *((FT_Int *)value) = type1->private_dict.blue_fuzz;
+ break;
+
+ case PS_DICT_BLUE_SHIFT:
+ retval = sizeof ( type1->private_dict.blue_shift );
+ if ( value && value_len >= retval )
+ *((FT_Int *)value) = type1->private_dict.blue_shift;
+ break;
+
+ case PS_DICT_NUM_OTHER_BLUES:
+ retval = sizeof ( type1->private_dict.num_other_blues );
+ if ( value && value_len >= retval )
+ *((FT_Byte *)value) = type1->private_dict.num_other_blues;
+ break;
+
+ case PS_DICT_OTHER_BLUE:
+ if ( idx < type1->private_dict.num_other_blues )
+ {
+ retval = sizeof ( type1->private_dict.other_blues[idx] );
+ if ( value && value_len >= retval )
+ *((FT_Short *)value) = type1->private_dict.other_blues[idx];
+ }
+ break;
+
+ case PS_DICT_NUM_FAMILY_BLUES:
+ retval = sizeof ( type1->private_dict.num_family_blues );
+ if ( value && value_len >= retval )
+ *((FT_Byte *)value) = type1->private_dict.num_family_blues;
+ break;
+
+ case PS_DICT_FAMILY_BLUE:
+ if ( idx < type1->private_dict.num_family_blues )
+ {
+ retval = sizeof ( type1->private_dict.family_blues[idx] );
+ if ( value && value_len >= retval )
+ *((FT_Short *)value) = type1->private_dict.family_blues[idx];
+ }
+ break;
+
+ case PS_DICT_NUM_FAMILY_OTHER_BLUES:
+ retval = sizeof ( type1->private_dict.num_family_other_blues );
+ if ( value && value_len >= retval )
+ *((FT_Byte *)value) = type1->private_dict.num_family_other_blues;
+ break;
+
+ case PS_DICT_FAMILY_OTHER_BLUE:
+ if ( idx < type1->private_dict.num_family_other_blues )
+ {
+ retval = sizeof ( type1->private_dict.family_other_blues[idx] );
+ if ( value && value_len >= retval )
+ *((FT_Short *)value) = type1->private_dict.family_other_blues[idx];
+ }
+ break;
+
+ case PS_DICT_NUM_STEM_SNAP_H:
+ retval = sizeof ( type1->private_dict.num_snap_widths );
+ if ( value && value_len >= retval )
+ *((FT_Byte *)value) = type1->private_dict.num_snap_widths;
+ break;
+
+ case PS_DICT_STEM_SNAP_H:
+ if ( idx < type1->private_dict.num_snap_widths )
+ {
+ retval = sizeof ( type1->private_dict.snap_widths[idx] );
+ if ( value && value_len >= retval )
+ *((FT_Short *)value) = type1->private_dict.snap_widths[idx];
+ }
+ break;
+
+ case PS_DICT_NUM_STEM_SNAP_V:
+ retval = sizeof ( type1->private_dict.num_snap_heights );
+ if ( value && value_len >= retval )
+ *((FT_Byte *)value) = type1->private_dict.num_snap_heights;
+ break;
+
+ case PS_DICT_STEM_SNAP_V:
+ if ( idx < type1->private_dict.num_snap_heights )
+ {
+ retval = sizeof ( type1->private_dict.snap_heights[idx] );
+ if ( value && value_len >= retval )
+ *((FT_Short *)value) = type1->private_dict.snap_heights[idx];
+ }
+ break;
+
+ case PS_DICT_RND_STEM_UP:
+ retval = sizeof ( type1->private_dict.round_stem_up );
+ if ( value && value_len >= retval )
+ *((FT_Bool *)value) = type1->private_dict.round_stem_up;
+ break;
+
+ case PS_DICT_FORCE_BOLD:
+ retval = sizeof ( type1->private_dict.force_bold );
+ if ( value && value_len >= retval )
+ *((FT_Bool *)value) = type1->private_dict.force_bold;
+ break;
+
+ case PS_DICT_MIN_FEATURE:
+ if ( idx < sizeof ( type1->private_dict.min_feature ) /
+ sizeof ( type1->private_dict.min_feature[0] ) )
+ {
+ retval = sizeof ( type1->private_dict.min_feature[idx] );
+ if ( value && value_len >= retval )
+ *((FT_Short *)value) = type1->private_dict.min_feature[idx];
+ }
+ break;
+
+ case PS_DICT_LEN_IV:
+ retval = sizeof ( type1->private_dict.lenIV );
+ if ( value && value_len >= retval )
+ *((FT_Int *)value) = type1->private_dict.lenIV;
+ break;
+
+ case PS_DICT_PASSWORD:
+ retval = sizeof ( type1->private_dict.password );
+ if ( value && value_len >= retval )
+ *((FT_Long *)value) = type1->private_dict.password;
+ break;
+
+ case PS_DICT_LANGUAGE_GROUP:
+ retval = sizeof ( type1->private_dict.language_group );
+ if ( value && value_len >= retval )
+ *((FT_Long *)value) = type1->private_dict.language_group;
+ break;
+
+ case PS_DICT_IS_FIXED_PITCH:
+ retval = sizeof ( type1->font_info.is_fixed_pitch );
+ if ( value && value_len >= retval )
+ *((FT_Bool *)value) = type1->font_info.is_fixed_pitch;
+ break;
+
+ case PS_DICT_UNDERLINE_POSITION:
+ retval = sizeof ( type1->font_info.underline_position );
+ if ( value && value_len >= retval )
+ *((FT_Short *)value) = type1->font_info.underline_position;
+ break;
+
+ case PS_DICT_UNDERLINE_THICKNESS:
+ retval = sizeof ( type1->font_info.underline_thickness );
+ if ( value && value_len >= retval )
+ *((FT_UShort *)value) = type1->font_info.underline_thickness;
+ break;
+
+ case PS_DICT_FS_TYPE:
+ retval = sizeof ( type1->font_extra.fs_type );
+ if ( value && value_len >= retval )
+ *((FT_UShort *)value) = type1->font_extra.fs_type;
+ break;
+
+ case PS_DICT_VERSION:
+ retval = (FT_Long)( ft_strlen( type1->font_info.version ) + 1 );
+ if ( value && value_len >= retval )
+ ft_memcpy( value, (void *)( type1->font_info.version ), retval );
+ break;
+
+ case PS_DICT_NOTICE:
+ retval = (FT_Long)( ft_strlen( type1->font_info.notice ) + 1 );
+ if ( value && value_len >= retval )
+ ft_memcpy( value, (void *)( type1->font_info.notice ), retval );
+ break;
+
+ case PS_DICT_FULL_NAME:
+ retval = (FT_Long)( ft_strlen( type1->font_info.full_name ) + 1 );
+ if ( value && value_len >= retval )
+ ft_memcpy( value, (void *)( type1->font_info.full_name ), retval );
+ break;
+
+ case PS_DICT_FAMILY_NAME:
+ retval = (FT_Long)( ft_strlen( type1->font_info.family_name ) + 1 );
+ if ( value && value_len >= retval )
+ ft_memcpy( value, (void *)( type1->font_info.family_name ), retval );
+ break;
+
+ case PS_DICT_WEIGHT:
+ retval = (FT_Long)( ft_strlen( type1->font_info.weight ) + 1 );
+ if ( value && value_len >= retval )
+ ft_memcpy( value, (void *)( type1->font_info.weight ), retval );
+ break;
+
+ case PS_DICT_ITALIC_ANGLE:
+ retval = sizeof ( type1->font_info.italic_angle );
+ if ( value && value_len >= retval )
+ *((FT_Long *)value) = type1->font_info.italic_angle;
+ break;
+ }
+
+ return retval;
}
@@ -177,6 +569,7 @@
(PS_GetFontExtraFunc) t1_ps_get_font_extra,
(PS_HasGlyphNamesFunc) t1_ps_has_glyph_names,
(PS_GetFontPrivateFunc)t1_ps_get_font_private,
+ (PS_GetFontValueFunc) t1_ps_get_font_value,
};
@@ -211,11 +604,11 @@
};
- static FT_Module_Interface
- Get_Interface( FT_Driver driver,
+ FT_CALLBACK_DEF( FT_Module_Interface )
+ Get_Interface( FT_Module module,
const FT_String* t1_interface )
{
- FT_UNUSED( driver );
+ FT_UNUSED( module );
return ft_service_list_lookup( t1_services, t1_interface );
}
@@ -256,11 +649,14 @@
/* They can be implemented by format-specific interfaces. */
/* */
static FT_Error
- Get_Kerning( T1_Face face,
+ Get_Kerning( FT_Face t1face, /* T1_Face */
FT_UInt left_glyph,
FT_UInt right_glyph,
FT_Vector* kerning )
{
+ T1_Face face = (T1_Face)t1face;
+
+
kerning->x = 0;
kerning->y = 0;
@@ -270,7 +666,7 @@
right_glyph,
kerning );
- return T1_Err_Ok;
+ return FT_Err_Ok;
}
@@ -285,7 +681,7 @@
FT_MODULE_DRIVER_SCALABLE |
FT_MODULE_DRIVER_HAS_HINTER,
- sizeof( FT_DriverRec ),
+ sizeof ( FT_DriverRec ),
"type1",
0x10000L,
@@ -293,38 +689,34 @@
0, /* format interface */
- (FT_Module_Constructor)T1_Driver_Init,
- (FT_Module_Destructor) T1_Driver_Done,
- (FT_Module_Requester) Get_Interface,
+ T1_Driver_Init,
+ T1_Driver_Done,
+ Get_Interface,
},
- sizeof( T1_FaceRec ),
- sizeof( T1_SizeRec ),
- sizeof( T1_GlyphSlotRec ),
+ sizeof ( T1_FaceRec ),
+ sizeof ( T1_SizeRec ),
+ sizeof ( T1_GlyphSlotRec ),
- (FT_Face_InitFunc) T1_Face_Init,
- (FT_Face_DoneFunc) T1_Face_Done,
- (FT_Size_InitFunc) T1_Size_Init,
- (FT_Size_DoneFunc) T1_Size_Done,
- (FT_Slot_InitFunc) T1_GlyphSlot_Init,
- (FT_Slot_DoneFunc) T1_GlyphSlot_Done,
+ T1_Face_Init,
+ T1_Face_Done,
+ T1_Size_Init,
+ T1_Size_Done,
+ T1_GlyphSlot_Init,
+ T1_GlyphSlot_Done,
-#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
- ft_stub_set_char_sizes,
- ft_stub_set_pixel_sizes,
-#endif
- (FT_Slot_LoadFunc) T1_Load_Glyph,
+ T1_Load_Glyph,
#ifdef T1_CONFIG_OPTION_NO_AFM
- (FT_Face_GetKerningFunc) 0,
- (FT_Face_AttachFunc) 0,
+ 0, /* FT_Face_GetKerningFunc */
+ 0, /* FT_Face_AttachFunc */
#else
- (FT_Face_GetKerningFunc) Get_Kerning,
- (FT_Face_AttachFunc) T1_Read_Metrics,
+ Get_Kerning,
+ T1_Read_Metrics,
#endif
- (FT_Face_GetAdvancesFunc) T1_Get_Advances,
- (FT_Size_RequestFunc) T1_Size_Request,
- (FT_Size_SelectFunc) 0
+ T1_Get_Advances,
+ T1_Size_Request,
+ 0 /* FT_Size_SelectFunc */
};
diff --git a/src/3rdparty/freetype/src/type1/t1driver.h b/src/3rdparty/freetype/src/type1/t1driver.h
index 9fecbeb0f8..639cd4a7ad 100644
--- a/src/3rdparty/freetype/src/type1/t1driver.h
+++ b/src/3rdparty/freetype/src/type1/t1driver.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_Driver_ClassRec ) t1_driver_class;
diff --git a/src/3rdparty/freetype/src/type1/t1errors.h b/src/3rdparty/freetype/src/type1/t1errors.h
index 81221c343d..8740530eef 100644
--- a/src/3rdparty/freetype/src/type1/t1errors.h
+++ b/src/3rdparty/freetype/src/type1/t1errors.h
@@ -4,7 +4,7 @@
/* */
/* Type 1 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, */
@@ -29,6 +29,7 @@
#undef __FTERRORS_H__
+#undef FT_ERR_PREFIX
#define FT_ERR_PREFIX T1_Err_
#define FT_ERR_BASE FT_Mod_Err_Type1
diff --git a/src/3rdparty/freetype/src/type1/t1gload.c b/src/3rdparty/freetype/src/type1/t1gload.c
index f3fad4f5df..af102fd85e 100644
--- a/src/3rdparty/freetype/src/type1/t1gload.c
+++ b/src/3rdparty/freetype/src/type1/t1gload.c
@@ -4,7 +4,7 @@
/* */
/* Type 1 Glyph Loader (body). */
/* */
-/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009, 2010 by */
+/* Copyright 1996-2006, 2008-2010, 2013, 2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -61,7 +61,7 @@
{
T1_Face face = (T1_Face)decoder->builder.face;
T1_Font type1 = &face->type1;
- FT_Error error = T1_Err_Ok;
+ FT_Error error = FT_Err_Ok;
#ifdef FT_CONFIG_OPTION_INCREMENTAL
FT_Incremental_InterfaceRec *inc =
@@ -194,7 +194,7 @@
for ( glyph_index = 0; glyph_index < type1->num_glyphs; glyph_index++ )
{
/* now get load the unscaled outline */
- error = T1_Parse_Glyph( &decoder, glyph_index );
+ (void)T1_Parse_Glyph( &decoder, glyph_index );
if ( glyph_index == 0 || decoder.builder.advance.x > *max_advance )
*max_advance = decoder.builder.advance.x;
@@ -203,17 +203,18 @@
psaux->t1_decoder_funcs->done( &decoder );
- return T1_Err_Ok;
+ return FT_Err_Ok;
}
FT_LOCAL_DEF( FT_Error )
- T1_Get_Advances( T1_Face face,
+ T1_Get_Advances( FT_Face t1face, /* T1_Face */
FT_UInt first,
FT_UInt count,
- FT_ULong load_flags,
+ FT_Int32 load_flags,
FT_Fixed* advances )
{
+ T1_Face face = (T1_Face)t1face;
T1_DecoderRec decoder;
T1_Font type1 = &face->type1;
PSAux_Service psaux = (PSAux_Service)face->psaux;
@@ -226,7 +227,7 @@
for ( nn = 0; nn < count; nn++ )
advances[nn] = 0;
- return T1_Err_Ok;
+ return FT_Err_Ok;
}
error = psaux->t1_decoder_funcs->init( &decoder,
@@ -260,19 +261,20 @@
advances[nn] = 0;
}
- return T1_Err_Ok;
+ return FT_Err_Ok;
}
FT_LOCAL_DEF( FT_Error )
- T1_Load_Glyph( T1_GlyphSlot glyph,
- T1_Size size,
+ T1_Load_Glyph( FT_GlyphSlot t1glyph, /* T1_GlyphSlot */
+ FT_Size t1size, /* T1_Size */
FT_UInt glyph_index,
FT_Int32 load_flags )
{
+ T1_GlyphSlot glyph = (T1_GlyphSlot)t1glyph;
FT_Error error;
T1_DecoderRec decoder;
- T1_Face face = (T1_Face)glyph->root.face;
+ T1_Face face = (T1_Face)t1glyph->face;
FT_Bool hinting;
T1_Font type1 = &face->type1;
PSAux_Service psaux = (PSAux_Service)face->psaux;
@@ -294,19 +296,21 @@
if ( glyph_index >= (FT_UInt)face->root.num_glyphs )
#endif /* FT_CONFIG_OPTION_INCREMENTAL */
{
- error = T1_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
goto Exit;
}
+ FT_TRACE1(( "T1_Load_Glyph: glyph index %d\n", glyph_index ));
+
FT_ASSERT( ( face->len_buildchar == 0 ) == ( face->buildchar == NULL ) );
if ( load_flags & FT_LOAD_NO_RECURSE )
load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING;
- if ( size )
+ if ( t1size )
{
- glyph->x_scale = size->root.metrics.x_scale;
- glyph->y_scale = size->root.metrics.y_scale;
+ glyph->x_scale = t1size->metrics.x_scale;
+ glyph->y_scale = t1size->metrics.y_scale;
}
else
{
@@ -314,18 +318,18 @@
glyph->y_scale = 0x10000L;
}
- glyph->root.outline.n_points = 0;
- glyph->root.outline.n_contours = 0;
+ t1glyph->outline.n_points = 0;
+ t1glyph->outline.n_contours = 0;
hinting = FT_BOOL( ( load_flags & FT_LOAD_NO_SCALE ) == 0 &&
( load_flags & FT_LOAD_NO_HINTING ) == 0 );
- glyph->root.format = FT_GLYPH_FORMAT_OUTLINE;
+ t1glyph->format = FT_GLYPH_FORMAT_OUTLINE;
error = decoder_funcs->init( &decoder,
- (FT_Face)face,
- (FT_Size)size,
- (FT_GlyphSlot)glyph,
+ t1glyph->face,
+ t1size,
+ t1glyph,
(FT_Byte**)type1->glyph_names,
face->blend,
FT_BOOL( hinting ),
@@ -368,19 +372,19 @@
/* bearing the yMax */
if ( !error )
{
- glyph->root.outline.flags &= FT_OUTLINE_OWNER;
- glyph->root.outline.flags |= FT_OUTLINE_REVERSE_FILL;
+ t1glyph->outline.flags &= FT_OUTLINE_OWNER;
+ t1glyph->outline.flags |= FT_OUTLINE_REVERSE_FILL;
/* for composite glyphs, return only left side bearing and */
/* advance width */
if ( load_flags & FT_LOAD_NO_RECURSE )
{
- FT_Slot_Internal internal = glyph->root.internal;
+ FT_Slot_Internal internal = t1glyph->internal;
- glyph->root.metrics.horiBearingX =
+ t1glyph->metrics.horiBearingX =
FIXED_TO_INT( decoder.builder.left_bearing.x );
- glyph->root.metrics.horiAdvance =
+ t1glyph->metrics.horiAdvance =
FIXED_TO_INT( decoder.builder.advance.x );
internal->glyph_matrix = font_matrix;
@@ -390,45 +394,45 @@
else
{
FT_BBox cbox;
- FT_Glyph_Metrics* metrics = &glyph->root.metrics;
+ FT_Glyph_Metrics* metrics = &t1glyph->metrics;
FT_Vector advance;
/* copy the _unscaled_ advance width */
metrics->horiAdvance =
FIXED_TO_INT( decoder.builder.advance.x );
- glyph->root.linearHoriAdvance =
+ t1glyph->linearHoriAdvance =
FIXED_TO_INT( decoder.builder.advance.x );
- glyph->root.internal->glyph_transformed = 0;
+ t1glyph->internal->glyph_transformed = 0;
- if ( load_flags & FT_LOAD_VERTICAL_LAYOUT )
+ if ( load_flags & FT_LOAD_VERTICAL_LAYOUT )
{
/* make up vertical ones */
metrics->vertAdvance = ( face->type1.font_bbox.yMax -
face->type1.font_bbox.yMin ) >> 16;
- glyph->root.linearVertAdvance = metrics->vertAdvance;
+ t1glyph->linearVertAdvance = metrics->vertAdvance;
}
else
{
metrics->vertAdvance =
FIXED_TO_INT( decoder.builder.advance.y );
- glyph->root.linearVertAdvance =
+ t1glyph->linearVertAdvance =
FIXED_TO_INT( decoder.builder.advance.y );
}
- glyph->root.format = FT_GLYPH_FORMAT_OUTLINE;
+ t1glyph->format = FT_GLYPH_FORMAT_OUTLINE;
- if ( size && size->root.metrics.y_ppem < 24 )
- glyph->root.outline.flags |= FT_OUTLINE_HIGH_PRECISION;
+ if ( t1size && t1size->metrics.y_ppem < 24 )
+ t1glyph->outline.flags |= FT_OUTLINE_HIGH_PRECISION;
#if 1
/* apply the font matrix, if any */
if ( font_matrix.xx != 0x10000L || font_matrix.yy != font_matrix.xx ||
font_matrix.xy != 0 || font_matrix.yx != 0 )
- FT_Outline_Transform( &glyph->root.outline, &font_matrix );
+ FT_Outline_Transform( &t1glyph->outline, &font_matrix );
if ( font_offset.x || font_offset.y )
- FT_Outline_Translate( &glyph->root.outline,
+ FT_Outline_Translate( &t1glyph->outline,
font_offset.x,
font_offset.y );
@@ -466,7 +470,7 @@
}
/* compute the other metrics */
- FT_Outline_Get_CBox( &glyph->root.outline, &cbox );
+ FT_Outline_Get_CBox( &t1glyph->outline, &cbox );
metrics->width = cbox.xMax - cbox.xMin;
metrics->height = cbox.yMax - cbox.yMin;
@@ -474,7 +478,7 @@
metrics->horiBearingX = cbox.xMin;
metrics->horiBearingY = cbox.yMax;
- if ( load_flags & FT_LOAD_VERTICAL_LAYOUT )
+ if ( load_flags & FT_LOAD_VERTICAL_LAYOUT )
{
/* make up vertical ones */
ft_synthesize_vertical_metrics( metrics,
@@ -484,8 +488,8 @@
/* Set control data to the glyph charstrings. Note that this is */
/* _not_ zero-terminated. */
- glyph->root.control_data = (FT_Byte*)glyph_data.pointer;
- glyph->root.control_len = glyph_data.length;
+ t1glyph->control_data = (FT_Byte*)glyph_data.pointer;
+ t1glyph->control_len = glyph_data.length;
}
@@ -500,8 +504,8 @@
/* Set the control data to null - it is no longer available if */
/* loaded incrementally. */
- glyph->root.control_data = 0;
- glyph->root.control_len = 0;
+ t1glyph->control_data = 0;
+ t1glyph->control_len = 0;
}
#endif
diff --git a/src/3rdparty/freetype/src/type1/t1gload.h b/src/3rdparty/freetype/src/type1/t1gload.h
index 100df06e8e..0bdea3a8d5 100644
--- a/src/3rdparty/freetype/src/type1/t1gload.h
+++ b/src/3rdparty/freetype/src/type1/t1gload.h
@@ -4,7 +4,7 @@
/* */
/* Type 1 Glyph Loader (specification). */
/* */
-/* Copyright 1996-2001, 2002, 2003, 2008 by */
+/* Copyright 1996-2001, 2002, 2003, 2008, 2011 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -32,15 +32,15 @@ FT_BEGIN_HEADER
FT_Pos* max_advance );
FT_LOCAL( FT_Error )
- T1_Get_Advances( T1_Face face,
+ T1_Get_Advances( FT_Face face,
FT_UInt first,
FT_UInt count,
- FT_ULong load_flags,
+ FT_Int32 load_flags,
FT_Fixed* advances );
FT_LOCAL( FT_Error )
- T1_Load_Glyph( T1_GlyphSlot glyph,
- T1_Size size,
+ T1_Load_Glyph( FT_GlyphSlot glyph,
+ FT_Size size,
FT_UInt glyph_index,
FT_Int32 load_flags );
diff --git a/src/3rdparty/freetype/src/type1/t1load.c b/src/3rdparty/freetype/src/type1/t1load.c
index d867e942c9..22b3f6b31d 100644
--- a/src/3rdparty/freetype/src/type1/t1load.c
+++ b/src/3rdparty/freetype/src/type1/t1load.c
@@ -4,7 +4,7 @@
/* */
/* Type 1 font loader (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, */
@@ -71,6 +71,13 @@
#include "t1errors.h"
+#ifdef FT_CONFIG_OPTION_INCREMENTAL
+#define IS_INCREMENTAL (FT_Bool)( face->root.internal->incremental_interface != 0 )
+#else
+#define IS_INCREMENTAL 0
+#endif
+
+
/*************************************************************************/
/* */
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
@@ -99,7 +106,7 @@
{
PS_Blend blend;
FT_Memory memory = face->root.memory;
- FT_Error error = T1_Err_Ok;
+ FT_Error error = FT_Err_Ok;
blend = face->blend;
@@ -123,8 +130,8 @@
/* allocate the blend `private' and `font_info' dictionaries */
if ( FT_NEW_ARRAY( blend->font_infos[1], num_designs ) ||
- FT_NEW_ARRAY( blend->privates[1], num_designs ) ||
- FT_NEW_ARRAY( blend->bboxes[1], num_designs ) ||
+ FT_NEW_ARRAY( blend->privates [1], num_designs ) ||
+ FT_NEW_ARRAY( blend->bboxes [1], num_designs ) ||
FT_NEW_ARRAY( blend->weight_vector, num_designs * 2 ) )
goto Exit;
@@ -136,12 +143,12 @@
for ( nn = 2; nn <= num_designs; nn++ )
{
- blend->privates[nn] = blend->privates [nn - 1] + 1;
blend->font_infos[nn] = blend->font_infos[nn - 1] + 1;
- blend->bboxes[nn] = blend->bboxes [nn - 1] + 1;
+ blend->privates [nn] = blend->privates [nn - 1] + 1;
+ blend->bboxes [nn] = blend->bboxes [nn - 1] + 1;
}
- blend->num_designs = num_designs;
+ blend->num_designs = num_designs;
}
else if ( blend->num_designs != num_designs )
goto Fail;
@@ -175,7 +182,7 @@
return error;
Fail:
- error = T1_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Exit;
}
@@ -189,7 +196,7 @@
FT_Error error;
- error = T1_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
if ( blend )
{
@@ -207,7 +214,7 @@
axis->maximum = map->design_points[map->num_points - 1];
}
- error = T1_Err_Ok;
+ error = FT_Err_Ok;
}
return error;
@@ -232,18 +239,11 @@
for ( j = 1; j < axismap->num_points; ++j )
{
if ( ncv <= axismap->blend_points[j] )
- {
- FT_Fixed t = FT_MulDiv( ncv - axismap->blend_points[j - 1],
- 0x10000L,
- axismap->blend_points[j] -
- axismap->blend_points[j - 1] );
-
return INT_TO_FIXED( axismap->design_points[j - 1] ) +
- FT_MulDiv( t,
- axismap->design_points[j] -
- axismap->design_points[j - 1],
- 1L );
- }
+ ( axismap->design_points[j] - axismap->design_points[j - 1] ) *
+ FT_DivFix( ncv - axismap->blend_points[j - 1],
+ axismap->blend_points[j] -
+ axismap->blend_points[j - 1] );
}
return INT_TO_FIXED( axismap->design_points[axismap->num_points - 1] );
@@ -302,7 +302,7 @@
FT_MM_Var* *master )
{
FT_Memory memory = face->root.memory;
- FT_MM_Var *mmvar;
+ FT_MM_Var *mmvar = NULL;
FT_Multi_Master mmaster;
FT_Error error;
FT_UInt i;
@@ -320,7 +320,7 @@
mmvar->num_axis = mmaster.num_axis;
mmvar->num_designs = mmaster.num_designs;
- mmvar->num_namedstyles = (FT_UInt)-1; /* Does not apply */
+ mmvar->num_namedstyles = ~0U; /* Does not apply */
mmvar->axis = (FT_Var_Axis*)&mmvar[1];
/* Point to axes after MM_Var struct */
mmvar->namedstyle = NULL;
@@ -333,8 +333,8 @@
mmvar->axis[i].def = ( mmvar->axis[i].minimum +
mmvar->axis[i].maximum ) / 2;
/* Does not apply. But this value is in range */
- mmvar->axis[i].strid = (FT_UInt)-1; /* Does not apply */
- mmvar->axis[i].tag = (FT_ULong)-1; /* Does not apply */
+ mmvar->axis[i].strid = ~0U; /* Does not apply */
+ mmvar->axis[i].tag = ~0U; /* Does not apply */
if ( ft_strcmp( mmvar->axis[i].name, "Weight" ) == 0 )
mmvar->axis[i].tag = FT_MAKE_TAG( 'w', 'g', 'h', 't' );
@@ -372,13 +372,11 @@
FT_UInt n, m;
- error = T1_Err_Invalid_Argument;
+ error = FT_ERR( Invalid_Argument );
if ( blend && blend->num_axis == num_coords )
{
/* recompute the weight vector from the blend coordinates */
- error = T1_Err_Ok;
-
for ( n = 0; n < blend->num_designs; n++ )
{
FT_Fixed result = 0x10000L; /* 1.0 fixed */
@@ -391,8 +389,10 @@
/* get current blend axis position */
factor = coords[m];
- if ( factor < 0 ) factor = 0;
- if ( factor > 0x10000L ) factor = 0x10000L;
+ if ( factor < 0 )
+ factor = 0;
+ if ( factor > 0x10000L )
+ factor = 0x10000L;
if ( ( n & ( 1 << m ) ) == 0 )
factor = 0x10000L - factor;
@@ -402,7 +402,7 @@
blend->weight_vector[n] = result;
}
- error = T1_Err_Ok;
+ error = FT_Err_Ok;
}
return error;
@@ -419,7 +419,7 @@
FT_UInt n, p;
- error = T1_Err_Invalid_Argument;
+ error = FT_ERR( Invalid_Argument );
if ( blend && blend->num_axis == num_coords )
{
/* compute the blend coordinates through the blend design map */
@@ -495,7 +495,7 @@
FT_Error error;
- error = T1_Err_Invalid_Argument;
+ error = FT_ERR( Invalid_Argument );
if ( num_coords <= 4 && num_coords > 0 )
{
for ( i = 0; i < num_coords; ++i )
@@ -524,7 +524,7 @@
/* release design pos table */
FT_FREE( blend->design_pos[0] );
for ( n = 1; n < num_designs; n++ )
- blend->design_pos[n] = 0;
+ blend->design_pos[n] = NULL;
/* release blend `private' and `font info' dictionaries */
FT_FREE( blend->privates[1] );
@@ -533,14 +533,14 @@
for ( n = 0; n < num_designs; n++ )
{
- blend->privates [n] = 0;
- blend->font_infos[n] = 0;
- blend->bboxes [n] = 0;
+ blend->privates [n] = NULL;
+ blend->font_infos[n] = NULL;
+ blend->bboxes [n] = NULL;
}
/* release weight vectors */
FT_FREE( blend->weight_vector );
- blend->default_weight_vector = 0;
+ blend->default_weight_vector = NULL;
/* release axis names */
for ( n = 0; n < num_axis; n++ )
@@ -567,7 +567,7 @@
{
T1_TokenRec axis_tokens[T1_MAX_MM_AXIS];
FT_Int n, num_axis;
- FT_Error error = T1_Err_Ok;
+ FT_Error error = FT_Err_Ok;
PS_Blend blend;
FT_Memory memory;
@@ -577,14 +577,14 @@
T1_MAX_MM_AXIS, &num_axis );
if ( num_axis < 0 )
{
- error = T1_Err_Ignore;
+ error = FT_ERR( Ignore );
goto Exit;
}
if ( num_axis == 0 || num_axis > T1_MAX_MM_AXIS )
{
FT_ERROR(( "parse_blend_axis_types: incorrect number of axes: %d\n",
num_axis ));
- error = T1_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Exit;
}
@@ -611,16 +611,16 @@
len = token->limit - token->start;
if ( len == 0 )
{
- error = T1_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Exit;
}
- if ( FT_ALLOC( blend->axis_names[n], len + 1 ) )
+ if ( FT_ALLOC( blend->axis_names[n], (FT_Long)( len + 1 ) ) )
goto Exit;
name = (FT_Byte*)blend->axis_names[n];
FT_MEM_COPY( name, token->start, len );
- name[len] = 0;
+ name[len] = '\0';
}
Exit:
@@ -637,7 +637,7 @@
FT_Int num_axis;
T1_Parser parser = &loader->parser;
- FT_Error error = T1_Err_Ok;
+ FT_Error error = FT_Err_Ok;
PS_Blend blend;
@@ -646,7 +646,7 @@
T1_MAX_MM_DESIGNS, &num_designs );
if ( num_designs < 0 )
{
- error = T1_Err_Ignore;
+ error = FT_ERR( Ignore );
goto Exit;
}
if ( num_designs == 0 || num_designs > T1_MAX_MM_DESIGNS )
@@ -654,7 +654,7 @@
FT_ERROR(( "parse_blend_design_positions:"
" incorrect number of designs: %d\n",
num_designs ));
- error = T1_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Exit;
}
@@ -687,7 +687,7 @@
FT_ERROR(( "parse_blend_design_positions:"
" invalid number of axes: %d\n",
n_axis ));
- error = T1_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Exit;
}
@@ -700,7 +700,7 @@
else if ( n_axis != num_axis )
{
FT_ERROR(( "parse_blend_design_positions: incorrect table\n" ));
- error = T1_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Exit;
}
@@ -729,7 +729,7 @@
parse_blend_design_map( T1_Face face,
T1_Loader loader )
{
- FT_Error error = T1_Err_Ok;
+ FT_Error error = FT_Err_Ok;
T1_Parser parser = &loader->parser;
PS_Blend blend;
T1_TokenRec axis_tokens[T1_MAX_MM_AXIS];
@@ -743,14 +743,14 @@
T1_MAX_MM_AXIS, &num_axis );
if ( num_axis < 0 )
{
- error = T1_Err_Ignore;
+ error = FT_ERR( Ignore );
goto Exit;
}
if ( num_axis == 0 || num_axis > T1_MAX_MM_AXIS )
{
FT_ERROR(( "parse_blend_design_map: incorrect number of axes: %d\n",
num_axis ));
- error = T1_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Exit;
}
@@ -781,7 +781,7 @@
if ( num_points <= 0 || num_points > T1_MAX_MM_MAP_POINTS )
{
FT_ERROR(( "parse_blend_design_map: incorrect table\n" ));
- error = T1_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Exit;
}
@@ -821,7 +821,7 @@
{
T1_TokenRec design_tokens[T1_MAX_MM_DESIGNS];
FT_Int num_designs;
- FT_Error error = T1_Err_Ok;
+ FT_Error error = FT_Err_Ok;
T1_Parser parser = &loader->parser;
PS_Blend blend = face->blend;
T1_Token token;
@@ -834,7 +834,7 @@
T1_MAX_MM_DESIGNS, &num_designs );
if ( num_designs < 0 )
{
- error = T1_Err_Ignore;
+ error = FT_ERR( Ignore );
goto Exit;
}
if ( num_designs == 0 || num_designs > T1_MAX_MM_DESIGNS )
@@ -842,7 +842,7 @@
FT_ERROR(( "parse_weight_vector:"
" incorrect number of designs: %d\n",
num_designs ));
- error = T1_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Exit;
}
@@ -859,7 +859,7 @@
" /BlendDesignPosition and /WeightVector have\n"
" "
" different number of elements\n" ));
- error = T1_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Exit;
}
@@ -896,7 +896,7 @@
}
-#endif /* T1_CONFIG_OPTION_NO_MM_SUPPORT */
+#endif /* !T1_CONFIG_OPTION_NO_MM_SUPPORT */
@@ -921,6 +921,9 @@
PS_Blend blend = face->blend;
+ if ( blend && blend->num_designs == 0 )
+ blend = NULL;
+
/* if the keyword has a dedicated callback, call it */
if ( field->type == T1_FIELD_TYPE_CALLBACK )
{
@@ -1001,13 +1004,24 @@
max_objects = 0;
}
- if ( field->type == T1_FIELD_TYPE_INTEGER_ARRAY ||
- field->type == T1_FIELD_TYPE_FIXED_ARRAY )
- error = T1_Load_Field_Table( &loader->parser, field,
- objects, max_objects, 0 );
+ if ( *objects )
+ {
+ if ( field->type == T1_FIELD_TYPE_INTEGER_ARRAY ||
+ field->type == T1_FIELD_TYPE_FIXED_ARRAY )
+ error = T1_Load_Field_Table( &loader->parser, field,
+ objects, max_objects, 0 );
+ else
+ error = T1_Load_Field( &loader->parser, field,
+ objects, max_objects, 0 );
+ }
else
- error = T1_Load_Field( &loader->parser, field,
- objects, max_objects, 0 );
+ {
+ FT_TRACE1(( "t1_load_keyword: ignoring keyword `%s'"
+ " which is not valid at this point\n"
+ " (probably due to missing keywords)\n",
+ field->ident ));
+ error = FT_Err_Ok;
+ }
Exit:
return error;
@@ -1027,7 +1041,8 @@
static int
read_binary_data( T1_Parser parser,
FT_Long* size,
- FT_Byte** base )
+ FT_Byte** base,
+ FT_Bool incremental )
{
FT_Byte* cur;
FT_Byte* limit = parser->root.limit;
@@ -1045,7 +1060,8 @@
if ( cur < limit && ft_isdigit( *cur ) )
{
- *size = T1_ToInt( parser );
+ FT_Long s = T1_ToInt( parser );
+
T1_Skip_PS_Token( parser ); /* `RD' or `-|' or something else */
@@ -1053,12 +1069,20 @@
/* `RD' or `-|' token */
*base = parser->root.cursor + 1;
- parser->root.cursor += *size + 1;
- return !parser->root.error;
+ if ( s >= 0 && s < limit - *base )
+ {
+ parser->root.cursor += s + 1;
+ *size = s;
+ return !parser->root.error;
+ }
+ }
+
+ if( !incremental )
+ {
+ FT_ERROR(( "read_binary_data: invalid size field\n" ));
+ parser->root.error = FT_THROW( Invalid_File_Format );
}
- FT_ERROR(( "read_binary_data: invalid size field\n" ));
- parser->root.error = T1_Err_Invalid_File_Format;
return 0;
}
@@ -1067,8 +1091,8 @@
/* and `/CharStrings' dictionaries. */
static void
- parse_font_matrix( T1_Face face,
- T1_Loader loader )
+ t1_parse_font_matrix( T1_Face face,
+ T1_Loader loader )
{
T1_Parser parser = &loader->parser;
FT_Matrix* matrix = &face->type1.font_matrix;
@@ -1081,9 +1105,9 @@
result = T1_ToFixedArray( parser, 6, temp, 3 );
- if ( result < 0 )
+ if ( result < 6 )
{
- parser->root.error = T1_Err_Invalid_File_Format;
+ parser->root.error = FT_THROW( Invalid_File_Format );
return;
}
@@ -1091,8 +1115,8 @@
if ( temp_scale == 0 )
{
- FT_ERROR(( "parse_font_matrix: invalid font matrix\n" ));
- parser->root.error = T1_Err_Invalid_File_Format;
+ FT_ERROR(( "t1_parse_font_matrix: invalid font matrix\n" ));
+ parser->root.error = FT_THROW( Invalid_File_Format );
return;
}
@@ -1100,8 +1124,7 @@
/* 1000 / temp_scale, because temp_scale was already multiplied by */
/* 1000 (in t1_tofixed, from psobjs.c). */
- root->units_per_EM = (FT_UShort)( FT_DivFix( 1000 * 0x10000L,
- temp_scale ) >> 16 );
+ root->units_per_EM = (FT_UShort)FT_DivFix( 1000, temp_scale );
/* we need to scale the values by 1.0/temp_scale */
if ( temp_scale != 0x10000L )
@@ -1111,7 +1134,7 @@
temp[2] = FT_DivFix( temp[2], temp_scale );
temp[4] = FT_DivFix( temp[4], temp_scale );
temp[5] = FT_DivFix( temp[5], temp_scale );
- temp[3] = 0x10000L;
+ temp[3] = temp[3] < 0 ? -0x10000L : 0x10000L;
}
matrix->xx = temp[0];
@@ -1141,7 +1164,7 @@
if ( cur >= limit )
{
FT_ERROR(( "parse_encoding: out of bounds\n" ));
- parser->root.error = T1_Err_Invalid_File_Format;
+ parser->root.error = FT_THROW( Invalid_File_Format );
return;
}
@@ -1188,7 +1211,7 @@
char* notdef = (char *)".notdef";
- T1_Add_Table( char_table, n, notdef, 8 );
+ (void)T1_Add_Table( char_table, n, notdef, 8 );
}
/* Now we need to read records of the form */
@@ -1249,11 +1272,18 @@
{
charcode = (FT_Int)T1_ToInt( parser );
T1_Skip_Spaces( parser );
+
+ /* protect against invalid charcode */
+ if ( cur == parser->root.cursor )
+ {
+ parser->root.error = FT_THROW( Unknown_File_Format );
+ return;
+ }
}
cur = parser->root.cursor;
- if ( *cur == '/' && cur + 2 < limit && n < count )
+ if ( cur + 2 < limit && *cur == '/' && n < count )
{
FT_PtrDist len;
@@ -1262,6 +1292,8 @@
parser->root.cursor = cur;
T1_Skip_PS_Token( parser );
+ if ( parser->root.cursor >= limit )
+ return;
if ( parser->root.error )
return;
@@ -1285,7 +1317,7 @@
/* specification (it might be an encoding for a CID type1 */
/* font, however), so we conclude that this font is NOT a */
/* type1 font. */
- parser->root.error = FT_Err_Unknown_File_Format;
+ parser->root.error = FT_THROW( Unknown_File_Format );
return;
}
}
@@ -1320,7 +1352,7 @@
face->type1.encoding_type = T1_ENCODING_TYPE_ISOLATIN1;
else
- parser->root.error = T1_Err_Ignore;
+ parser->root.error = FT_ERR( Ignore );
}
}
@@ -1348,7 +1380,7 @@
T1_Skip_Spaces ( parser );
if ( parser->root.cursor >= parser->root.limit ||
*parser->root.cursor != ']' )
- parser->root.error = T1_Err_Invalid_File_Format;
+ parser->root.error = FT_THROW( Invalid_File_Format );
return;
}
@@ -1379,15 +1411,17 @@
FT_Byte* base;
- /* If the next token isn't `dup' we are done. */
- if ( ft_strncmp( (char*)parser->root.cursor, "dup", 3 ) != 0 )
+ /* If we are out of data, or if the next token isn't `dup', */
+ /* we are done. */
+ if ( parser->root.cursor + 4 >= parser->root.limit ||
+ ft_strncmp( (char*)parser->root.cursor, "dup", 3 ) != 0 )
break;
T1_Skip_PS_Token( parser ); /* `dup' */
idx = T1_ToInt( parser );
- if ( !read_binary_data( parser, &size, &base ) )
+ if ( !read_binary_data( parser, &size, &base, IS_INCREMENTAL ) )
return;
/* The binary string is followed by one token, e.g. `NP' */
@@ -1399,7 +1433,8 @@
return;
T1_Skip_Spaces ( parser );
- if ( ft_strncmp( (char*)parser->root.cursor, "put", 3 ) == 0 )
+ if ( parser->root.cursor + 4 < parser->root.limit &&
+ ft_strncmp( (char*)parser->root.cursor, "put", 3 ) == 0 )
{
T1_Skip_PS_Token( parser ); /* skip `put' */
T1_Skip_Spaces ( parser );
@@ -1424,7 +1459,7 @@
/* least contain a `return'), but we support them anyway */
if ( size < face->type1.private_dict.lenIV )
{
- error = T1_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Fail;
}
@@ -1478,6 +1513,12 @@
num_glyphs = (FT_Int)T1_ToInt( parser );
+ if ( num_glyphs < 0 )
+ {
+ error = FT_THROW( Invalid_File_Format );
+ goto Fail;
+ }
+
/* some fonts like Optima-Oblique not only define the /CharStrings */
/* array but access it also */
if ( num_glyphs == 0 || parser->root.error )
@@ -1555,6 +1596,11 @@
}
T1_Skip_PS_Token( parser );
+ if ( parser->root.cursor >= limit )
+ {
+ error = FT_THROW( Invalid_File_Format );
+ goto Fail;
+ }
if ( parser->root.error )
return;
@@ -1563,16 +1609,16 @@
FT_PtrDist len;
- if ( cur + 1 >= limit )
+ if ( cur + 2 >= limit )
{
- error = T1_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Fail;
}
cur++; /* skip `/' */
len = parser->root.cursor - cur;
- if ( !read_binary_data( parser, &size, &base ) )
+ if ( !read_binary_data( parser, &size, &base, IS_INCREMENTAL ) )
return;
/* for some non-standard fonts like `Optima' which provides */
@@ -1605,7 +1651,7 @@
if ( size <= face->type1.private_dict.lenIV )
{
- error = T1_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Fail;
}
@@ -1764,7 +1810,7 @@
#include "t1tokens.h"
/* now add the special functions... */
- T1_FIELD_CALLBACK( "FontMatrix", parse_font_matrix,
+ T1_FIELD_CALLBACK( "FontMatrix", t1_parse_font_matrix,
T1_FIELD_DICT_FONTDICT )
T1_FIELD_CALLBACK( "Encoding", parse_encoding,
T1_FIELD_DICT_FONTDICT )
@@ -1809,7 +1855,7 @@
parser->root.cursor = base;
parser->root.limit = base + size;
- parser->root.error = T1_Err_Ok;
+ parser->root.error = FT_Err_Ok;
limit = parser->root.limit;
@@ -1861,8 +1907,8 @@
parser->root.cursor = start_binary;
- if ( !read_binary_data( parser, &s, &b ) )
- return T1_Err_Invalid_File_Format;
+ if ( !read_binary_data( parser, &s, &b, IS_INCREMENTAL ) )
+ return FT_THROW( Invalid_File_Format );
have_integer = 0;
}
@@ -1874,8 +1920,8 @@
parser->root.cursor = start_binary;
- if ( !read_binary_data( parser, &s, &b ) )
- return T1_Err_Invalid_File_Format;
+ if ( !read_binary_data( parser, &s, &b, IS_INCREMENTAL ) )
+ return FT_THROW( Invalid_File_Format );
have_integer = 0;
}
@@ -1947,8 +1993,8 @@
if ( !( dict & keyword->dict ) )
{
- FT_TRACE1(( "parse_dict: found %s but ignoring it "
- "since it is in the wrong dictionary\n",
+ FT_TRACE1(( "parse_dict: found `%s' but ignoring it"
+ " since it is in the wrong dictionary\n",
keyword->ident ));
break;
}
@@ -1960,10 +2006,10 @@
parser->root.error = t1_load_keyword( face,
loader,
keyword );
- if ( parser->root.error != T1_Err_Ok )
+ if ( parser->root.error != FT_Err_Ok )
{
- if ( FT_ERROR_BASE( parser->root.error ) == FT_Err_Ignore )
- parser->root.error = T1_Err_Ok;
+ if ( FT_ERR_EQ( parser->root.error, Ignore ) )
+ parser->root.error = FT_Err_Ok;
else
return parser->root.error;
}
@@ -2132,8 +2178,10 @@
}
}
}
+ else
+ face->len_buildchar = 0;
-#endif /* T1_CONFIG_OPTION_NO_MM_SUPPORT */
+#endif /* !T1_CONFIG_OPTION_NO_MM_SUPPORT */
/* now, propagate the subrs, charstrings, and glyphnames tables */
/* to the Type1 data */
@@ -2148,13 +2196,11 @@
type1->subrs_len = loader.subrs.lengths;
}
-#ifdef FT_CONFIG_OPTION_INCREMENTAL
- if ( !face->root.internal->incremental_interface )
-#endif
+ if ( !IS_INCREMENTAL )
if ( !loader.charstrings.init )
{
FT_ERROR(( "T1_Open_Face: no `/CharStrings' array in face\n" ));
- error = T1_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
}
loader.charstrings.init = 0;
@@ -2173,14 +2219,13 @@
if ( type1->encoding_type == T1_ENCODING_TYPE_ARRAY )
{
FT_Int charcode, idx, min_char, max_char;
- FT_Byte* char_name;
FT_Byte* glyph_name;
/* OK, we do the following: for each element in the encoding */
/* table, look up the index of the glyph having the same name */
/* the index is then stored in type1.encoding.char_index, and */
- /* a the name to type1.encoding.char_name */
+ /* the name to type1.encoding.char_name */
min_char = 0;
max_char = 0;
@@ -2188,6 +2233,9 @@
charcode = 0;
for ( ; charcode < loader.encoding_table.max_elems; charcode++ )
{
+ FT_Byte* char_name;
+
+
type1->encoding.char_index[charcode] = 0;
type1->encoding.char_name [charcode] = (char *)".notdef";
diff --git a/src/3rdparty/freetype/src/type1/t1objs.c b/src/3rdparty/freetype/src/type1/t1objs.c
index b1de687196..e11770feef 100644
--- a/src/3rdparty/freetype/src/type1/t1objs.c
+++ b/src/3rdparty/freetype/src/type1/t1objs.c
@@ -4,7 +4,7 @@
/* */
/* Type 1 objects manager (body). */
/* */
-/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
+/* Copyright 1996-2009, 2011, 2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -72,8 +72,11 @@
FT_LOCAL_DEF( void )
- T1_Size_Done( T1_Size size )
+ T1_Size_Done( FT_Size t1size ) /* T1_Size */
{
+ T1_Size size = (T1_Size)t1size;
+
+
if ( size->root.internal )
{
PSH_Globals_Funcs funcs;
@@ -89,9 +92,10 @@
FT_LOCAL_DEF( FT_Error )
- T1_Size_Init( T1_Size size )
+ T1_Size_Init( FT_Size t1size ) /* T1_Size */
{
- FT_Error error = T1_Err_Ok;
+ T1_Size size = (T1_Size)t1size;
+ FT_Error error = FT_Err_Ok;
PSH_Globals_Funcs funcs = T1_Size_Get_Globals_Funcs( size );
@@ -112,9 +116,10 @@
FT_LOCAL_DEF( FT_Error )
- T1_Size_Request( T1_Size size,
+ T1_Size_Request( FT_Size t1size, /* T1_Size */
FT_Size_Request req )
{
+ T1_Size size = (T1_Size)t1size;
PSH_Globals_Funcs funcs = T1_Size_Get_Globals_Funcs( size );
@@ -126,7 +131,7 @@
size->root.metrics.y_scale,
0, 0 );
- return T1_Err_Ok;
+ return FT_Err_Ok;
}
@@ -137,20 +142,20 @@
/*************************************************************************/
FT_LOCAL_DEF( void )
- T1_GlyphSlot_Done( T1_GlyphSlot slot )
+ T1_GlyphSlot_Done( FT_GlyphSlot slot )
{
- slot->root.internal->glyph_hints = 0;
+ slot->internal->glyph_hints = 0;
}
FT_LOCAL_DEF( FT_Error )
- T1_GlyphSlot_Init( T1_GlyphSlot slot )
+ T1_GlyphSlot_Init( FT_GlyphSlot slot )
{
T1_Face face;
PSHinter_Service pshinter;
- face = (T1_Face)slot->root.face;
+ face = (T1_Face)slot->face;
pshinter = (PSHinter_Service)face->pshinter;
if ( pshinter )
@@ -158,15 +163,18 @@
FT_Module module;
- module = FT_Get_Module( slot->root.face->driver->root.library, "pshinter" );
- if (module)
+ module = FT_Get_Module( slot->face->driver->root.library,
+ "pshinter" );
+ if ( module )
{
T1_Hints_Funcs funcs;
+
funcs = pshinter->get_t1_funcs( module );
- slot->root.internal->glyph_hints = (void*)funcs;
+ slot->internal->glyph_hints = (void*)funcs;
}
}
+
return 0;
}
@@ -190,8 +198,9 @@
/* face :: A typeless pointer to the face object to destroy. */
/* */
FT_LOCAL_DEF( void )
- T1_Face_Done( T1_Face face )
+ T1_Face_Done( FT_Face t1face ) /* T1_Face */
{
+ T1_Face face = (T1_Face)t1face;
FT_Memory memory;
T1_Font type1;
@@ -289,11 +298,12 @@
/* */
FT_LOCAL_DEF( FT_Error )
T1_Face_Init( FT_Stream stream,
- T1_Face face,
+ FT_Face t1face, /* T1_Face */
FT_Int face_index,
FT_Int num_params,
FT_Parameter* params )
{
+ T1_Face face = (T1_Face)t1face;
FT_Error error;
FT_Service_PsCMaps psnames;
PSAux_Service psaux;
@@ -313,10 +323,18 @@
face->psaux = FT_Get_Module_Interface( FT_FACE_LIBRARY( face ),
"psaux" );
psaux = (PSAux_Service)face->psaux;
+ if ( !psaux )
+ {
+ FT_ERROR(( "T1_Face_Init: cannot access `psaux' module\n" ));
+ error = FT_THROW( Missing_Module );
+ goto Exit;
+ }
face->pshinter = FT_Get_Module_Interface( FT_FACE_LIBRARY( face ),
"pshinter" );
+ FT_TRACE2(( "Type 1 driver\n" ));
+
/* open the tokenizer; this will also check the font format */
error = T1_Open_Face( face );
if ( error )
@@ -330,7 +348,7 @@
if ( face_index > 0 )
{
FT_ERROR(( "T1_Face_Init: invalid face index\n" ));
- error = T1_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
goto Exit;
}
@@ -346,10 +364,10 @@
root->num_glyphs = type1->num_glyphs;
root->face_index = 0;
- root->face_flags = FT_FACE_FLAG_SCALABLE |
- FT_FACE_FLAG_HORIZONTAL |
- FT_FACE_FLAG_GLYPH_NAMES |
- FT_FACE_FLAG_HINTER;
+ root->face_flags |= FT_FACE_FLAG_SCALABLE |
+ FT_FACE_FLAG_HORIZONTAL |
+ FT_FACE_FLAG_GLYPH_NAMES |
+ FT_FACE_FLAG_HINTER;
if ( info->is_fixed_pitch )
root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;
@@ -447,7 +465,7 @@
root->bbox.xMax = ( type1->font_bbox.xMax + 0xFFFF ) >> 16;
root->bbox.yMax = ( type1->font_bbox.yMax + 0xFFFF ) >> 16;
- /* Set units_per_EM if we didn't set it in parse_font_matrix. */
+ /* Set units_per_EM if we didn't set it in t1_parse_font_matrix. */
if ( !root->units_per_EM )
root->units_per_EM = 1000;
@@ -471,7 +489,7 @@
if ( !error )
root->max_advance_width = (FT_Short)FIXED_TO_INT( max_advance );
else
- error = T1_Err_Ok; /* clear error */
+ error = FT_Err_Ok; /* clear error */
}
root->max_advance_height = root->height;
@@ -484,7 +502,7 @@
FT_Face root = &face->root;
- if ( psnames && psaux )
+ if ( psnames )
{
FT_CharMapRec charmap;
T1_CMap_Classes cmap_classes = psaux->t1_cmap_classes;
@@ -494,14 +512,18 @@
charmap.face = root;
/* first of all, try to synthesize a Unicode charmap */
- charmap.platform_id = 3;
- charmap.encoding_id = 1;
+ charmap.platform_id = TT_PLATFORM_MICROSOFT;
+ charmap.encoding_id = TT_MS_ID_UNICODE_CS;
charmap.encoding = FT_ENCODING_UNICODE;
- FT_CMap_New( cmap_classes->unicode, NULL, &charmap, NULL );
+ error = FT_CMap_New( cmap_classes->unicode, NULL, &charmap, NULL );
+ if ( error &&
+ FT_ERR_NEQ( error, No_Unicode_Glyph_Name ) )
+ goto Exit;
+ error = FT_Err_Ok;
/* now, generate an Adobe Standard encoding when appropriate */
- charmap.platform_id = 7;
+ charmap.platform_id = TT_PLATFORM_ADOBE;
clazz = NULL;
switch ( type1->encoding_type )
@@ -535,7 +557,7 @@
}
if ( clazz )
- FT_CMap_New( clazz, NULL, &charmap, NULL );
+ error = FT_CMap_New( clazz, NULL, &charmap, NULL );
#if 0
/* Select default charmap */
@@ -565,11 +587,11 @@
/* FreeType error code. 0 means success. */
/* */
FT_LOCAL_DEF( FT_Error )
- T1_Driver_Init( T1_Driver driver )
+ T1_Driver_Init( FT_Module driver )
{
FT_UNUSED( driver );
- return T1_Err_Ok;
+ return FT_Err_Ok;
}
@@ -585,7 +607,7 @@
/* driver :: A handle to the target Type 1 driver. */
/* */
FT_LOCAL_DEF( void )
- T1_Driver_Done( T1_Driver driver )
+ T1_Driver_Done( FT_Module driver )
{
FT_UNUSED( driver );
}
diff --git a/src/3rdparty/freetype/src/type1/t1objs.h b/src/3rdparty/freetype/src/type1/t1objs.h
index e5e90293d7..54ccbb996a 100644
--- a/src/3rdparty/freetype/src/type1/t1objs.h
+++ b/src/3rdparty/freetype/src/type1/t1objs.h
@@ -4,7 +4,7 @@
/* */
/* Type 1 objects manager (specification). */
/* */
-/* Copyright 1996-2001, 2002, 2006 by */
+/* Copyright 1996-2001, 2002, 2006, 2011 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -37,17 +37,6 @@ FT_BEGIN_HEADER
/*************************************************************************/
/* */
/* <Type> */
- /* T1_Driver */
- /* */
- /* <Description> */
- /* A handle to a Type 1 driver object. */
- /* */
- typedef struct T1_DriverRec_ *T1_Driver;
-
-
- /*************************************************************************/
- /* */
- /* <Type> */
/* T1_Size */
/* */
/* <Description> */
@@ -106,14 +95,14 @@ FT_BEGIN_HEADER
FT_LOCAL( void )
- T1_Size_Done( T1_Size size );
+ T1_Size_Done( FT_Size size );
FT_LOCAL( FT_Error )
- T1_Size_Request( T1_Size size,
+ T1_Size_Request( FT_Size size,
FT_Size_Request req );
FT_LOCAL( FT_Error )
- T1_Size_Init( T1_Size size );
+ T1_Size_Init( FT_Size size );
/*************************************************************************/
@@ -142,25 +131,25 @@ FT_BEGIN_HEADER
FT_LOCAL( FT_Error )
T1_Face_Init( FT_Stream stream,
- T1_Face face,
+ FT_Face face,
FT_Int face_index,
FT_Int num_params,
FT_Parameter* params );
FT_LOCAL( void )
- T1_Face_Done( T1_Face face );
+ T1_Face_Done( FT_Face face );
FT_LOCAL( FT_Error )
- T1_GlyphSlot_Init( T1_GlyphSlot slot );
+ T1_GlyphSlot_Init( FT_GlyphSlot slot );
FT_LOCAL( void )
- T1_GlyphSlot_Done( T1_GlyphSlot slot );
+ T1_GlyphSlot_Done( FT_GlyphSlot slot );
FT_LOCAL( FT_Error )
- T1_Driver_Init( T1_Driver driver );
+ T1_Driver_Init( FT_Module driver );
FT_LOCAL( void )
- T1_Driver_Done( T1_Driver driver );
+ T1_Driver_Done( FT_Module driver );
FT_END_HEADER
diff --git a/src/3rdparty/freetype/src/type1/t1parse.c b/src/3rdparty/freetype/src/type1/t1parse.c
index 2a762279fd..ccf9f4cc56 100644
--- a/src/3rdparty/freetype/src/type1/t1parse.c
+++ b/src/3rdparty/freetype/src/type1/t1parse.c
@@ -4,7 +4,7 @@
/* */
/* Type 1 parser (body). */
/* */
-/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2008, 2009 by */
+/* Copyright 1996-2005, 2008, 2009, 2012-2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -119,10 +119,10 @@
if ( !FT_FRAME_ENTER( header_length ) )
{
- error = T1_Err_Ok;
+ error = FT_Err_Ok;
if ( ft_memcmp( stream->cursor, header_string, header_length ) != 0 )
- error = T1_Err_Unknown_File_Format;
+ error = FT_THROW( Unknown_File_Format );
FT_FRAME_EXIT();
}
@@ -158,13 +158,13 @@
error = check_type1_format( stream, "%!PS-AdobeFont", 14 );
if ( error )
{
- if ( error != T1_Err_Unknown_File_Format )
+ if ( FT_ERR_NEQ( error, Unknown_File_Format ) )
goto Exit;
error = check_type1_format( stream, "%!FontType", 10 );
if ( error )
{
- FT_TRACE2(( "[not a Type1 font]\n" ));
+ FT_TRACE2(( " not a Type 1 font\n" ));
goto Exit;
}
}
@@ -263,7 +263,7 @@
{
FT_Stream stream = parser->stream;
FT_Memory memory = parser->root.memory;
- FT_Error error = T1_Err_Ok;
+ FT_Error error = FT_Err_Ok;
FT_ULong size;
@@ -299,7 +299,7 @@
{
FT_ERROR(( "T1_Get_Private_Dict:"
" invalid private dictionary section\n" ));
- error = T1_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Fail;
}
@@ -313,7 +313,7 @@
error = read_pfb_tag( stream, &tag, &size );
if ( error || tag != 0x8002U )
{
- error = T1_Err_Ok;
+ error = FT_Err_Ok;
break;
}
@@ -332,9 +332,11 @@
/* dictionary block in the heap. */
/* first of all, look at the `eexec' keyword */
- FT_Byte* cur = parser->base_dict;
- FT_Byte* limit = cur + parser->base_len;
- FT_Byte c;
+ FT_Byte* cur = parser->base_dict;
+ FT_Byte* limit = cur + parser->base_len;
+ FT_Byte c;
+ FT_Pointer pos_lf;
+ FT_Bool test_cr;
Again:
@@ -342,7 +344,7 @@
{
c = cur[0];
if ( c == 'e' && cur + 9 < limit ) /* 9 = 5 letters for `eexec' + */
- /* newline + 4 chars */
+ /* whitespace + 4 chars */
{
if ( cur[1] == 'e' &&
cur[2] == 'x' &&
@@ -355,7 +357,7 @@
{
FT_ERROR(( "T1_Get_Private_Dict:"
" could not find `eexec' keyword\n" ));
- error = T1_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Exit;
}
}
@@ -364,7 +366,8 @@
/* or string (as e.g. in u003043t.gsf from ghostscript) */
parser->root.cursor = parser->base_dict;
- parser->root.limit = cur + 9;
+ /* set limit to `eexec' + whitespace + 4 characters */
+ parser->root.limit = cur + 10;
cur = parser->root.cursor;
limit = parser->root.limit;
@@ -396,27 +399,37 @@
parser->root.limit = parser->base_dict + parser->base_len;
T1_Skip_PS_Token( parser );
- cur = parser->root.cursor;
+ cur = parser->root.cursor;
+ limit = parser->root.limit;
- /* according to the Type1 spec, the first cipher byte must not be */
+ /* According to the Type 1 spec, the first cipher byte must not be */
/* an ASCII whitespace character code (blank, tab, carriage return */
/* or line feed). We have seen Type 1 fonts with two line feed */
/* characters... So skip now all whitespace character codes. */
- while ( cur < limit &&
- ( *cur == ' ' ||
- *cur == '\t' ||
- *cur == '\r' ||
- *cur == '\n' ) )
+ /* */
+ /* On the other hand, Adobe's Type 1 parser handles fonts just */
+ /* fine that are violating this limitation, so we add a heuristic */
+ /* test to stop at \r only if it is not used for EOL. */
+
+ pos_lf = ft_memchr( cur, '\n', limit - cur );
+ test_cr = FT_BOOL( !pos_lf ||
+ pos_lf > ft_memchr( cur, '\r', limit - cur ) );
+
+ while ( cur < limit &&
+ ( *cur == ' ' ||
+ *cur == '\t' ||
+ (test_cr && *cur == '\r' ) ||
+ *cur == '\n' ) )
++cur;
if ( cur >= limit )
{
FT_ERROR(( "T1_Get_Private_Dict:"
" `eexec' not properly terminated\n" ));
- error = T1_Err_Invalid_File_Format;
+ error = FT_THROW( Invalid_File_Format );
goto Exit;
}
- size = parser->base_len - ( cur - parser->base_dict );
+ size = (FT_ULong)( parser->base_len - ( cur - parser->base_dict ) );
if ( parser->in_memory )
{
@@ -437,11 +450,12 @@
/* now determine whether the private dictionary is encoded in binary */
/* or hexadecimal ASCII format -- decode it accordingly */
- /* we need to access the next 4 bytes (after the final \r following */
- /* the `eexec' keyword); if they all are hexadecimal digits, then */
- /* we have a case of ASCII storage */
+ /* we need to access the next 4 bytes (after the final whitespace */
+ /* following the `eexec' keyword); if they all are hexadecimal */
+ /* digits, then we have a case of ASCII storage */
- if ( ft_isxdigit( cur[0] ) && ft_isxdigit( cur[1] ) &&
+ if ( cur + 3 < limit &&
+ ft_isxdigit( cur[0] ) && ft_isxdigit( cur[1] ) &&
ft_isxdigit( cur[2] ) && ft_isxdigit( cur[3] ) )
{
/* ASCII hexadecimal encoding */
@@ -467,6 +481,14 @@
/* we now decrypt the encoded binary private dictionary */
psaux->t1_decrypt( parser->private_dict, parser->private_len, 55665U );
+ if ( parser->private_len < 4 )
+ {
+ FT_ERROR(( "T1_Get_Private_Dict:"
+ " invalid private dictionary section\n" ));
+ error = FT_THROW( Invalid_File_Format );
+ goto Fail;
+ }
+
/* replace the four random bytes at the beginning with whitespace */
parser->private_dict[0] = ' ';
parser->private_dict[1] = ' ';
diff --git a/src/3rdparty/freetype/src/type1/t1tokens.h b/src/3rdparty/freetype/src/type1/t1tokens.h
index 2d692f0e61..e37276b908 100644
--- a/src/3rdparty/freetype/src/type1/t1tokens.h
+++ b/src/3rdparty/freetype/src/type1/t1tokens.h
@@ -96,7 +96,7 @@
T1_FIELD_DICT_PRIVATE )
T1_FIELD_BOOL ( "ForceBold", force_bold,
T1_FIELD_DICT_PRIVATE )
-
+
#undef FT_STRUCTURE
#define FT_STRUCTURE T1_FontRec