diff options
Diffstat (limited to 'src/3rdparty/freetype/src/base/ftobjs.c')
-rw-r--r-- | src/3rdparty/freetype/src/base/ftobjs.c | 166 |
1 files changed, 132 insertions, 34 deletions
diff --git a/src/3rdparty/freetype/src/base/ftobjs.c b/src/3rdparty/freetype/src/base/ftobjs.c index 086237a79d..46bcd3bb8b 100644 --- a/src/3rdparty/freetype/src/base/ftobjs.c +++ b/src/3rdparty/freetype/src/base/ftobjs.c @@ -4,7 +4,8 @@ /* */ /* The FreeType private base classes (body). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, */ +/* 2010 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -37,7 +38,9 @@ #include FT_SERVICE_KERNING_H #include FT_SERVICE_TRUETYPE_ENGINE_H +#ifdef FT_CONFIG_OPTION_MAC_FONTS #include "ftbase.h" +#endif #define GRID_FIT_METRICS @@ -348,7 +351,7 @@ /* free bitmap buffer if needed */ ft_glyphslot_free_bitmap( slot ); - /* slot->internal might be 0 in out-of-memory situations */ + /* slot->internal might be NULL in out-of-memory situations */ if ( slot->internal ) { /* free glyph loader */ @@ -592,27 +595,29 @@ * Determine whether we need to auto-hint or not. * The general rules are: * - * - Do only auto-hinting if we have a hinter module, - * a scalable font format dealing with outlines, - * and no transforms except simple slants. + * - Do only auto-hinting if we have a hinter module, a scalable font + * format dealing with outlines, and no transforms except simple + * slants and/or rotations by integer multiples of 90 degrees. * - * - Then, autohint if FT_LOAD_FORCE_AUTOHINT is set - * or if we don't have a native font hinter. + * - Then, auto-hint if FT_LOAD_FORCE_AUTOHINT is set or if we don't + * have a native font hinter. * * - Otherwise, auto-hint for LIGHT hinting mode. * - * - Exception: The font is `tricky' and requires - * the native hinter to load properly. + * - Exception: The font is `tricky' and requires the native hinter to + * load properly. */ - if ( hinter && - !( load_flags & FT_LOAD_NO_HINTING ) && - !( load_flags & FT_LOAD_NO_AUTOHINT ) && - FT_DRIVER_IS_SCALABLE( driver ) && - FT_DRIVER_USES_OUTLINES( driver ) && - !FT_IS_TRICKY( face ) && - face->internal->transform_matrix.yy > 0 && - face->internal->transform_matrix.yx == 0 ) + if ( hinter && + !( load_flags & FT_LOAD_NO_HINTING ) && + !( load_flags & FT_LOAD_NO_AUTOHINT ) && + FT_DRIVER_IS_SCALABLE( driver ) && + FT_DRIVER_USES_OUTLINES( driver ) && + !FT_IS_TRICKY( face ) && + ( ( face->internal->transform_matrix.yx == 0 && + face->internal->transform_matrix.xx != 0 ) || + ( face->internal->transform_matrix.xx == 0 && + face->internal->transform_matrix.yx != 0 ) ) ) { if ( ( load_flags & FT_LOAD_FORCE_AUTOHINT ) || !FT_DRIVER_HAS_HINTER( driver ) ) @@ -706,8 +711,8 @@ } /* compute the linear advance in 16.16 pixels */ - if ( ( load_flags & FT_LOAD_LINEAR_DESIGN ) == 0 && - ( FT_IS_SCALABLE( face ) ) ) + if ( ( load_flags & FT_LOAD_LINEAR_DESIGN ) == 0 && + ( FT_IS_SCALABLE( face ) ) ) { FT_Size_Metrics* metrics = &face->size->metrics; @@ -737,11 +742,30 @@ renderer, slot, &internal->transform_matrix, &internal->transform_delta ); + else if ( slot->format == FT_GLYPH_FORMAT_OUTLINE ) + { + /* apply `standard' transformation if no renderer is available */ + if ( &internal->transform_matrix ) + FT_Outline_Transform( &slot->outline, + &internal->transform_matrix ); + + if ( &internal->transform_delta ) + FT_Outline_Translate( &slot->outline, + internal->transform_delta.x, + internal->transform_delta.y ); + } + /* transform advance */ FT_Vector_Transform( &slot->advance, &internal->transform_matrix ); } } + FT_TRACE5(( " x advance: %d\n" , slot->advance.x )); + FT_TRACE5(( " y advance: %d\n" , slot->advance.y )); + + FT_TRACE5(( " linear x advance: %d\n" , slot->linearHoriAdvance )); + FT_TRACE5(( " linear y advance: %d\n" , slot->linearVertAdvance )); + /* do we need to render the image now? */ if ( !error && slot->format != FT_GLYPH_FORMAT_BITMAP && @@ -1111,7 +1135,7 @@ if ( error ) { destroy_charmaps( face, memory ); - if ( clazz->done_face && face ) + if ( clazz->done_face ) clazz->done_face( face ); FT_FREE( internal ); FT_FREE( face ); @@ -2402,12 +2426,24 @@ ft_synthesize_vertical_metrics( FT_Glyph_Metrics* metrics, FT_Pos advance ) { + FT_Pos height = metrics->height; + + + /* compensate for glyph with bbox above/below the baseline */ + if ( metrics->horiBearingY < 0 ) + { + if ( height < metrics->horiBearingY ) + height = metrics->horiBearingY; + } + else if ( metrics->horiBearingY > 0 ) + height -= metrics->horiBearingY; + /* the factor 1.2 is a heuristical value */ if ( !advance ) - advance = metrics->height * 12 / 10; + advance = height * 12 / 10; - metrics->vertBearingX = -( metrics->width / 2 ); - metrics->vertBearingY = ( advance - metrics->height ) / 2; + metrics->vertBearingX = metrics->horiBearingX - metrics->horiAdvance / 2; + metrics->vertBearingY = ( advance - height ) / 2; metrics->vertAdvance = advance; } @@ -3052,7 +3088,12 @@ FT_CMap cmap = FT_CMAP( face->charmap ); - result = cmap->clazz->char_index( cmap, charcode ); + if ( charcode > 0xFFFFFFFFUL ) + { + FT_TRACE1(( "FT_Get_Char_Index: too large charcode" )); + FT_TRACE1(( " 0x%x is truncated\n", charcode )); + } + result = cmap->clazz->char_index( cmap, (FT_UInt32)charcode ); } return result; } @@ -3132,8 +3173,20 @@ FT_CMap vcmap = FT_CMAP( charmap ); - result = vcmap->clazz->char_var_index( vcmap, ucmap, charcode, - variantSelector ); + if ( charcode > 0xFFFFFFFFUL ) + { + FT_TRACE1(( "FT_Get_Char_Index: too large charcode" )); + FT_TRACE1(( " 0x%x is truncated\n", charcode )); + } + if ( variantSelector > 0xFFFFFFFFUL ) + { + FT_TRACE1(( "FT_Get_Char_Index: too large variantSelector" )); + FT_TRACE1(( " 0x%x is truncated\n", variantSelector )); + } + + result = vcmap->clazz->char_var_index( vcmap, ucmap, + (FT_UInt32)charcode, + (FT_UInt32)variantSelector ); } } @@ -3161,8 +3214,20 @@ FT_CMap vcmap = FT_CMAP( charmap ); - result = vcmap->clazz->char_var_default( vcmap, charcode, - variantSelector ); + if ( charcode > 0xFFFFFFFFUL ) + { + FT_TRACE1(( "FT_Get_Char_Index: too large charcode" )); + FT_TRACE1(( " 0x%x is truncated\n", charcode )); + } + if ( variantSelector > 0xFFFFFFFFUL ) + { + FT_TRACE1(( "FT_Get_Char_Index: too large variantSelector" )); + FT_TRACE1(( " 0x%x is truncated\n", variantSelector )); + } + + result = vcmap->clazz->char_var_default( vcmap, + (FT_UInt32)charcode, + (FT_UInt32)variantSelector ); } } @@ -3217,7 +3282,14 @@ FT_Memory memory = FT_FACE_MEMORY( face ); - result = vcmap->clazz->charvariant_list( vcmap, memory, charcode ); + if ( charcode > 0xFFFFFFFFUL ) + { + FT_TRACE1(( "FT_Get_Char_Index: too large charcode" )); + FT_TRACE1(( " 0x%x is truncated\n", charcode )); + } + + result = vcmap->clazz->charvariant_list( vcmap, memory, + (FT_UInt32)charcode ); } } return result; @@ -3244,8 +3316,14 @@ FT_Memory memory = FT_FACE_MEMORY( face ); + if ( variantSelector > 0xFFFFFFFFUL ) + { + FT_TRACE1(( "FT_Get_Char_Index: too large variantSelector" )); + FT_TRACE1(( " 0x%x is truncated\n", variantSelector )); + } + result = vcmap->clazz->variantchar_list( vcmap, memory, - variantSelector ); + (FT_UInt32)variantSelector ); } } @@ -3295,7 +3373,7 @@ ((FT_Byte*)buffer)[0] = 0; if ( face && - glyph_index <= (FT_UInt)face->num_glyphs && + (FT_Long)glyph_index <= face->num_glyphs && FT_HAS_GLYPH_NAMES( face ) ) { FT_Service_GlyphDict service; @@ -3395,6 +3473,7 @@ FT_ULong *length ) { FT_Service_SFNT_Table service; + FT_ULong offset; if ( !face || !FT_IS_SFNT( face ) ) @@ -3404,7 +3483,7 @@ if ( service == NULL ) return FT_Err_Unimplemented_Feature; - return service->table_info( face, table_index, tag, length ); + return service->table_info( face, table_index, tag, &offset, length ); } @@ -3729,7 +3808,7 @@ while ( renderer ) { error = renderer->render( renderer, slot, render_mode, NULL ); - if ( !error || + if ( !error || FT_ERROR_BASE( error ) != FT_Err_Cannot_Render_Glyph ) break; @@ -4127,6 +4206,13 @@ library->memory = memory; +#ifdef FT_CONFIG_OPTION_PIC + /* initialize position independent code containers */ + error = ft_pic_container_init( library ); + if ( error ) + goto Fail; +#endif + /* allocate the render pool */ library->raster_pool_size = FT_RENDER_POOL_SIZE; #if FT_RENDER_POOL_SIZE > 0 @@ -4134,12 +4220,19 @@ goto Fail; #endif + library->version_major = FREETYPE_MAJOR; + library->version_minor = FREETYPE_MINOR; + library->version_patch = FREETYPE_PATCH; + /* That's ok now */ *alibrary = library; return FT_Err_Ok; Fail: +#ifdef FT_CONFIG_OPTION_PIC + ft_pic_container_destroy( library ); +#endif FT_FREE( library ); return error; } @@ -4220,7 +4313,7 @@ { FT_Done_Face( FT_FACE( faces->head->data ) ); if ( faces->head ) - FT_ERROR(( "FT_Done_Library: failed to free some faces\n" )); + FT_TRACE0(( "FT_Done_Library: failed to free some faces\n" )); } } } @@ -4256,6 +4349,11 @@ FT_FREE( library->raster_pool ); library->raster_pool_size = 0; +#ifdef FT_CONFIG_OPTION_PIC + /* Destroy pic container contents */ + ft_pic_container_destroy( library ); +#endif + FT_FREE( library ); return FT_Err_Ok; } |