From 727dee178a392d20eb050d0c446f2fcc29058fa1 Mon Sep 17 00:00:00 2001 From: Victoria Lease Date: Mon, 10 Jun 2013 13:55:54 -0700 Subject: Update freetype to 5e094c6fb2ddd6e8901a5679e2cbb8fa476a38ee Integrated patches from freetype2 git repository, up to hashval 5e094c6fb2ddd6e8901a5679e2cbb8fa476a38ee, which is post-2.4.12. Most recent commit message from freetype git: [truetype] Improve handling of broken sbit advance widths. Noteworthy patches included: [cff] Add a new Type 2 interpreter and hinter. Add support for color embedded bitmaps (eg. color emoji). Change-Id: Ia8b6a67bc18f841b24f44edf80f81f663185b598 --- src/base/ftobjs.c | 493 +++++++++++++++++++++++++++++++++--------------------- 1 file changed, 304 insertions(+), 189 deletions(-) (limited to 'src/base/ftobjs.c') diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c index 36ee797..ac2a39c 100644 --- a/src/base/ftobjs.c +++ b/src/base/ftobjs.c @@ -4,7 +4,7 @@ /* */ /* The FreeType private base classes (body). */ /* */ -/* Copyright 1996-2012 by */ +/* Copyright 1996-2013 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -29,6 +29,7 @@ #include FT_TRUETYPE_TAGS_H #include FT_TRUETYPE_IDS_H +#include FT_SERVICE_PROPERTIES_H #include FT_SERVICE_SFNT_H #include FT_SERVICE_POSTSCRIPT_NAME_H #include FT_SERVICE_GLYPH_DICT_H @@ -40,6 +41,32 @@ #include "ftbase.h" #endif + +#ifdef FT_DEBUG_LEVEL_TRACE + +#include FT_BITMAP_H + +#if defined( _MSC_VER ) /* Visual C++ (and Intel C++) */ + /* We disable the warning `conversion from XXX to YYY, */ + /* possible loss of data' in order to compile cleanly with */ + /* the maximum level of warnings: `md5.c' is non-FreeType */ + /* code, and it gets used during development builds only. */ +#pragma warning( push ) +#pragma warning( disable : 4244 ) +#endif /* _MSC_VER */ + + /* it's easiest to include `md5.c' directly */ +#define free md5_free /* suppress a shadow warning */ +#include "md5.c" +#undef free + +#if defined( _MSC_VER ) +#pragma warning( pop ) +#endif + +#endif /* FT_DEBUG_LEVEL_TRACE */ + + #define GRID_FIT_METRICS @@ -136,10 +163,10 @@ *astream = 0; if ( !library ) - return FT_Err_Invalid_Library_Handle; + return FT_THROW( Invalid_Library_Handle ); if ( !args ) - return FT_Err_Invalid_Argument; + return FT_THROW( Invalid_Argument ); memory = library->memory; @@ -177,7 +204,7 @@ #endif else - error = FT_Err_Invalid_Argument; + error = FT_THROW( Invalid_Argument ); if ( error ) FT_FREE( stream ); @@ -384,7 +411,7 @@ if ( !face || !face->driver ) - return FT_Err_Invalid_Argument; + return FT_THROW( Invalid_Argument ); driver = face->driver; clazz = driver->clazz; @@ -574,7 +601,7 @@ if ( !face || !face->size || !face->glyph ) - return FT_Err_Invalid_Face_Handle; + return FT_THROW( Invalid_Face_Handle ); /* The validity test for `glyph_index' is performed by the */ /* font drivers. */ @@ -651,7 +678,7 @@ if ( autohint ) { - FT_AutoHinter_Service hinting; + FT_AutoHinter_Interface hinting; /* try to load embedded bitmaps first if available */ @@ -680,7 +707,7 @@ internal->transform_flags = 0; /* load auto-hinted outline */ - hinting = (FT_AutoHinter_Service)hinter->clazz->module_interface; + hinting = (FT_AutoHinter_Interface)hinter->clazz->module_interface; error = hinting->load_glyph( (FT_AutoHinter)hinter, slot, face->size, @@ -814,7 +841,7 @@ if ( !face ) - return FT_Err_Invalid_Face_Handle; + return FT_THROW( Invalid_Face_Handle ); glyph_index = (FT_UInt)char_code; if ( face->charmap ) @@ -965,7 +992,7 @@ first = face->charmaps; if ( !first ) - return FT_Err_Invalid_CharMap_Handle; + return FT_THROW( Invalid_CharMap_Handle ); /* * The original TrueType specification(s) only specified charmap @@ -1043,7 +1070,7 @@ } } - return FT_Err_Invalid_CharMap_Handle; + return FT_THROW( Invalid_CharMap_Handle ); } @@ -1165,7 +1192,7 @@ /* is returned. */ /* no error should happen, but we want to play safe */ - if ( error2 && error2 != FT_Err_Invalid_CharMap_Handle ) + if ( error2 && FT_ERR_NEQ( error2, Invalid_CharMap_Handle ) ) { error = error2; goto Fail; @@ -1206,7 +1233,7 @@ /* test for valid `library' and `aface' delayed to FT_Open_Face() */ if ( !pathname ) - return FT_Err_Invalid_Argument; + return FT_THROW( Invalid_Argument ); args.flags = FT_OPEN_PATHNAME; args.pathname = (char*)pathname; @@ -1232,7 +1259,7 @@ /* test for valid `library' and `face' delayed to FT_Open_Face() */ if ( !file_base ) - return FT_Err_Invalid_Argument; + return FT_THROW( Invalid_Argument ); args.flags = FT_OPEN_MEMORY; args.memory_base = file_base; @@ -1304,10 +1331,10 @@ if ( !library ) - return FT_Err_Invalid_Library_Handle; + return FT_THROW( Invalid_Library_Handle ); if ( !base ) - return FT_Err_Invalid_Argument; + return FT_THROW( Invalid_Argument ); *astream = 0; memory = library->memory; @@ -1421,7 +1448,7 @@ if ( FT_READ_ULONG( tag ) ) return error; if ( tag != TTAG_typ1 ) - return FT_Err_Unknown_File_Format; + return FT_THROW( Unknown_File_Format ); if ( FT_READ_USHORT( numTables ) ) return error; @@ -1458,7 +1485,7 @@ if ( face_index >= 0 && pstable_index == face_index ) return FT_Err_Ok; } - return FT_Err_Table_Missing; + return FT_THROW( Table_Missing ); } @@ -1504,7 +1531,7 @@ error = open_face_from_buffer( library, sfnt_ps, length, - face_index < 0 ? face_index : 0, + FT_MIN( face_index, 0 ), is_sfnt_cid ? "cid" : "type1", aface ); Exit: @@ -1512,7 +1539,7 @@ FT_Error error1; - if ( error == FT_Err_Unknown_File_Format ) + if ( FT_ERR_EQ( error, Unknown_File_Format ) ) { error1 = FT_Stream_Seek( stream, pos ); if ( error1 ) @@ -1540,7 +1567,7 @@ FT_Long face_index, FT_Face *aface ) { - FT_Error error = FT_Err_Cannot_Open_Resource; + FT_Error error = FT_ERR( Cannot_Open_Resource ); FT_Memory memory = library->memory; FT_Byte* pfb_data = NULL; int i, type, flags; @@ -1633,7 +1660,7 @@ pfb_data[pfb_pos++] = 0; } - error = FT_Err_Cannot_Open_Resource; + error = FT_ERR( Cannot_Open_Resource ); if ( pfb_pos > pfb_len || pfb_pos + rlen > pfb_len ) goto Exit2; @@ -1695,7 +1722,7 @@ if ( face_index == -1 ) face_index = 0; if ( face_index >= resource_cnt ) - return FT_Err_Cannot_Open_Resource; + return FT_THROW( Cannot_Open_Resource ); flag_offset = offsets[face_index]; error = FT_Stream_Seek( stream, flag_offset ); @@ -1705,7 +1732,7 @@ if ( FT_READ_LONG( rlen ) ) goto Exit; if ( rlen == -1 ) - return FT_Err_Cannot_Open_Resource; + return FT_THROW( Cannot_Open_Resource ); error = open_face_PS_from_sfnt_stream( library, stream, @@ -1812,7 +1839,7 @@ if ( NULL == stream ) - return FT_Err_Invalid_Stream_Operation; + return FT_THROW( Invalid_Stream_Operation ); error = FT_Stream_Seek( stream, 0 ); if ( error ) @@ -1829,7 +1856,7 @@ header[ 1] > 33 || header[63] != 0 || header[2 + header[1]] != 0 ) - return FT_Err_Unknown_File_Format; + return FT_THROW( Unknown_File_Format ); dlen = ( header[0x53] << 24 ) | ( header[0x54] << 16 ) | @@ -1862,7 +1889,7 @@ #define FT_COMPONENT trace_raccess FT_Memory memory = library->memory; - FT_Error error = FT_Err_Unknown_File_Format; + FT_Error error = FT_ERR( Unknown_File_Format ); int i; char * file_names[FT_RACCESS_N_RULES]; @@ -1901,7 +1928,7 @@ i, args2.pathname, offsets[i] )); error = FT_Stream_New( library, &args2, &stream2 ); - if ( is_darwin_vfs && error == FT_Err_Cannot_Open_Stream ) + if ( is_darwin_vfs && FT_ERR_EQ( error, Cannot_Open_Stream ) ) vfs_rfork_has_no_font = TRUE; if ( error ) @@ -1930,7 +1957,7 @@ /* Caller (load_mac_face) requires FT_Err_Unknown_File_Format. */ if ( error ) - error = FT_Err_Unknown_File_Format; + error = FT_ERR( Unknown_File_Format ); return error; @@ -1959,7 +1986,7 @@ error = IsMacBinary( library, stream, face_index, aface ); - if ( FT_ERROR_BASE( error ) == FT_Err_Unknown_File_Format ) + if ( FT_ERR_EQ( error, Unknown_File_Format ) ) { #undef FT_COMPONENT @@ -1976,9 +2003,9 @@ } - if ( ( FT_ERROR_BASE( error ) == FT_Err_Unknown_File_Format || - FT_ERROR_BASE( error ) == FT_Err_Invalid_Stream_Operation ) && - ( args->flags & FT_OPEN_PATHNAME ) ) + if ( ( FT_ERR_EQ( error, Unknown_File_Format ) || + FT_ERR_EQ( error, Invalid_Stream_Operation ) ) && + ( args->flags & FT_OPEN_PATHNAME ) ) error = load_face_in_embedded_rfork( library, stream, face_index, aface, args ); return error; @@ -2011,7 +2038,7 @@ /* FT_Stream_New() */ if ( ( !aface && face_index >= 0 ) || !args ) - return FT_Err_Invalid_Argument; + return FT_THROW( Invalid_Argument ); external_stream = FT_BOOL( ( args->flags & FT_OPEN_STREAM ) && args->stream ); @@ -2048,18 +2075,19 @@ goto Success; } else - error = FT_Err_Invalid_Handle; + error = FT_THROW( Invalid_Handle ); FT_Stream_Free( stream, external_stream ); goto Fail; } else { + error = FT_ERR( Missing_Module ); + /* check each font driver for an appropriate format */ cur = library->modules; limit = cur + library->num_modules; - for ( ; cur < limit; cur++ ) { /* not all modules are font drivers, so check... */ @@ -2084,7 +2112,7 @@ #ifdef FT_CONFIG_OPTION_MAC_FONTS if ( ft_strcmp( cur[0]->clazz->module_name, "truetype" ) == 0 && - FT_ERROR_BASE( error ) == FT_Err_Table_Missing ) + FT_ERR_EQ( error, Table_Missing ) ) { /* TrueType but essential tables are missing */ if ( FT_Stream_Seek( stream, 0 ) ) @@ -2104,39 +2132,39 @@ } #endif - if ( FT_ERROR_BASE( error ) != FT_Err_Unknown_File_Format ) + if ( FT_ERR_NEQ( error, Unknown_File_Format ) ) goto Fail3; } } - Fail3: - /* If we are on the mac, and we get an FT_Err_Invalid_Stream_Operation */ - /* it may be because we have an empty data fork, so we need to check */ - /* the resource fork. */ - if ( FT_ERROR_BASE( error ) != FT_Err_Cannot_Open_Stream && - FT_ERROR_BASE( error ) != FT_Err_Unknown_File_Format && - FT_ERROR_BASE( error ) != FT_Err_Invalid_Stream_Operation ) - goto Fail2; + Fail3: + /* If we are on the mac, and we get an */ + /* FT_Err_Invalid_Stream_Operation it may be because we have an */ + /* empty data fork, so we need to check the resource fork. */ + if ( FT_ERR_NEQ( error, Cannot_Open_Stream ) && + FT_ERR_NEQ( error, Unknown_File_Format ) && + FT_ERR_NEQ( error, Invalid_Stream_Operation ) ) + goto Fail2; #if !defined( FT_MACINTOSH ) && defined( FT_CONFIG_OPTION_MAC_FONTS ) - error = load_mac_face( library, stream, face_index, aface, args ); - if ( !error ) - { - /* We don't want to go to Success here. We've already done that. */ - /* On the other hand, if we succeeded we still need to close this */ - /* stream (we opened a different stream which extracted the */ - /* interesting information out of this stream here. That stream */ - /* will still be open and the face will point to it). */ - FT_Stream_Free( stream, external_stream ); - return error; - } + error = load_mac_face( library, stream, face_index, aface, args ); + if ( !error ) + { + /* We don't want to go to Success here. We've already done that. */ + /* On the other hand, if we succeeded we still need to close this */ + /* stream (we opened a different stream which extracted the */ + /* interesting information out of this stream here. That stream */ + /* will still be open and the face will point to it). */ + FT_Stream_Free( stream, external_stream ); + return error; + } - if ( FT_ERROR_BASE( error ) != FT_Err_Unknown_File_Format ) - goto Fail2; + if ( FT_ERR_NEQ( error, Unknown_File_Format ) ) + goto Fail2; #endif /* !FT_MACINTOSH && FT_CONFIG_OPTION_MAC_FONTS */ /* no driver is able to handle this format */ - error = FT_Err_Unknown_File_Format; + error = FT_THROW( Unknown_File_Format ); Fail2: FT_Stream_Free( stream, external_stream ); @@ -2258,7 +2286,7 @@ /* test for valid `face' delayed to FT_Attach_Stream() */ if ( !filepathname ) - return FT_Err_Invalid_Argument; + return FT_THROW( Invalid_Argument ); open.stream = NULL; open.flags = FT_OPEN_PATHNAME; @@ -2284,11 +2312,11 @@ /* test for valid `parameters' delayed to FT_Stream_New() */ if ( !face ) - return FT_Err_Invalid_Face_Handle; + return FT_THROW( Invalid_Face_Handle ); driver = face->driver; if ( !driver ) - return FT_Err_Invalid_Driver_Handle; + return FT_THROW( Invalid_Driver_Handle ); error = FT_Stream_New( driver->root.library, parameters, &stream ); if ( error ) @@ -2297,7 +2325,7 @@ /* we implement FT_Attach_Stream in each driver through the */ /* `attach_file' interface */ - error = FT_Err_Unimplemented_Feature; + error = FT_ERR( Unimplemented_Feature ); clazz = driver->clazz; if ( clazz->attach_file ) error = clazz->attach_file( face, stream ); @@ -2334,7 +2362,7 @@ FT_ListNode node; - error = FT_Err_Invalid_Face_Handle; + error = FT_ERR( Invalid_Face_Handle ); if ( face && face->driver ) { face->internal->refcount--; @@ -2380,13 +2408,13 @@ if ( !face ) - return FT_Err_Invalid_Face_Handle; + return FT_THROW( Invalid_Face_Handle ); if ( !asize ) - return FT_Err_Invalid_Size_Handle; + return FT_THROW( Invalid_Size_Handle ); if ( !face->driver ) - return FT_Err_Invalid_Driver_Handle; + return FT_THROW( Invalid_Driver_Handle ); *asize = 0; @@ -2438,15 +2466,15 @@ if ( !size ) - return FT_Err_Invalid_Size_Handle; + return FT_THROW( Invalid_Size_Handle ); face = size->face; if ( !face ) - return FT_Err_Invalid_Face_Handle; + return FT_THROW( Invalid_Face_Handle ); driver = face->driver; if ( !driver ) - return FT_Err_Invalid_Driver_Handle; + return FT_THROW( Invalid_Driver_Handle ); memory = driver->root.memory; @@ -2467,7 +2495,7 @@ destroy_size( memory, size, driver ); } else - error = FT_Err_Invalid_Size_Handle; + error = FT_THROW( Invalid_Size_Handle ); return error; } @@ -2486,11 +2514,11 @@ if ( !FT_HAS_FIXED_SIZES( face ) ) - return FT_Err_Invalid_Face_Handle; + return FT_THROW( Invalid_Face_Handle ); /* FT_Bitmap_Size doesn't provide enough info... */ if ( req->type != FT_SIZE_REQUEST_TYPE_NOMINAL ) - return FT_Err_Unimplemented_Feature; + return FT_THROW( Unimplemented_Feature ); w = FT_REQUEST_WIDTH ( req ); h = FT_REQUEST_HEIGHT( req ); @@ -2513,6 +2541,8 @@ if ( w == FT_PIX_ROUND( bsize->x_ppem ) || ignore_width ) { + FT_TRACE3(( "FT_Match_Size: bitmap strike %d matches\n", i )); + if ( size_index ) *size_index = (FT_ULong)i; @@ -2520,7 +2550,7 @@ } } - return FT_Err_Invalid_Pixel_Size; + return FT_THROW( Invalid_Pixel_Size ); } @@ -2763,10 +2793,10 @@ if ( !face || !FT_HAS_FIXED_SIZES( face ) ) - return FT_Err_Invalid_Face_Handle; + return FT_THROW( Invalid_Face_Handle ); if ( strike_index < 0 || strike_index >= face->num_fixed_sizes ) - return FT_Err_Invalid_Argument; + return FT_THROW( Invalid_Argument ); clazz = face->driver->clazz; @@ -2816,11 +2846,11 @@ if ( !face ) - return FT_Err_Invalid_Face_Handle; + return FT_THROW( Invalid_Face_Handle ); if ( !req || req->width < 0 || req->height < 0 || req->type >= FT_SIZE_REQUEST_TYPE_MAX ) - return FT_Err_Invalid_Argument; + return FT_THROW( Invalid_Argument ); clazz = face->driver->clazz; @@ -2869,9 +2899,6 @@ if ( error ) return error; - FT_TRACE3(( "FT_Request_Size: bitmap strike %lu matched\n", - strike_index )); - return FT_Select_Size( face, (FT_Int)strike_index ); } @@ -2971,10 +2998,10 @@ if ( !face ) - return FT_Err_Invalid_Face_Handle; + return FT_THROW( Invalid_Face_Handle ); if ( !akerning ) - return FT_Err_Invalid_Argument; + return FT_THROW( Invalid_Argument ); driver = face->driver; @@ -3030,14 +3057,14 @@ if ( !face ) - return FT_Err_Invalid_Face_Handle; + return FT_THROW( Invalid_Face_Handle ); if ( !akerning ) - return FT_Err_Invalid_Argument; + return FT_THROW( Invalid_Argument ); FT_FACE_FIND_SERVICE( face, service, KERNING ); if ( !service ) - return FT_Err_Unimplemented_Feature; + return FT_THROW( Unimplemented_Feature ); error = service->get_track( face, point_size, @@ -3059,10 +3086,10 @@ if ( !face ) - return FT_Err_Invalid_Face_Handle; + return FT_THROW( Invalid_Face_Handle ); if ( encoding == FT_ENCODING_NONE ) - return FT_Err_Invalid_Argument; + return FT_THROW( Invalid_Argument ); /* FT_ENCODING_UNICODE is special. We try to find the `best' Unicode */ /* charmap available, i.e., one with UCS-4 characters, if possible. */ @@ -3073,7 +3100,7 @@ cur = face->charmaps; if ( !cur ) - return FT_Err_Invalid_CharMap_Handle; + return FT_THROW( Invalid_CharMap_Handle ); limit = cur + face->num_charmaps; @@ -3095,7 +3122,7 @@ } } - return FT_Err_Invalid_Argument; + return FT_THROW( Invalid_Argument ); } @@ -3110,13 +3137,13 @@ if ( !face ) - return FT_Err_Invalid_Face_Handle; + return FT_THROW( Invalid_Face_Handle ); cur = face->charmaps; if ( !cur ) - return FT_Err_Invalid_CharMap_Handle; + return FT_THROW( Invalid_CharMap_Handle ); if ( FT_Get_CMap_Format( charmap ) == 14 ) - return FT_Err_Invalid_Argument; + return FT_THROW( Invalid_Argument ); limit = cur + face->num_charmaps; @@ -3137,7 +3164,7 @@ return 0; } } - return FT_Err_Invalid_Argument; + return FT_THROW( Invalid_Argument ); } @@ -3176,7 +3203,7 @@ { FT_CMap_Class clazz = cmap->clazz; FT_Face face = cmap->charmap.face; - FT_Memory memory = FT_FACE_MEMORY(face); + FT_Memory memory = FT_FACE_MEMORY( face ); if ( clazz->done ) @@ -3245,7 +3272,7 @@ if ( clazz == NULL || charmap == NULL || charmap->face == NULL ) - return FT_Err_Invalid_Argument; + return FT_THROW( Invalid_Argument ); face = charmap->face; memory = FT_FACE_MEMORY( face ); @@ -3578,7 +3605,7 @@ FT_Pointer buffer, FT_UInt buffer_max ) { - FT_Error error = FT_Err_Invalid_Argument; + FT_Error error = FT_ERR( Invalid_Argument ); /* clean up buffer */ @@ -3667,11 +3694,11 @@ if ( !face || !FT_IS_SFNT( face ) ) - return FT_Err_Invalid_Face_Handle; + return FT_THROW( Invalid_Face_Handle ); FT_FACE_FIND_SERVICE( face, service, SFNT_TABLE ); if ( service == NULL ) - return FT_Err_Unimplemented_Feature; + return FT_THROW( Unimplemented_Feature ); return service->load_table( face, tag, offset, buffer, length ); } @@ -3690,11 +3717,11 @@ if ( !face || !FT_IS_SFNT( face ) ) - return FT_Err_Invalid_Face_Handle; + return FT_THROW( Invalid_Face_Handle ); FT_FACE_FIND_SERVICE( face, service, SFNT_TABLE ); if ( service == NULL ) - return FT_Err_Unimplemented_Feature; + return FT_THROW( Unimplemented_Feature ); return service->table_info( face, table_index, tag, &offset, length ); } @@ -3757,11 +3784,11 @@ if ( size == NULL ) - return FT_Err_Invalid_Argument; + return FT_THROW( Invalid_Argument ); face = size->face; if ( face == NULL || face->driver == NULL ) - return FT_Err_Invalid_Argument; + return FT_THROW( Invalid_Argument ); /* we don't need anything more complex than that; all size objects */ /* are already listed by the face */ @@ -3953,15 +3980,15 @@ if ( !library ) - return FT_Err_Invalid_Library_Handle; + return FT_THROW( Invalid_Library_Handle ); if ( !renderer ) - return FT_Err_Invalid_Argument; + return FT_THROW( Invalid_Argument ); node = FT_List_Find( &library->renderers, renderer ); if ( !node ) { - error = FT_Err_Invalid_Argument; + error = FT_THROW( Invalid_Argument ); goto Exit; } @@ -4019,12 +4046,12 @@ else renderer = FT_Lookup_Renderer( library, slot->format, &node ); - error = FT_Err_Unimplemented_Feature; + error = FT_ERR( Unimplemented_Feature ); while ( renderer ) { error = renderer->render( renderer, slot, render_mode, NULL ); - if ( !error || - FT_ERROR_BASE( error ) != FT_Err_Cannot_Render_Glyph ) + if ( !error || + FT_ERR_NEQ( error, Cannot_Render_Glyph ) ) break; /* FT_Err_Cannot_Render_Glyph is returned if the render mode */ @@ -4044,6 +4071,47 @@ } } +#ifdef FT_DEBUG_LEVEL_TRACE + +#undef FT_COMPONENT +#define FT_COMPONENT trace_bitmap + + /* we convert to a single bitmap format for computing the checksum */ + { + FT_Bitmap bitmap; + FT_Error err; + + + FT_Bitmap_New( &bitmap ); + + err = FT_Bitmap_Convert( library, &slot->bitmap, &bitmap, 1 ); + if ( !err ) + { + MD5_CTX ctx; + unsigned char md5[16]; + int i; + + + MD5_Init( &ctx); + MD5_Update( &ctx, bitmap.buffer, bitmap.rows * bitmap.pitch ); + MD5_Final( md5, &ctx ); + + FT_TRACE3(( "MD5 checksum for %dx%d bitmap:\n" + " ", + bitmap.rows, bitmap.pitch )); + for ( i = 0; i < 16; i++ ) + FT_TRACE3(( "%02X", md5[i] )); + FT_TRACE3(( "\n" )); + } + + FT_Bitmap_Done( library, &bitmap ); + } + +#undef FT_COMPONENT +#define FT_COMPONENT trace_objs + +#endif /* FT_DEBUG_LEVEL_TRACE */ + return error; } @@ -4058,7 +4126,7 @@ if ( !slot || !slot->face ) - return FT_Err_Invalid_Argument; + return FT_THROW( Invalid_Argument ); library = FT_FACE_LIBRARY( slot->face ); @@ -4138,14 +4206,14 @@ FREETYPE_MINOR ) if ( !library ) - return FT_Err_Invalid_Library_Handle; + return FT_THROW( Invalid_Library_Handle ); if ( !clazz ) - return FT_Err_Invalid_Argument; + return FT_THROW( Invalid_Argument ); /* check freetype version */ if ( clazz->module_requires > FREETYPE_VER_FIXED ) - return FT_Err_Invalid_Version; + return FT_THROW( Invalid_Version ); /* look for a module with the same name in the library's table */ for ( nn = 0; nn < library->num_modules; nn++ ) @@ -4155,7 +4223,7 @@ { /* this installed module has the same name, compare their versions */ if ( clazz->module_version <= module->clazz->module_version ) - return FT_Err_Lower_Module_Version; + return FT_THROW( Lower_Module_Version ); /* remove the module from our list, then exit the loop to replace */ /* it by our new version.. */ @@ -4169,7 +4237,7 @@ if ( library->num_modules >= FT_MAX_MODULES ) { - error = FT_Err_Too_Many_Drivers; + error = FT_THROW( Too_Many_Drivers ); goto Exit; } @@ -4301,19 +4369,18 @@ { FT_Pointer result = NULL; + if ( module ) { FT_ASSERT( module->clazz && module->clazz->get_interface ); - /* first, look for the service in the module - */ + /* first, look for the service in the module */ if ( module->clazz->get_interface ) result = module->clazz->get_interface( module, service_id ); if ( result == NULL ) { - /* we didn't find it, look in all other modules then - */ + /* we didn't find it, look in all other modules then */ FT_Library library = module->library; FT_Module* cur = library->modules; FT_Module* limit = cur + library->num_modules; @@ -4349,7 +4416,7 @@ /* try to find the module from the table, then remove it from there */ if ( !library ) - return FT_Err_Invalid_Library_Handle; + return FT_THROW( Invalid_Library_Handle ); if ( module ) { @@ -4378,7 +4445,119 @@ } } } - return FT_Err_Invalid_Driver_Handle; + return FT_THROW( Invalid_Driver_Handle ); + } + + + FT_Error + ft_property_do( FT_Library library, + const FT_String* module_name, + const FT_String* property_name, + void* value, + FT_Bool set ) + { + FT_Module* cur; + FT_Module* limit; + FT_Module_Interface interface; + + FT_Service_Properties service; + +#ifdef FT_DEBUG_LEVEL_ERROR + const FT_String* set_name = "FT_Property_Set"; + const FT_String* get_name = "FT_Property_Get"; + const FT_String* func_name = set ? set_name : get_name; +#endif + + FT_Bool missing_func; + + + if ( !library ) + return FT_THROW( Invalid_Library_Handle ); + + if ( !module_name || !property_name || !value ) + return FT_THROW( Invalid_Argument ); + + cur = library->modules; + limit = cur + library->num_modules; + + /* search module */ + for ( ; cur < limit; cur++ ) + if ( !ft_strcmp( cur[0]->clazz->module_name, module_name ) ) + break; + + if ( cur == limit ) + { + FT_ERROR(( "%s: can't find module `%s'\n", + func_name, module_name )); + return FT_THROW( Missing_Module ); + } + + /* check whether we have a service interface */ + if ( !cur[0]->clazz->get_interface ) + { + FT_ERROR(( "%s: module `%s' doesn't support properties\n", + func_name, module_name )); + return FT_THROW( Unimplemented_Feature ); + } + + /* search property service */ + interface = cur[0]->clazz->get_interface( cur[0], + FT_SERVICE_ID_PROPERTIES ); + if ( !interface ) + { + FT_ERROR(( "%s: module `%s' doesn't support properties\n", + func_name, module_name )); + return FT_THROW( Unimplemented_Feature ); + } + + service = (FT_Service_Properties)interface; + + if ( set ) + missing_func = !service->set_property; + else + missing_func = !service->get_property; + + if ( missing_func ) + { + FT_ERROR(( "%s: property service of module `%s' is broken\n", + func_name, module_name )); + return FT_THROW( Unimplemented_Feature ); + } + + return set ? service->set_property( cur[0], property_name, value ) + : service->get_property( cur[0], property_name, value ); + } + + + /* documentation is in ftmodapi.h */ + + FT_EXPORT_DEF( FT_Error ) + FT_Property_Set( FT_Library library, + const FT_String* module_name, + const FT_String* property_name, + const void* value ) + { + return ft_property_do( library, + module_name, + property_name, + (void*)value, + TRUE ); + } + + + /* documentation is in ftmodapi.h */ + + FT_EXPORT_DEF( FT_Error ) + FT_Property_Get( FT_Library library, + const FT_String* module_name, + const FT_String* property_name, + void* value ) + { + return ft_property_do( library, + module_name, + property_name, + value, + FALSE ); } @@ -4417,7 +4596,7 @@ if ( !memory ) - return FT_Err_Invalid_Argument; + return FT_THROW( Invalid_Argument ); #ifdef FT_DEBUG_LEVEL_ERROR /* init debugging support */ @@ -4504,7 +4683,7 @@ if ( !library ) - return FT_Err_Invalid_Library_Handle; + return FT_THROW( Invalid_Library_Handle ); library->refcount--; if ( library->refcount > 0 ) @@ -4651,70 +4830,6 @@ } -#ifdef FT_CONFIG_OPTION_OLD_INTERNALS - - FT_BASE_DEF( FT_Error ) - ft_stub_set_char_sizes( FT_Size size, - FT_F26Dot6 width, - FT_F26Dot6 height, - FT_UInt horz_res, - FT_UInt vert_res ) - { - FT_Size_RequestRec req; - FT_Driver driver = size->face->driver; - - - if ( driver->clazz->request_size ) - { - req.type = FT_SIZE_REQUEST_TYPE_NOMINAL; - req.width = width; - req.height = height; - - if ( horz_res == 0 ) - horz_res = vert_res; - - if ( vert_res == 0 ) - vert_res = horz_res; - - if ( horz_res == 0 ) - horz_res = vert_res = 72; - - req.horiResolution = horz_res; - req.vertResolution = vert_res; - - return driver->clazz->request_size( size, &req ); - } - - return 0; - } - - - FT_BASE_DEF( FT_Error ) - ft_stub_set_pixel_sizes( FT_Size size, - FT_UInt width, - FT_UInt height ) - { - FT_Size_RequestRec req; - FT_Driver driver = size->face->driver; - - - if ( driver->clazz->request_size ) - { - req.type = FT_SIZE_REQUEST_TYPE_NOMINAL; - req.width = width << 6; - req.height = height << 6; - req.horiResolution = 0; - req.vertResolution = 0; - - return driver->clazz->request_size( size, &req ); - } - - return 0; - } - -#endif /* FT_CONFIG_OPTION_OLD_INTERNALS */ - - /* documentation is in freetype.h */ FT_EXPORT_DEF( FT_Error ) @@ -4726,7 +4841,7 @@ FT_Int *p_arg2, FT_Matrix *p_transform ) { - FT_Error error = FT_Err_Invalid_Argument; + FT_Error error = FT_ERR( Invalid_Argument ); if ( glyph && -- cgit v1.2.3