From 1ee02cd0419021c3d4950af2619da39c6e9c47f0 Mon Sep 17 00:00:00 2001 From: marha Date: Mon, 21 Dec 2009 15:22:51 +0000 Subject: Updated to freetype-2.3.11 --- freetype/src/base/Jamfile | 3 +- freetype/src/base/basepic.c | 83 ++++++++++++++++++++++++ freetype/src/base/basepic.h | 62 ++++++++++++++++++ freetype/src/base/ftadvanc.c | 2 +- freetype/src/base/ftbase.c | 6 +- freetype/src/base/ftbbox.c | 21 +++--- freetype/src/base/ftbitmap.c | 8 ++- freetype/src/base/ftcalc.c | 34 +++++----- freetype/src/base/ftdbgmem.c | 2 +- freetype/src/base/ftgloadr.c | 7 ++ freetype/src/base/ftglyph.c | 21 +++--- freetype/src/base/ftinit.c | 113 ++++++++++++++++++++++++++++---- freetype/src/base/ftnames.c | 94 --------------------------- freetype/src/base/ftobjs.c | 150 +++++++++++++++++++++++++++++++++---------- freetype/src/base/ftpatent.c | 14 ++-- freetype/src/base/ftpic.c | 54 ++++++++++++++++ freetype/src/base/ftrfork.c | 4 +- freetype/src/base/ftsnames.c | 94 +++++++++++++++++++++++++++ freetype/src/base/ftstream.c | 56 ++++++++-------- freetype/src/base/ftstroke.c | 50 ++++++++++++--- freetype/src/base/ftsynth.c | 25 +++++++- freetype/src/base/ftsystem.c | 9 +-- freetype/src/base/fttrigon.c | 10 +-- freetype/src/base/rules.mk | 2 +- 24 files changed, 688 insertions(+), 236 deletions(-) create mode 100644 freetype/src/base/basepic.c create mode 100644 freetype/src/base/basepic.h delete mode 100644 freetype/src/base/ftnames.c create mode 100644 freetype/src/base/ftpic.c create mode 100644 freetype/src/base/ftsnames.c (limited to 'freetype/src/base') diff --git a/freetype/src/base/Jamfile b/freetype/src/base/Jamfile index aba60fbe0..832e8b842 100644 --- a/freetype/src/base/Jamfile +++ b/freetype/src/base/Jamfile @@ -18,8 +18,9 @@ SubDir FT2_TOP $(FT2_SRC_DIR) base ; if $(FT2_MULTI) { _sources = ftadvanc ftcalc ftdbgmem ftgloadr - ftnames ftobjs ftoutln ftrfork + ftobjs ftoutln ftrfork ftsnames ftstream fttrigon ftutil + basepic ftpic ; } else diff --git a/freetype/src/base/basepic.c b/freetype/src/base/basepic.c new file mode 100644 index 000000000..c0bccb695 --- /dev/null +++ b/freetype/src/base/basepic.c @@ -0,0 +1,83 @@ +/***************************************************************************/ +/* */ +/* basepic.c */ +/* */ +/* The FreeType position independent code services for base. */ +/* */ +/* Copyright 2009 by */ +/* Oran Agra and Mickey Gabel. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#include +#include FT_FREETYPE_H +#include FT_INTERNAL_OBJECTS_H +#include "basepic.h" + +#ifdef FT_CONFIG_OPTION_PIC + + /* forward declaration of PIC init functions from ftglyph.c */ + void FT_Init_Class_ft_outline_glyph_class(FT_Glyph_Class*); + void FT_Init_Class_ft_bitmap_glyph_class(FT_Glyph_Class*); + + /* forward declaration of PIC init functions from ftinit.c */ + FT_Error ft_create_default_module_classes(FT_Library); + void ft_destroy_default_module_classes(FT_Library); + + void + ft_base_pic_free( FT_Library library ) + { + FT_PIC_Container* pic_container = &library->pic_container; + FT_Memory memory = library->memory; + if ( pic_container->base ) + { + /* Destroy default module classes (in case FT_Add_Default_Modules was used) */ + ft_destroy_default_module_classes( library ); + + FT_FREE( pic_container->base ); + pic_container->base = NULL; + } + } + + + FT_Error + ft_base_pic_init( FT_Library library ) + { + FT_PIC_Container* pic_container = &library->pic_container; + FT_Error error = FT_Err_Ok; + BasePIC* container; + FT_Memory memory = library->memory; + + /* allocate pointer, clear and set global container pointer */ + if ( FT_ALLOC ( container, sizeof ( *container ) ) ) + return error; + FT_MEM_SET( container, 0, sizeof(*container) ); + pic_container->base = container; + + /* initialize default modules list and pointers */ + error = ft_create_default_module_classes( library ); + if ( error ) + goto Exit; + + /* initialize pointer table - this is how the module usually expects this data */ + FT_Init_Class_ft_outline_glyph_class(&container->ft_outline_glyph_class); + FT_Init_Class_ft_bitmap_glyph_class(&container->ft_bitmap_glyph_class); + +Exit: + if(error) + ft_base_pic_free(library); + return error; + } + + +#endif /* FT_CONFIG_OPTION_PIC */ + + +/* END */ diff --git a/freetype/src/base/basepic.h b/freetype/src/base/basepic.h new file mode 100644 index 000000000..bb1774576 --- /dev/null +++ b/freetype/src/base/basepic.h @@ -0,0 +1,62 @@ +/***************************************************************************/ +/* */ +/* basepic.h */ +/* */ +/* The FreeType position independent code services for base. */ +/* */ +/* Copyright 2009 by */ +/* Oran Agra and Mickey Gabel. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef __BASEPIC_H__ +#define __BASEPIC_H__ + + +FT_BEGIN_HEADER + +#include FT_INTERNAL_PIC_H + +#ifndef FT_CONFIG_OPTION_PIC +#define FT_OUTLINE_GLYPH_CLASS_GET &ft_outline_glyph_class +#define FT_BITMAP_GLYPH_CLASS_GET &ft_bitmap_glyph_class +#define FT_DEFAULT_MODULES_GET ft_default_modules + +#else /* FT_CONFIG_OPTION_PIC */ + +#include FT_GLYPH_H + + typedef struct BasePIC_ + { + FT_Module_Class** default_module_classes; + FT_Glyph_Class ft_outline_glyph_class; + FT_Glyph_Class ft_bitmap_glyph_class; + } BasePIC; + +#define GET_PIC(lib) ((BasePIC*)((lib)->pic_container.base)) +#define FT_OUTLINE_GLYPH_CLASS_GET (&GET_PIC(library)->ft_outline_glyph_class) +#define FT_BITMAP_GLYPH_CLASS_GET (&GET_PIC(library)->ft_bitmap_glyph_class) +#define FT_DEFAULT_MODULES_GET (GET_PIC(library)->default_module_classes) + + void + ft_base_pic_free( FT_Library library ); + + FT_Error + ft_base_pic_init( FT_Library library ); + +#endif /* FT_CONFIG_OPTION_PIC */ + /* */ + +FT_END_HEADER + +#endif /* __BASEPIC_H__ */ + + +/* END */ diff --git a/freetype/src/base/ftadvanc.c b/freetype/src/base/ftadvanc.c index 504f9d230..8ab7fcb92 100644 --- a/freetype/src/base/ftadvanc.c +++ b/freetype/src/base/ftadvanc.c @@ -140,7 +140,7 @@ if ( flags & FT_ADVANCE_FLAG_FAST_ONLY ) return FT_Err_Unimplemented_Feature; - flags |= FT_LOAD_ADVANCE_ONLY; + flags |= (FT_UInt32)FT_LOAD_ADVANCE_ONLY; for ( nn = 0; nn < count; nn++ ) { error = FT_Load_Glyph( face, start + nn, flags ); diff --git a/freetype/src/base/ftbase.c b/freetype/src/base/ftbase.c index d1fe6e608..6a27ea95a 100644 --- a/freetype/src/base/ftbase.c +++ b/freetype/src/base/ftbase.c @@ -4,7 +4,7 @@ /* */ /* Single object library component (body only). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004, 2006, 2007, 2008 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2006, 2007, 2008, 2009 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -20,14 +20,16 @@ #define FT_MAKE_OPTION_SINGLE_OBJECT +#include "ftpic.c" +#include "basepic.c" #include "ftadvanc.c" #include "ftcalc.c" #include "ftdbgmem.c" #include "ftgloadr.c" -#include "ftnames.c" #include "ftobjs.c" #include "ftoutln.c" #include "ftrfork.c" +#include "ftsnames.c" #include "ftstream.c" #include "fttrigon.c" #include "ftutil.c" diff --git a/freetype/src/base/ftbbox.c b/freetype/src/base/ftbbox.c index 532ab1357..8136ccc1e 100644 --- a/freetype/src/base/ftbbox.c +++ b/freetype/src/base/ftbbox.c @@ -29,6 +29,7 @@ #include FT_IMAGE_H #include FT_OUTLINE_H #include FT_INTERNAL_CALC_H +#include FT_INTERNAL_OBJECTS_H typedef struct TBBox_Rec_ @@ -559,6 +560,13 @@ return 0; } +FT_DEFINE_OUTLINE_FUNCS(bbox_interface, + (FT_Outline_MoveTo_Func) BBox_Move_To, + (FT_Outline_LineTo_Func) BBox_Move_To, + (FT_Outline_ConicTo_Func)BBox_Conic_To, + (FT_Outline_CubicTo_Func)BBox_Cubic_To, + 0, 0 + ) /* documentation is in ftbbox.h */ @@ -628,18 +636,13 @@ /* the two boxes are different, now walk over the outline to */ /* get the Bezier arc extrema. */ - static const FT_Outline_Funcs bbox_interface = - { - (FT_Outline_MoveTo_Func) BBox_Move_To, - (FT_Outline_LineTo_Func) BBox_Move_To, - (FT_Outline_ConicTo_Func)BBox_Conic_To, - (FT_Outline_CubicTo_Func)BBox_Cubic_To, - 0, 0 - }; - FT_Error error; TBBox_Rec user; +#ifdef FT_CONFIG_OPTION_PIC + FT_Outline_Funcs bbox_interface; + Init_Class_bbox_interface(&bbox_interface); +#endif user.bbox = bbox; diff --git a/freetype/src/base/ftbitmap.c b/freetype/src/base/ftbitmap.c index 8810cfadf..46fcce613 100644 --- a/freetype/src/base/ftbitmap.c +++ b/freetype/src/base/ftbitmap.c @@ -228,8 +228,12 @@ if ( !bitmap || !bitmap->buffer ) return FT_Err_Invalid_Argument; - xstr = FT_PIX_ROUND( xStrength ) >> 6; - ystr = FT_PIX_ROUND( yStrength ) >> 6; + if ( ( ( FT_PIX_ROUND( xStrength ) >> 6 ) > FT_INT_MAX ) || + ( ( FT_PIX_ROUND( yStrength ) >> 6 ) > FT_INT_MAX ) ) + return FT_Err_Invalid_Argument; + + xstr = (FT_Int)FT_PIX_ROUND( xStrength ) >> 6; + ystr = (FT_Int)FT_PIX_ROUND( yStrength ) >> 6; if ( xstr == 0 && ystr == 0 ) return FT_Err_Ok; diff --git a/freetype/src/base/ftcalc.c b/freetype/src/base/ftcalc.c index 04295a693..3892fabfe 100644 --- a/freetype/src/base/ftcalc.c +++ b/freetype/src/base/ftcalc.c @@ -110,12 +110,12 @@ FT_EXPORT_DEF( FT_Int32 ) FT_Sqrt32( FT_Int32 x ) { - FT_ULong val, root, newroot, mask; + FT_UInt32 val, root, newroot, mask; root = 0; - mask = 0x40000000L; - val = (FT_ULong)x; + mask = (FT_UInt32)0x40000000UL; + val = (FT_UInt32)x; do { @@ -362,6 +362,7 @@ long s; + /* XXX: this function does not allow 64-bit arguments */ if ( a == 0 || b == c ) return a; @@ -377,12 +378,12 @@ FT_Int64 temp, temp2; - ft_multo64( a, b, &temp ); + ft_multo64( (FT_Int32)a, (FT_Int32)b, &temp ); temp2.hi = 0; temp2.lo = (FT_UInt32)(c >> 1); FT_Add64( &temp, &temp2, &temp ); - a = ft_div64by32( temp.hi, temp.lo, c ); + a = ft_div64by32( temp.hi, temp.lo, (FT_Int32)c ); } else a = 0x7FFFFFFFL; @@ -416,8 +417,8 @@ FT_Int64 temp; - ft_multo64( a, b, &temp ); - a = ft_div64by32( temp.hi, temp.lo, c ); + ft_multo64( (FT_Int32)a, (FT_Int32)b, &temp ); + a = ft_div64by32( temp.hi, temp.lo, (FT_Int32)c ); } else a = 0x7FFFFFFFL; @@ -539,13 +540,14 @@ FT_UInt32 q; - s = a; a = FT_ABS( a ); - s ^= b; b = FT_ABS( b ); + /* XXX: this function does not allow 64-bit arguments */ + s = (FT_Int32)a; a = FT_ABS( a ); + s ^= (FT_Int32)b; b = FT_ABS( b ); if ( b == 0 ) { /* check for division by 0 */ - q = 0x7FFFFFFFL; + q = (FT_UInt32)0x7FFFFFFFL; } else if ( ( a >> 16 ) == 0 ) { @@ -562,7 +564,7 @@ temp2.hi = 0; temp2.lo = (FT_UInt32)( b >> 1 ); FT_Add64( &temp, &temp2, &temp ); - q = ft_div64by32( temp.hi, temp.lo, b ); + q = ft_div64by32( temp.hi, temp.lo, (FT_Int32)b ); } return ( s < 0 ? -(FT_Int32)q : (FT_Int32)q ); @@ -840,7 +842,7 @@ FT_Pos out_x, FT_Pos out_y ) { - FT_Int result; + FT_Long result; /* avoid overflow on 16-bit system */ /* deal with the trivial cases quickly */ @@ -889,8 +891,9 @@ FT_Int64 z1, z2; - ft_multo64( in_x, out_y, &z1 ); - ft_multo64( in_y, out_x, &z2 ); + /* XXX: this function does not allow 64-bit arguments */ + ft_multo64( (FT_Int32)in_x, (FT_Int32)out_y, &z1 ); + ft_multo64( (FT_Int32)in_y, (FT_Int32)out_x, &z2 ); if ( z1.hi > z2.hi ) result = +1; @@ -906,7 +909,8 @@ #endif } - return result; + /* XXX: only the sign of return value, +1/0/-1 must be used */ + return (FT_Int)result; } diff --git a/freetype/src/base/ftdbgmem.c b/freetype/src/base/ftdbgmem.c index 8b2a3304f..677f24208 100644 --- a/freetype/src/base/ftdbgmem.c +++ b/freetype/src/base/ftdbgmem.c @@ -421,7 +421,7 @@ "FreeType: %ld bytes of memory leaked in %ld blocks\n", leaks, leak_count ); - printf( "FreeType: No memory leaks detected!\n" ); + printf( "FreeType: no memory leaks detected\n" ); } } diff --git a/freetype/src/base/ftgloadr.c b/freetype/src/base/ftgloadr.c index ab52621ea..ac0010ddd 100644 --- a/freetype/src/base/ftgloadr.c +++ b/freetype/src/base/ftgloadr.c @@ -218,6 +218,9 @@ { new_max = FT_PAD_CEIL( new_max, 8 ); + if ( new_max > FT_OUTLINE_POINTS_MAX ) + return FT_Err_Array_Too_Large; + if ( FT_RENEW_ARRAY( base->points, old_max, new_max ) || FT_RENEW_ARRAY( base->tags, old_max, new_max ) ) goto Exit; @@ -246,6 +249,10 @@ if ( new_max > old_max ) { new_max = FT_PAD_CEIL( new_max, 4 ); + + if ( new_max > FT_OUTLINE_CONTOURS_MAX ) + return FT_Err_Array_Too_Large; + if ( FT_RENEW_ARRAY( base->contours, old_max, new_max ) ) goto Exit; diff --git a/freetype/src/base/ftglyph.c b/freetype/src/base/ftglyph.c index 4130cb110..ef61d45df 100644 --- a/freetype/src/base/ftglyph.c +++ b/freetype/src/base/ftglyph.c @@ -34,6 +34,7 @@ #include FT_BITMAP_H #include FT_INTERNAL_OBJECTS_H +#include "basepic.h" /*************************************************************************/ /* */ @@ -129,9 +130,7 @@ } - FT_CALLBACK_TABLE_DEF - const FT_Glyph_Class ft_bitmap_glyph_class = - { + FT_DEFINE_GLYPH(ft_bitmap_glyph_class, sizeof ( FT_BitmapGlyphRec ), FT_GLYPH_FORMAT_BITMAP, @@ -141,7 +140,7 @@ 0, /* FT_Glyph_TransformFunc */ ft_bitmap_glyph_bbox, 0 /* FT_Glyph_PrepareFunc */ - }; + ) /*************************************************************************/ @@ -255,9 +254,7 @@ } - FT_CALLBACK_TABLE_DEF - const FT_Glyph_Class ft_outline_glyph_class = - { + FT_DEFINE_GLYPH( ft_outline_glyph_class, sizeof ( FT_OutlineGlyphRec ), FT_GLYPH_FORMAT_OUTLINE, @@ -267,7 +264,7 @@ ft_outline_glyph_transform, ft_outline_glyph_bbox, ft_outline_glyph_prepare - }; + ) /*************************************************************************/ @@ -373,11 +370,11 @@ /* if it is a bitmap, that's easy :-) */ if ( slot->format == FT_GLYPH_FORMAT_BITMAP ) - clazz = &ft_bitmap_glyph_class; + clazz = FT_BITMAP_GLYPH_CLASS_GET; /* it it is an outline too */ else if ( slot->format == FT_GLYPH_FORMAT_OUTLINE ) - clazz = &ft_outline_glyph_class; + clazz = FT_OUTLINE_GLYPH_CLASS_GET; else { @@ -533,7 +530,7 @@ clazz = glyph->clazz; /* when called with a bitmap glyph, do nothing and return successfully */ - if ( clazz == &ft_bitmap_glyph_class ) + if ( clazz == FT_BITMAP_GLYPH_CLASS_GET ) goto Exit; if ( !clazz || !clazz->glyph_prepare ) @@ -546,7 +543,7 @@ dummy.format = clazz->glyph_format; /* create result bitmap glyph */ - error = ft_new_glyph( glyph->library, &ft_bitmap_glyph_class, + error = ft_new_glyph( glyph->library, FT_BITMAP_GLYPH_CLASS_GET, (FT_Glyph*)(void*)&bitmap ); if ( error ) goto Exit; diff --git a/freetype/src/base/ftinit.c b/freetype/src/base/ftinit.c index dac30b0d8..ef1350386 100644 --- a/freetype/src/base/ftinit.c +++ b/freetype/src/base/ftinit.c @@ -4,7 +4,7 @@ /* */ /* FreeType initialization layer (body). */ /* */ -/* Copyright 1996-2001, 2002, 2005, 2007 by */ +/* Copyright 1996-2001, 2002, 2005, 2007, 2009 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -42,6 +42,7 @@ #include FT_INTERNAL_OBJECTS_H #include FT_INTERNAL_DEBUG_H #include FT_MODULE_H +#include "basepic.h" /*************************************************************************/ @@ -53,6 +54,8 @@ #undef FT_COMPONENT #define FT_COMPONENT trace_init +#ifndef FT_CONFIG_OPTION_PIC + #undef FT_USE_MODULE #ifdef __cplusplus #define FT_USE_MODULE( type, x ) extern "C" const type x; @@ -74,6 +77,99 @@ 0 }; +#else /* FT_CONFIG_OPTION_PIC */ + +#ifdef __cplusplus +#define FT_EXTERNC extern "C" +#else +#define FT_EXTERNC extern +#endif + + /* declare the module's class creation/destruction functions */ +#undef FT_USE_MODULE +#define FT_USE_MODULE( type, x ) \ + FT_EXTERNC FT_Error FT_Create_Class_##x( FT_Library library, FT_Module_Class** output_class ); \ + FT_EXTERNC void FT_Destroy_Class_##x( FT_Library library, FT_Module_Class* clazz ); + +#include FT_CONFIG_MODULES_H + + + /* count all module classes */ +#undef FT_USE_MODULE +#define FT_USE_MODULE( type, x ) MODULE_CLASS_##x, + + enum { +#include FT_CONFIG_MODULES_H + FT_NUM_MODULE_CLASSES + }; + + /* destroy all module classes */ +#undef FT_USE_MODULE +#define FT_USE_MODULE( type, x ) \ + if ( classes[i] ) { FT_Destroy_Class_##x(library, classes[i]); } \ + i++; \ + + FT_BASE_DEF( void ) + ft_destroy_default_module_classes( FT_Library library ) + { + FT_Module_Class** classes; + FT_Memory memory; + FT_UInt i; + BasePIC* pic_container = library->pic_container.base; + + if ( !pic_container->default_module_classes ) + return; + + memory = library->memory; + classes = pic_container->default_module_classes; + i = 0; + +#include FT_CONFIG_MODULES_H + + FT_FREE( classes ); + pic_container->default_module_classes = 0; + } + + /* initialize all module classes and the pointer table */ +#undef FT_USE_MODULE +#define FT_USE_MODULE( type, x ) \ + error = FT_Create_Class_##x(library, &clazz); \ + if (error) goto Exit; \ + classes[i++] = clazz; + + FT_BASE_DEF( FT_Error ) + ft_create_default_module_classes( FT_Library library ) + { + FT_Error error; + FT_Memory memory; + FT_Module_Class** classes; + FT_Module_Class* clazz; + FT_UInt i; + BasePIC* pic_container = library->pic_container.base; + + memory = library->memory; + pic_container->default_module_classes = 0; + + if ( FT_ALLOC(classes, sizeof(FT_Module_Class*) * (FT_NUM_MODULE_CLASSES + 1) ) ) + return error; + /* initialize all pointers to 0, especially the last one */ + for (i = 0; i < FT_NUM_MODULE_CLASSES; i++) + classes[i] = 0; + classes[FT_NUM_MODULE_CLASSES] = 0; + + i = 0; + +#include FT_CONFIG_MODULES_H + +Exit: + if (error) ft_destroy_default_module_classes( library ); + else pic_container->default_module_classes = classes; + + return error; + } + + +#endif /* FT_CONFIG_OPTION_PIC */ /* documentation is in ftmodapi.h */ @@ -86,16 +182,15 @@ /* test for valid `library' delayed to FT_Add_Module() */ - cur = ft_default_modules; + cur = FT_DEFAULT_MODULES_GET; while ( *cur ) { error = FT_Add_Module( library, *cur ); /* notify errors, but don't stop */ if ( error ) - { - FT_ERROR(( "FT_Add_Default_Module: Cannot install `%s', error = 0x%x\n", - (*cur)->module_name, error )); - } + FT_TRACE0(( "FT_Add_Default_Module:" + " Cannot install `%s', error = 0x%x\n", + (*cur)->module_name, error )); cur++; } } @@ -127,13 +222,7 @@ if ( error ) FT_Done_Memory( memory ); else - { - (*alibrary)->version_major = FREETYPE_MAJOR; - (*alibrary)->version_minor = FREETYPE_MINOR; - (*alibrary)->version_patch = FREETYPE_PATCH; - FT_Add_Default_Modules( *alibrary ); - } return error; } diff --git a/freetype/src/base/ftnames.c b/freetype/src/base/ftnames.c deleted file mode 100644 index 7fde5c40b..000000000 --- a/freetype/src/base/ftnames.c +++ /dev/null @@ -1,94 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftnames.c */ -/* */ -/* Simple interface to access SFNT name tables (which are used */ -/* to hold font names, copyright info, notices, etc.) (body). */ -/* */ -/* This is _not_ used to retrieve glyph names! */ -/* */ -/* Copyright 1996-2001, 2002 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#include -#include FT_SFNT_NAMES_H -#include FT_INTERNAL_TRUETYPE_TYPES_H -#include FT_INTERNAL_STREAM_H - - -#ifdef TT_CONFIG_OPTION_SFNT_NAMES - - - /* documentation is in ftnames.h */ - - FT_EXPORT_DEF( FT_UInt ) - FT_Get_Sfnt_Name_Count( FT_Face face ) - { - return (face && FT_IS_SFNT( face )) ? ((TT_Face)face)->num_names : 0; - } - - - /* documentation is in ftnames.h */ - - FT_EXPORT_DEF( FT_Error ) - FT_Get_Sfnt_Name( FT_Face face, - FT_UInt idx, - FT_SfntName *aname ) - { - FT_Error error = FT_Err_Invalid_Argument; - - - if ( aname && face && FT_IS_SFNT( face ) ) - { - TT_Face ttface = (TT_Face)face; - - - if ( idx < (FT_UInt)ttface->num_names ) - { - TT_NameEntryRec* entry = ttface->name_table.names + idx; - - - /* load name on demand */ - if ( entry->stringLength > 0 && entry->string == NULL ) - { - FT_Memory memory = face->memory; - FT_Stream stream = face->stream; - - - if ( FT_NEW_ARRAY ( entry->string, entry->stringLength ) || - FT_STREAM_SEEK( entry->stringOffset ) || - FT_STREAM_READ( entry->string, entry->stringLength ) ) - { - FT_FREE( entry->string ); - entry->stringLength = 0; - } - } - - aname->platform_id = entry->platformID; - aname->encoding_id = entry->encodingID; - aname->language_id = entry->languageID; - aname->name_id = entry->nameID; - aname->string = (FT_Byte*)entry->string; - aname->string_len = entry->stringLength; - - error = FT_Err_Ok; - } - } - - return error; - } - - -#endif /* TT_CONFIG_OPTION_SFNT_NAMES */ - - -/* END */ diff --git a/freetype/src/base/ftobjs.c b/freetype/src/base/ftobjs.c index 72dea335b..421540c8d 100644 --- a/freetype/src/base/ftobjs.c +++ b/freetype/src/base/ftobjs.c @@ -348,14 +348,18 @@ /* free bitmap buffer if needed */ ft_glyphslot_free_bitmap( slot ); - /* free glyph loader */ - if ( FT_DRIVER_USES_OUTLINES( driver ) ) + /* slot->internal might be NULL in out-of-memory situations */ + if ( slot->internal ) { - FT_GlyphLoader_Done( slot->internal->loader ); - slot->internal->loader = 0; - } + /* free glyph loader */ + if ( FT_DRIVER_USES_OUTLINES( driver ) ) + { + FT_GlyphLoader_Done( slot->internal->loader ); + slot->internal->loader = 0; + } - FT_FREE( slot->internal ); + FT_FREE( slot->internal ); + } } @@ -588,27 +592,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 ) ) @@ -2398,12 +2404,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; } @@ -3048,7 +3066,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; } @@ -3128,8 +3151,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 ); } } @@ -3157,8 +3192,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 ); } } @@ -3213,7 +3260,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; @@ -3240,8 +3294,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 ); } } @@ -3291,7 +3351,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; @@ -3391,6 +3451,7 @@ FT_ULong *length ) { FT_Service_SFNT_Table service; + FT_ULong offset; if ( !face || !FT_IS_SFNT( face ) ) @@ -3400,7 +3461,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 ); } @@ -3725,7 +3786,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; @@ -4123,6 +4184,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 @@ -4130,12 +4198,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; } @@ -4216,7 +4291,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" )); } } } @@ -4252,6 +4327,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; } diff --git a/freetype/src/base/ftpatent.c b/freetype/src/base/ftpatent.c index 9f129d8f0..236d9a674 100644 --- a/freetype/src/base/ftpatent.c +++ b/freetype/src/base/ftpatent.c @@ -103,6 +103,7 @@ } Exit: + FT_UNUSED( error ); FT_FRAME_EXIT(); return result; } @@ -113,7 +114,7 @@ FT_ULong tag ) { FT_Stream stream = face->stream; - FT_Error error; + FT_Error error = FT_Err_Ok; FT_Service_SFNT_Table service; FT_Bool result = FALSE; @@ -122,15 +123,18 @@ if ( service ) { - FT_ULong offset, size; + FT_UInt i = 0; + FT_ULong tag_i = 0, offset_i, length_i; + for ( i = 0; !error && tag_i != tag ; i++ ) + error = service->table_info( face, i, + &tag_i, &offset_i, &length_i ); - error = service->table_info( face, tag, &offset, &size ); if ( error || - FT_STREAM_SEEK( offset ) ) + FT_STREAM_SEEK( offset_i ) ) goto Exit; - result = _tt_check_patents_in_range( stream, size ); + result = _tt_check_patents_in_range( stream, length_i ); } Exit: diff --git a/freetype/src/base/ftpic.c b/freetype/src/base/ftpic.c new file mode 100644 index 000000000..d5271a972 --- /dev/null +++ b/freetype/src/base/ftpic.c @@ -0,0 +1,54 @@ +/***************************************************************************/ +/* */ +/* ftpic.c */ +/* */ +/* The FreeType position independent code services (body). */ +/* */ +/* Copyright 2009 by */ +/* Oran Agra and Mickey Gabel. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#include +#include FT_FREETYPE_H +#include FT_INTERNAL_OBJECTS_H +#include "basepic.h" + +#ifdef FT_CONFIG_OPTION_PIC + + /* documentation is in ftpic.h */ + + FT_BASE_DEF( FT_Error ) + ft_pic_container_init( FT_Library library ) + { + FT_PIC_Container* pic_container = &library->pic_container; + FT_Error error = FT_Err_Ok; + + FT_MEM_SET( pic_container, 0, sizeof(*pic_container) ); + + error = ft_base_pic_init( library ); + if(error) + return error; + + return FT_Err_Ok; + } + + + /* Destroy the contents of the container. */ + FT_BASE_DEF( void ) + ft_pic_container_destroy( FT_Library library ) + { + ft_base_pic_free( library ); + } + +#endif /* FT_CONFIG_OPTION_PIC */ + + +/* END */ diff --git a/freetype/src/base/ftrfork.c b/freetype/src/base/ftrfork.c index d59a07611..133c2de05 100644 --- a/freetype/src/base/ftrfork.c +++ b/freetype/src/base/ftrfork.c @@ -752,9 +752,9 @@ const char *insertion ) { char* new_name; - char* tmp; + const char* tmp; const char* slash; - unsigned new_length; + size_t new_length; FT_Error error = FT_Err_Ok; FT_UNUSED( error ); diff --git a/freetype/src/base/ftsnames.c b/freetype/src/base/ftsnames.c new file mode 100644 index 000000000..3447888ca --- /dev/null +++ b/freetype/src/base/ftsnames.c @@ -0,0 +1,94 @@ +/***************************************************************************/ +/* */ +/* ftsnames.c */ +/* */ +/* Simple interface to access SFNT name tables (which are used */ +/* to hold font names, copyright info, notices, etc.) (body). */ +/* */ +/* This is _not_ used to retrieve glyph names! */ +/* */ +/* Copyright 1996-2001, 2002, 2009 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#include +#include FT_SFNT_NAMES_H +#include FT_INTERNAL_TRUETYPE_TYPES_H +#include FT_INTERNAL_STREAM_H + + +#ifdef TT_CONFIG_OPTION_SFNT_NAMES + + + /* documentation is in ftsnames.h */ + + FT_EXPORT_DEF( FT_UInt ) + FT_Get_Sfnt_Name_Count( FT_Face face ) + { + return ( face && FT_IS_SFNT( face ) ) ? ((TT_Face)face)->num_names : 0; + } + + + /* documentation is in ftsnames.h */ + + FT_EXPORT_DEF( FT_Error ) + FT_Get_Sfnt_Name( FT_Face face, + FT_UInt idx, + FT_SfntName *aname ) + { + FT_Error error = FT_Err_Invalid_Argument; + + + if ( aname && face && FT_IS_SFNT( face ) ) + { + TT_Face ttface = (TT_Face)face; + + + if ( idx < (FT_UInt)ttface->num_names ) + { + TT_NameEntryRec* entry = ttface->name_table.names + idx; + + + /* load name on demand */ + if ( entry->stringLength > 0 && entry->string == NULL ) + { + FT_Memory memory = face->memory; + FT_Stream stream = face->stream; + + + if ( FT_NEW_ARRAY ( entry->string, entry->stringLength ) || + FT_STREAM_SEEK( entry->stringOffset ) || + FT_STREAM_READ( entry->string, entry->stringLength ) ) + { + FT_FREE( entry->string ); + entry->stringLength = 0; + } + } + + aname->platform_id = entry->platformID; + aname->encoding_id = entry->encodingID; + aname->language_id = entry->languageID; + aname->name_id = entry->nameID; + aname->string = (FT_Byte*)entry->string; + aname->string_len = entry->stringLength; + + error = FT_Err_Ok; + } + } + + return error; + } + + +#endif /* TT_CONFIG_OPTION_SFNT_NAMES */ + + +/* END */ diff --git a/freetype/src/base/ftstream.c b/freetype/src/base/ftstream.c index cff67e0e9..b638599db 100644 --- a/freetype/src/base/ftstream.c +++ b/freetype/src/base/ftstream.c @@ -4,7 +4,7 @@ /* */ /* I/O stream support (body). */ /* */ -/* Copyright 2000-2001, 2002, 2004, 2005, 2006, 2008 by */ +/* Copyright 2000-2001, 2002, 2004, 2005, 2006, 2008, 2009 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -60,13 +60,12 @@ FT_Error error = FT_Err_Ok; - stream->pos = pos; - if ( stream->read ) { if ( stream->read( stream, pos, 0, 0 ) ) { - FT_ERROR(( "FT_Stream_Seek: invalid i/o; pos = 0x%lx, size = 0x%lx\n", + FT_ERROR(( "FT_Stream_Seek:" + " invalid i/o; pos = 0x%lx, size = 0x%lx\n", pos, stream->size )); error = FT_Err_Invalid_Stream_Operation; @@ -75,12 +74,16 @@ /* note that seeking to the first position after the file is valid */ else if ( pos > stream->size ) { - FT_ERROR(( "FT_Stream_Seek: invalid i/o; pos = 0x%lx, size = 0x%lx\n", + FT_ERROR(( "FT_Stream_Seek:" + " invalid i/o; pos = 0x%lx, size = 0x%lx\n", pos, stream->size )); error = FT_Err_Invalid_Stream_Operation; } + if ( !error ) + stream->pos = pos; + return error; } @@ -124,7 +127,8 @@ if ( pos >= stream->size ) { - FT_ERROR(( "FT_Stream_ReadAt: invalid i/o; pos = 0x%lx, size = 0x%lx\n", + FT_ERROR(( "FT_Stream_ReadAt:" + " invalid i/o; pos = 0x%lx, size = 0x%lx\n", pos, stream->size )); return FT_Err_Invalid_Stream_Operation; @@ -145,8 +149,8 @@ if ( read_bytes < count ) { - FT_ERROR(( "FT_Stream_ReadAt:" )); - FT_ERROR(( " invalid read; expected %lu bytes, got %lu\n", + FT_ERROR(( "FT_Stream_ReadAt:" + " invalid read; expected %lu bytes, got %lu\n", count, read_bytes )); error = FT_Err_Invalid_Stream_Operation; @@ -211,7 +215,7 @@ FT_Stream_ReleaseFrame( FT_Stream stream, FT_Byte** pbytes ) { - if ( stream->read ) + if ( stream && stream->read ) { FT_Memory memory = stream->memory; @@ -256,8 +260,8 @@ stream->base, count ); if ( read_bytes < count ) { - FT_ERROR(( "FT_Stream_EnterFrame:" )); - FT_ERROR(( " invalid read; expected %lu bytes, got %lu\n", + FT_ERROR(( "FT_Stream_EnterFrame:" + " invalid read; expected %lu bytes, got %lu\n", count, read_bytes )); FT_FREE( stream->base ); @@ -273,8 +277,8 @@ if ( stream->pos >= stream->size || stream->pos + count > stream->size ) { - FT_ERROR(( "FT_Stream_EnterFrame:" )); - FT_ERROR(( " invalid i/o; pos = 0x%lx, count = %lu, size = 0x%lx\n", + FT_ERROR(( "FT_Stream_EnterFrame:" + " invalid i/o; pos = 0x%lx, count = %lu, size = 0x%lx\n", stream->pos, count, stream->size )); error = FT_Err_Invalid_Stream_Operation; @@ -459,7 +463,8 @@ Fail: *error = FT_Err_Invalid_Stream_Operation; - FT_ERROR(( "FT_Stream_ReadChar: invalid i/o; pos = 0x%lx, size = 0x%lx\n", + FT_ERROR(( "FT_Stream_ReadChar:" + " invalid i/o; pos = 0x%lx, size = 0x%lx\n", stream->pos, stream->size )); return 0; @@ -505,8 +510,8 @@ Fail: *error = FT_Err_Invalid_Stream_Operation; - FT_ERROR(( "FT_Stream_ReadShort:" )); - FT_ERROR(( " invalid i/o; pos = 0x%lx, size = 0x%lx\n", + FT_ERROR(( "FT_Stream_ReadShort:" + " invalid i/o; pos = 0x%lx, size = 0x%lx\n", stream->pos, stream->size )); return 0; @@ -552,8 +557,8 @@ Fail: *error = FT_Err_Invalid_Stream_Operation; - FT_ERROR(( "FT_Stream_ReadShortLE:" )); - FT_ERROR(( " invalid i/o; pos = 0x%lx, size = 0x%lx\n", + FT_ERROR(( "FT_Stream_ReadShortLE:" + " invalid i/o; pos = 0x%lx, size = 0x%lx\n", stream->pos, stream->size )); return 0; @@ -599,8 +604,8 @@ Fail: *error = FT_Err_Invalid_Stream_Operation; - FT_ERROR(( "FT_Stream_ReadOffset:" )); - FT_ERROR(( " invalid i/o; pos = 0x%lx, size = 0x%lx\n", + FT_ERROR(( "FT_Stream_ReadOffset:" + " invalid i/o; pos = 0x%lx, size = 0x%lx\n", stream->pos, stream->size )); return 0; @@ -645,9 +650,10 @@ return result; Fail: - FT_ERROR(( "FT_Stream_ReadLong: invalid i/o; pos = 0x%lx, size = 0x%lx\n", - stream->pos, stream->size )); *error = FT_Err_Invalid_Stream_Operation; + FT_ERROR(( "FT_Stream_ReadLong:" + " invalid i/o; pos = 0x%lx, size = 0x%lx\n", + stream->pos, stream->size )); return 0; } @@ -691,10 +697,10 @@ return result; Fail: - FT_ERROR(( "FT_Stream_ReadLongLE:" )); - FT_ERROR(( " invalid i/o; pos = 0x%lx, size = 0x%lx\n", - stream->pos, stream->size )); *error = FT_Err_Invalid_Stream_Operation; + FT_ERROR(( "FT_Stream_ReadLongLE:" + " invalid i/o; pos = 0x%lx, size = 0x%lx\n", + stream->pos, stream->size )); return 0; } diff --git a/freetype/src/base/ftstroke.c b/freetype/src/base/ftstroke.c index 3f5421fa5..0978b0ed9 100644 --- a/freetype/src/base/ftstroke.c +++ b/freetype/src/base/ftstroke.c @@ -706,7 +706,7 @@ FT_Bool valid; FT_StrokeBorderRec borders[2]; - FT_Memory memory; + FT_Library library; } FT_StrokerRec; @@ -729,7 +729,7 @@ if ( !FT_NEW( stroker ) ) { - stroker->memory = memory; + stroker->library = library; ft_stroke_border_init( &stroker->borders[0], memory ); ft_stroke_border_init( &stroker->borders[1], memory ); @@ -777,13 +777,13 @@ { if ( stroker ) { - FT_Memory memory = stroker->memory; + FT_Memory memory = stroker->library->memory; ft_stroke_border_done( &stroker->borders[0] ); ft_stroke_border_done( &stroker->borders[1] ); - stroker->memory = NULL; + stroker->library = NULL; FT_FREE( stroker ); } } @@ -859,6 +859,31 @@ error = ft_stroke_border_lineto( border, &delta, FALSE ); } + else if ( stroker->line_cap == FT_STROKER_LINECAP_BUTT ) + { + /* add a butt ending */ + FT_Vector delta; + FT_Angle rotate = FT_SIDE_TO_ROTATE( side ); + FT_Fixed radius = stroker->radius; + FT_StrokeBorder border = stroker->borders + side; + + + FT_Vector_From_Polar( &delta, radius, angle + rotate ); + + delta.x += stroker->center.x; + delta.y += stroker->center.y; + + error = ft_stroke_border_lineto( border, &delta, FALSE ); + if ( error ) + goto Exit; + + FT_Vector_From_Polar( &delta, radius, angle - rotate ); + + delta.x += stroker->center.x; + delta.y += stroker->center.y; + + error = ft_stroke_border_lineto( border, &delta, FALSE ); + } Exit: return error; @@ -1844,8 +1869,13 @@ return FT_Err_Invalid_Outline; } - +/* declare an extern to access ft_outline_glyph_class global allocated + in ftglyph.c, and use the FT_OUTLINE_GLYPH_CLASS_GET macro to access + it when FT_CONFIG_OPTION_PIC is defined */ +#ifndef FT_CONFIG_OPTION_PIC extern const FT_Glyph_Class ft_outline_glyph_class; +#endif +#include "basepic.h" /* documentation is in ftstroke.h */ @@ -1857,13 +1887,14 @@ { FT_Error error = FT_Err_Invalid_Argument; FT_Glyph glyph = NULL; - + FT_Library library = stroker->library; + FT_UNUSED(library); if ( pglyph == NULL ) goto Exit; glyph = *pglyph; - if ( glyph == NULL || glyph->clazz != &ft_outline_glyph_class ) + if ( glyph == NULL || glyph->clazz != FT_OUTLINE_GLYPH_CLASS_GET ) goto Exit; { @@ -1930,13 +1961,14 @@ { FT_Error error = FT_Err_Invalid_Argument; FT_Glyph glyph = NULL; - + FT_Library library = stroker->library; + FT_UNUSED(library); if ( pglyph == NULL ) goto Exit; glyph = *pglyph; - if ( glyph == NULL || glyph->clazz != &ft_outline_glyph_class ) + if ( glyph == NULL || glyph->clazz != FT_OUTLINE_GLYPH_CLASS_GET ) goto Exit; { diff --git a/freetype/src/base/ftsynth.c b/freetype/src/base/ftsynth.c index 443d27260..326d8e73e 100644 --- a/freetype/src/base/ftsynth.c +++ b/freetype/src/base/ftsynth.c @@ -18,11 +18,21 @@ #include #include FT_SYNTHESIS_H +#include FT_INTERNAL_DEBUG_H #include FT_INTERNAL_OBJECTS_H #include FT_OUTLINE_H #include FT_BITMAP_H + /*************************************************************************/ + /* */ + /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ + /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ + /* messages during execution. */ + /* */ +#undef FT_COMPONENT +#define FT_COMPONENT trace_synth + /*************************************************************************/ /*************************************************************************/ /**** ****/ @@ -106,6 +116,18 @@ xstr = 1 << 6; ystr &= ~63; + /* + * XXX: overflow check for 16-bit system, for compatibility + * with FT_GlyphSlot_Embolden() since freetype-2.1.10. + * unfortunately, this function return no informations + * about the cause of error. + */ + if ( ( ystr >> 6 ) > FT_INT_MAX || ( ystr >> 6 ) < FT_INT_MIN ) + { + FT_TRACE1(( "FT_GlyphSlot_Embolden:" )); + FT_TRACE1(( "too strong embolding parameter ystr=%d\n", ystr )); + return; + } error = FT_GlyphSlot_Own_Bitmap( slot ); if ( error ) return; @@ -129,8 +151,9 @@ slot->metrics.vertBearingY += ystr; slot->metrics.vertAdvance += ystr; + /* XXX: 16-bit overflow case must be excluded before here */ if ( slot->format == FT_GLYPH_FORMAT_BITMAP ) - slot->bitmap_top += ystr >> 6; + slot->bitmap_top += (FT_Int)( ystr >> 6 ); } diff --git a/freetype/src/base/ftsystem.c b/freetype/src/base/ftsystem.c index f64908fd2..4d06d6db5 100644 --- a/freetype/src/base/ftsystem.c +++ b/freetype/src/base/ftsystem.c @@ -4,7 +4,7 @@ /* */ /* ANSI-specific FreeType low-level system interface (body). */ /* */ -/* Copyright 1996-2001, 2002, 2006, 2008 by */ +/* Copyright 1996-2001, 2002, 2006, 2008, 2009 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -205,7 +205,8 @@ file = STREAM_FILE( stream ); - ft_fseek( file, offset, SEEK_SET ); + if ( stream->pos != offset ) + ft_fseek( file, offset, SEEK_SET ); return (unsigned long)ft_fread( buffer, 1, count, file ); } @@ -226,8 +227,8 @@ file = ft_fopen( filepathname, "rb" ); if ( !file ) { - FT_ERROR(( "FT_Stream_Open:" )); - FT_ERROR(( " could not open `%s'\n", filepathname )); + FT_ERROR(( "FT_Stream_Open:" + " could not open `%s'\n", filepathname )); return FT_Err_Cannot_Open_Resource; } diff --git a/freetype/src/base/fttrigon.c b/freetype/src/base/fttrigon.c index 9f513946b..fdf433ab8 100644 --- a/freetype/src/base/fttrigon.c +++ b/freetype/src/base/fttrigon.c @@ -72,10 +72,10 @@ val = ( val >= 0 ) ? val : -val; v1 = (FT_UInt32)val >> 16; - v2 = (FT_UInt32)val & 0xFFFFL; + v2 = (FT_UInt32)(val & 0xFFFFL); - k1 = FT_TRIG_SCALE >> 16; /* constant */ - k2 = FT_TRIG_SCALE & 0xFFFFL; /* constant */ + k1 = (FT_UInt32)FT_TRIG_SCALE >> 16; /* constant */ + k2 = (FT_UInt32)(FT_TRIG_SCALE & 0xFFFFL); /* constant */ hi = k1 * v1; lo1 = k1 * v2 + k2 * v1; /* can't overflow */ @@ -86,7 +86,7 @@ hi += lo1 >> 16; if ( lo1 < lo3 ) - hi += 0x10000UL; + hi += (FT_UInt32)0x10000UL; val = (FT_Fixed)hi; @@ -433,7 +433,7 @@ if ( shift > 0 ) { - FT_Int32 half = 1L << ( shift - 1 ); + FT_Int32 half = (FT_Int32)1L << ( shift - 1 ); vec->x = ( v.x + half + FT_SIGN_LONG( v.x ) ) >> shift; diff --git a/freetype/src/base/rules.mk b/freetype/src/base/rules.mk index 66260e677..10f578abc 100644 --- a/freetype/src/base/rules.mk +++ b/freetype/src/base/rules.mk @@ -37,10 +37,10 @@ BASE_SRC := $(BASE_DIR)/ftadvanc.c \ $(BASE_DIR)/ftcalc.c \ $(BASE_DIR)/ftdbgmem.c \ $(BASE_DIR)/ftgloadr.c \ - $(BASE_DIR)/ftnames.c \ $(BASE_DIR)/ftobjs.c \ $(BASE_DIR)/ftoutln.c \ $(BASE_DIR)/ftrfork.c \ + $(BASE_DIR)/ftsnames.c \ $(BASE_DIR)/ftstream.c \ $(BASE_DIR)/fttrigon.c \ $(BASE_DIR)/ftutil.c -- cgit v1.2.3