From dba44cd4e5754b579f2184a864ffe7b79b0a7e56 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Mon, 2 Nov 2015 07:10:28 +0400 Subject: Update bundled FreeType to 2.6.1 Change-Id: Ic489f8aa8ad42da3922f542e6c9064afe44f3799 Reviewed-by: Friedemann Kleint Reviewed-by: Lars Knoll --- src/3rdparty/freetype/src/winfonts/winfnt.c | 89 ++++++++++++++++++----------- 1 file changed, 56 insertions(+), 33 deletions(-) (limited to 'src/3rdparty/freetype/src/winfonts/winfnt.c') diff --git a/src/3rdparty/freetype/src/winfonts/winfnt.c b/src/3rdparty/freetype/src/winfonts/winfnt.c index 4705c53963..4bfa55a429 100644 --- a/src/3rdparty/freetype/src/winfonts/winfnt.c +++ b/src/3rdparty/freetype/src/winfonts/winfnt.c @@ -4,7 +4,7 @@ /* */ /* FreeType font driver for Windows FNT/FON files */ /* */ -/* Copyright 1996-2004, 2006-2014 by */ +/* Copyright 1996-2015 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* Copyright 2003 Huw D M Davies for Codeweavers */ /* Copyright 2007 Dmitry Timoshkov for Codeweavers */ @@ -28,7 +28,7 @@ #include "winfnt.h" #include "fnterrs.h" #include FT_SERVICE_WINFNT_H -#include FT_SERVICE_XFREE86_NAME_H +#include FT_SERVICE_FONT_FORMAT_H /*************************************************************************/ /* */ @@ -201,7 +201,7 @@ FT_FREE( font->family_name ); FT_FREE( font ); - face->font = 0; + face->font = NULL; } @@ -269,15 +269,18 @@ static FT_Error fnt_face_get_dll_font( FNT_Face face, - FT_Int face_index ) + FT_Int face_instance_index ) { FT_Error error; FT_Stream stream = FT_FACE( face )->stream; FT_Memory memory = FT_FACE( face )->memory; WinMZ_HeaderRec mz_header; + FT_Long face_index; - face->font = 0; + face->font = NULL; + + face_index = FT_ABS( face_instance_index ) & 0xFFFF; /* does it begin with an MZ header? */ if ( FT_STREAM_SEEK( 0 ) || @@ -317,6 +320,21 @@ size_shift = FT_GET_USHORT_LE(); + /* Microsoft's specification of the executable-file header format */ + /* for `New Executable' (NE) doesn't give a limit for the */ + /* alignment shift count; however, in 1985, the year of the */ + /* specification release, only 32bit values were supported, thus */ + /* anything larger than 16 doesn't make sense in general, given */ + /* that file offsets are 16bit values, shifted by the alignment */ + /* shift count */ + if ( size_shift > 16 ) + { + FT_TRACE2(( "invalid alignment shift count for resource data\n" )); + error = FT_THROW( Invalid_File_Format ); + goto Exit; + } + + for (;;) { FT_UShort type_id, count; @@ -331,8 +349,8 @@ if ( type_id == 0x8008U ) { font_count = count; - font_offset = (FT_ULong)( FT_STREAM_POS() + 4 + - ( stream->cursor - stream->limit ) ); + font_offset = FT_STREAM_POS() + 4 + + (FT_ULong)( stream->cursor - stream->limit ); break; } @@ -359,19 +377,20 @@ face->root.num_faces = font_count; + if ( face_instance_index < 0 ) + goto Exit; + if ( face_index >= font_count ) { error = FT_THROW( Invalid_Argument ); goto Exit; } - else if ( face_index < 0 ) - goto Exit; if ( FT_NEW( face->font ) ) goto Exit; - if ( FT_STREAM_SEEK( font_offset + face_index * 12 ) || - FT_FRAME_ENTER( 12 ) ) + if ( FT_STREAM_SEEK( font_offset + (FT_ULong)face_index * 12 ) || + FT_FRAME_ENTER( 12 ) ) goto Fail; face->font->offset = (FT_ULong)FT_GET_USHORT_LE() << size_shift; @@ -391,7 +410,7 @@ WinPE_RsrcDirEntryRec dir_entry1, dir_entry2, dir_entry3; WinPE_RsrcDataEntryRec data_entry; - FT_Long root_dir_offset, name_dir_offset, lang_dir_offset; + FT_ULong root_dir_offset, name_dir_offset, lang_dir_offset; FT_UShort i, j, k; @@ -689,13 +708,14 @@ static FT_Error FNT_Face_Init( FT_Stream stream, FT_Face fntface, /* FNT_Face */ - FT_Int face_index, + FT_Int face_instance_index, FT_Int num_params, FT_Parameter* params ) { FNT_Face face = (FNT_Face)fntface; FT_Error error; FT_Memory memory = FT_FACE_MEMORY( face ); + FT_Int face_index; FT_UNUSED( num_params ); FT_UNUSED( params ); @@ -703,9 +723,11 @@ FT_TRACE2(( "Windows FNT driver\n" )); + face_index = FT_ABS( face_instance_index ) & 0xFFFF; + /* try to load font from a DLL */ - error = fnt_face_get_dll_font( face, face_index ); - if ( !error && face_index < 0 ) + error = fnt_face_get_dll_font( face, face_instance_index ); + if ( !error && face_instance_index < 0 ) goto Exit; if ( FT_ERR_EQ( error, Unknown_File_Format ) ) @@ -726,10 +748,11 @@ if ( !error ) { + if ( face_instance_index < 0 ) + goto Exit; + if ( face_index > 0 ) error = FT_THROW( Invalid_Argument ); - else if ( face_index < 0 ) - goto Exit; } } @@ -739,9 +762,9 @@ /* we now need to fill the root FT_Face fields */ /* with relevant information */ { - FT_Face root = FT_FACE( face ); - FNT_Font font = face->font; - FT_PtrDist family_size; + FT_Face root = FT_FACE( face ); + FNT_Font font = face->font; + FT_ULong family_size; root->face_index = face_index; @@ -769,9 +792,9 @@ FT_UShort x_res, y_res; - bsize->width = font->header.avg_width; - bsize->height = (FT_Short)( - font->header.pixel_height + font->header.external_leading ); + bsize->width = (FT_Short)font->header.avg_width; + bsize->height = (FT_Short)( font->header.pixel_height + + font->header.external_leading ); bsize->size = font->header.nominal_point_size << 6; x_res = font->header.horizontal_resolution; @@ -964,7 +987,7 @@ FNT_Font font; FT_Error error = FT_Err_Ok; FT_Byte* p; - FT_Int len; + FT_UInt len; FT_Bitmap* bitmap = &slot->bitmap; FT_ULong offset; FT_Bool new_format; @@ -1009,7 +1032,7 @@ p = font->fnt_frame + offset; - bitmap->width = FT_NEXT_SHORT_LE( p ); + bitmap->width = FT_NEXT_USHORT_LE( p ); /* jump to glyph entry */ if ( new_format ) @@ -1030,12 +1053,12 @@ /* allocate and build bitmap */ { FT_Memory memory = FT_FACE_MEMORY( slot->face ); - FT_Int pitch = ( bitmap->width + 7 ) >> 3; + FT_UInt pitch = ( bitmap->width + 7 ) >> 3; FT_Byte* column; FT_Byte* write; - bitmap->pitch = pitch; + bitmap->pitch = (int)pitch; bitmap->rows = font->header.pixel_height; bitmap->pixel_mode = FT_PIXEL_MODE_MONO; @@ -1069,14 +1092,14 @@ slot->format = FT_GLYPH_FORMAT_BITMAP; /* now set up metrics */ - slot->metrics.width = bitmap->width << 6; - slot->metrics.height = bitmap->rows << 6; - slot->metrics.horiAdvance = bitmap->width << 6; + slot->metrics.width = (FT_Pos)( bitmap->width << 6 ); + slot->metrics.height = (FT_Pos)( bitmap->rows << 6 ); + slot->metrics.horiAdvance = (FT_Pos)( bitmap->width << 6 ); slot->metrics.horiBearingX = 0; slot->metrics.horiBearingY = slot->bitmap_top << 6; ft_synthesize_vertical_metrics( &slot->metrics, - bitmap->rows << 6 ); + (FT_Pos)( bitmap->rows << 6 ) ); Exit: return error; @@ -1108,8 +1131,8 @@ static const FT_ServiceDescRec winfnt_services[] = { - { FT_SERVICE_ID_XF86_NAME, FT_XF86_FORMAT_WINFNT }, - { FT_SERVICE_ID_WINFNT, &winfnt_service_rec }, + { FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_WINFNT }, + { FT_SERVICE_ID_WINFNT, &winfnt_service_rec }, { NULL, NULL } }; -- cgit v1.2.3