From 2eaf0cf8fd6e7c290497fedb08134a89e7b49b1d Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Thu, 19 Mar 2015 17:34:42 +0400 Subject: Update bundled FreeType to 2.5.5 Removed everything, imported with help of import_from_tarball.sh script, and then added a pre-generated builds/unix/ftconfig.h Task-number: QTBUG-44648 Change-Id: Iea948e41f7761f1580382b3763d04c7a61383382 Reviewed-by: Lars Knoll --- src/3rdparty/freetype/src/pcf/pcfdrivr.c | 146 +++++++++++++++++++------------ 1 file changed, 89 insertions(+), 57 deletions(-) (limited to 'src/3rdparty/freetype/src/pcf/pcfdrivr.c') diff --git a/src/3rdparty/freetype/src/pcf/pcfdrivr.c b/src/3rdparty/freetype/src/pcf/pcfdrivr.c index b34e542aeb..96f6912ba9 100644 --- a/src/3rdparty/freetype/src/pcf/pcfdrivr.c +++ b/src/3rdparty/freetype/src/pcf/pcfdrivr.c @@ -2,7 +2,7 @@ FreeType font driver for pcf files - Copyright (C) 2000, 2001, 2002, 2003, 2004, 2006, 2007, 2008, 2009 by + Copyright (C) 2000-2004, 2006-2011, 2013, 2014 by Francesco Zappa Nardelli Permission is hereby granted, free of charge, to any person obtaining a copy @@ -32,8 +32,10 @@ THE SOFTWARE. #include FT_INTERNAL_OBJECTS_H #include FT_GZIP_H #include FT_LZW_H +#include FT_BZIP2_H #include FT_ERRORS_H #include FT_BDF_H +#include FT_TRUETYPE_IDS_H #include "pcf.h" #include "pcfdrivr.h" @@ -81,7 +83,7 @@ THE SOFTWARE. cmap->num_encodings = (FT_UInt)face->nencodings; cmap->encodings = face->encodings; - return PCF_Err_Ok; + return FT_Err_Ok; } @@ -187,7 +189,7 @@ THE SOFTWARE. } - FT_CALLBACK_TABLE_DEF + static const FT_CMap_ClassRec pcf_cmap_class = { sizeof ( PCF_CMapRec ), @@ -216,24 +218,24 @@ THE SOFTWARE. FT_FREE( face->metrics ); /* free properties */ + if ( face->properties ) { - PCF_Property prop; - FT_Int i; + FT_Int i; - if ( face->properties ) + for ( i = 0; i < face->nprops; i++ ) { - for ( i = 0; i < face->nprops; i++ ) - { - prop = &face->properties[i]; + PCF_Property prop = &face->properties[i]; - if ( prop ) { - FT_FREE( prop->name ); - if ( prop->isString ) - FT_FREE( prop->value.atom ); - } + + if ( prop ) + { + FT_FREE( prop->name ); + if ( prop->isString ) + FT_FREE( prop->value.atom ); } } + FT_FREE( face->properties ); } @@ -244,13 +246,11 @@ THE SOFTWARE. FT_FREE( face->charset_encoding ); FT_FREE( face->charset_registry ); - FT_TRACE4(( "PCF_Face_Done: done face\n" )); - - /* close gzip/LZW stream if any */ - if ( pcfface->stream == &face->gzip_stream ) + /* close compressed stream if any */ + if ( pcfface->stream == &face->comp_stream ) { - FT_Stream_Close( &face->gzip_stream ); - pcfface->stream = face->gzip_source; + FT_Stream_Close( &face->comp_stream ); + pcfface->stream = face->comp_source; } } @@ -263,20 +263,22 @@ THE SOFTWARE. FT_Parameter* params ) { PCF_Face face = (PCF_Face)pcfface; - FT_Error error = PCF_Err_Ok; + FT_Error error; FT_UNUSED( num_params ); FT_UNUSED( params ); - FT_UNUSED( face_index ); + FT_TRACE2(( "PCF driver\n" )); + error = pcf_load_font( stream, face ); if ( error ) { PCF_Face_Done( pcfface ); -#if defined( FT_CONFIG_OPTION_USE_ZLIB ) || \ - defined( FT_CONFIG_OPTION_USE_LZW ) +#if defined( FT_CONFIG_OPTION_USE_ZLIB ) || \ + defined( FT_CONFIG_OPTION_USE_LZW ) || \ + defined( FT_CONFIG_OPTION_USE_BZIP2 ) #ifdef FT_CONFIG_OPTION_USE_ZLIB { @@ -284,8 +286,8 @@ THE SOFTWARE. /* this didn't work, try gzip support! */ - error2 = FT_Stream_OpenGzip( &face->gzip_stream, stream ); - if ( FT_ERROR_BASE( error2 ) == FT_Err_Unimplemented_Feature ) + error2 = FT_Stream_OpenGzip( &face->comp_stream, stream ); + if ( FT_ERR_EQ( error2, Unimplemented_Feature ) ) goto Fail; error = error2; @@ -299,19 +301,34 @@ THE SOFTWARE. /* this didn't work, try LZW support! */ - error3 = FT_Stream_OpenLZW( &face->gzip_stream, stream ); - if ( FT_ERROR_BASE( error3 ) == FT_Err_Unimplemented_Feature ) + error3 = FT_Stream_OpenLZW( &face->comp_stream, stream ); + if ( FT_ERR_EQ( error3, Unimplemented_Feature ) ) goto Fail; error = error3; } #endif /* FT_CONFIG_OPTION_USE_LZW */ +#ifdef FT_CONFIG_OPTION_USE_BZIP2 + if ( error ) + { + FT_Error error4; + + + /* this didn't work, try Bzip2 support! */ + error4 = FT_Stream_OpenBzip2( &face->comp_stream, stream ); + if ( FT_ERR_EQ( error4, Unimplemented_Feature ) ) + goto Fail; + + error = error4; + } +#endif /* FT_CONFIG_OPTION_USE_BZIP2 */ + if ( error ) goto Fail; - face->gzip_source = stream; - pcfface->stream = &face->gzip_stream; + face->comp_source = stream; + pcfface->stream = &face->comp_stream; stream = pcfface->stream; @@ -319,13 +336,27 @@ THE SOFTWARE. if ( error ) goto Fail; -#else /* !(FT_CONFIG_OPTION_USE_ZLIB || FT_CONFIG_OPTION_USE_LZW) */ +#else /* !(FT_CONFIG_OPTION_USE_ZLIB || + FT_CONFIG_OPTION_USE_LZW || + FT_CONFIG_OPTION_USE_BZIP2) */ goto Fail; #endif } + /* PCF could not have multiple face in single font file. + * XXX: non-zero face_index is already invalid argument, but + * Type1, Type42 driver has a convention to return + * an invalid argument error when the font could be + * opened by the specified driver. + */ + if ( face_index > 0 ) { + FT_ERROR(( "PCF_Face_Init: invalid face index\n" )); + PCF_Face_Done( pcfface ); + return FT_THROW( Invalid_Argument ); + } + /* set up charmap */ { FT_String *charset_registry = face->charset_registry; @@ -358,14 +389,15 @@ THE SOFTWARE. charmap.face = FT_FACE( face ); charmap.encoding = FT_ENCODING_NONE; - charmap.platform_id = 0; - charmap.encoding_id = 0; + /* initial platform/encoding should indicate unset status? */ + charmap.platform_id = TT_PLATFORM_APPLE_UNICODE; + charmap.encoding_id = TT_APPLE_ID_DEFAULT; if ( unicode_charmap ) { charmap.encoding = FT_ENCODING_UNICODE; - charmap.platform_id = 3; - charmap.encoding_id = 1; + charmap.platform_id = TT_PLATFORM_MICROSOFT; + charmap.encoding_id = TT_MS_ID_UNICODE_CS; } error = FT_CMap_New( &pcf_cmap_class, NULL, &charmap, NULL ); @@ -382,9 +414,9 @@ THE SOFTWARE. return error; Fail: - FT_TRACE2(( "[not a valid PCF file]\n" )); + FT_TRACE2(( " not a PCF file\n" )); PCF_Face_Done( pcfface ); - error = PCF_Err_Unknown_File_Format; /* error */ + error = FT_THROW( Unknown_File_Format ); /* error */ goto Exit; } @@ -402,7 +434,7 @@ THE SOFTWARE. size->metrics.descender = -accel->fontDescent << 6; size->metrics.max_advance = accel->maxbounds.characterWidth << 6; - return PCF_Err_Ok; + return FT_Err_Ok; } @@ -412,7 +444,7 @@ THE SOFTWARE. { PCF_Face face = (PCF_Face)size->face; FT_Bitmap_Size* bsize = size->face->available_sizes; - FT_Error error = PCF_Err_Invalid_Pixel_Size; + FT_Error error = FT_ERR( Invalid_Pixel_Size ); FT_Long height; @@ -423,17 +455,17 @@ THE SOFTWARE. { case FT_SIZE_REQUEST_TYPE_NOMINAL: if ( height == ( ( bsize->y_ppem + 32 ) >> 6 ) ) - error = PCF_Err_Ok; + error = FT_Err_Ok; break; case FT_SIZE_REQUEST_TYPE_REAL_DIM: if ( height == ( face->accel.fontAscent + face->accel.fontDescent ) ) - error = PCF_Err_Ok; + error = FT_Err_Ok; break; default: - error = PCF_Err_Unimplemented_Feature; + error = FT_THROW( Unimplemented_Feature ); break; } @@ -452,7 +484,7 @@ THE SOFTWARE. { PCF_Face face = (PCF_Face)FT_SIZE_FACE( size ); FT_Stream stream; - FT_Error error = PCF_Err_Ok; + FT_Error error = FT_Err_Ok; FT_Bitmap* bitmap = &slot->bitmap; PCF_Metric metric; FT_Offset bytes; @@ -460,11 +492,17 @@ THE SOFTWARE. FT_UNUSED( load_flags ); - FT_TRACE4(( "load_glyph %d ---", glyph_index )); + FT_TRACE1(( "PCF_Glyph_Load: glyph index %d\n", glyph_index )); - if ( !face || glyph_index >= (FT_UInt)face->root.num_glyphs ) + if ( !face ) { - error = PCF_Err_Invalid_Argument; + error = FT_THROW( Invalid_Face_Handle ); + goto Exit; + } + + if ( glyph_index >= (FT_UInt)face->root.num_glyphs ) + { + error = FT_THROW( Invalid_Argument ); goto Exit; } @@ -504,13 +542,13 @@ THE SOFTWARE. break; default: - return PCF_Err_Invalid_File_Format; + return FT_THROW( Invalid_File_Format ); } /* XXX: to do: are there cases that need repadding the bitmap? */ bytes = bitmap->pitch * bitmap->rows; - error = ft_glyphslot_alloc_bitmap( slot, bytes ); + error = ft_glyphslot_alloc_bitmap( slot, (FT_ULong)bytes ); if ( error ) goto Exit; @@ -554,8 +592,6 @@ THE SOFTWARE. ( face->accel.fontAscent + face->accel.fontDescent ) << 6 ); - FT_TRACE4(( " --- ok\n" )); - Exit: return error; } @@ -600,7 +636,7 @@ THE SOFTWARE. return 0; } - return PCF_Err_Invalid_Argument; + return FT_THROW( Invalid_Argument ); } @@ -661,8 +697,8 @@ THE SOFTWARE. 0, - 0, - 0, + 0, /* FT_Module_Constructor */ + 0, /* FT_Module_Destructor */ pcf_driver_requester }, @@ -677,10 +713,6 @@ THE SOFTWARE. 0, /* FT_Slot_InitFunc */ 0, /* FT_Slot_DoneFunc */ -#ifdef FT_CONFIG_OPTION_OLD_INTERNALS - ft_stub_set_char_sizes, - ft_stub_set_pixel_sizes, -#endif PCF_Glyph_Load, 0, /* FT_Face_GetKerningFunc */ -- cgit v1.2.3