diff options
Diffstat (limited to 'src')
79 files changed, 1064 insertions, 680 deletions
diff --git a/src/autofit/afcjk.c b/src/autofit/afcjk.c index 0acef9c..8e407c8 100644 --- a/src/autofit/afcjk.c +++ b/src/autofit/afcjk.c @@ -4,7 +4,7 @@ /* */ /* Auto-fitter hinting routines for CJK script (body). */ /* */ -/* Copyright 2006-2011 by */ +/* Copyright 2006-2012 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -1610,7 +1610,7 @@ goto Exit; } - offset = cur_len % 64; + offset = cur_len & 63; if ( offset < 32 ) { @@ -2225,11 +2225,11 @@ }; - AF_DEFINE_SCRIPT_CLASS(af_cjk_script_class, + AF_DEFINE_SCRIPT_CLASS( af_cjk_script_class, AF_SCRIPT_CJK, af_cjk_uniranges, - sizeof( AF_CJKMetricsRec ), + sizeof ( AF_CJKMetricsRec ), (AF_Script_InitMetricsFunc) af_cjk_metrics_init, (AF_Script_ScaleMetricsFunc)af_cjk_metrics_scale, @@ -2247,11 +2247,11 @@ }; - AF_DEFINE_SCRIPT_CLASS(af_cjk_script_class, + AF_DEFINE_SCRIPT_CLASS( af_cjk_script_class, AF_SCRIPT_CJK, af_cjk_uniranges, - sizeof( AF_CJKMetricsRec ), + sizeof ( AF_CJKMetricsRec ), (AF_Script_InitMetricsFunc) NULL, (AF_Script_ScaleMetricsFunc)NULL, diff --git a/src/autofit/afdummy.c b/src/autofit/afdummy.c index c712651..4bf278c 100644 --- a/src/autofit/afdummy.c +++ b/src/autofit/afdummy.c @@ -47,7 +47,7 @@ AF_SCRIPT_NONE, NULL, - sizeof( AF_ScriptMetricsRec ), + sizeof ( AF_ScriptMetricsRec ), (AF_Script_InitMetricsFunc) NULL, (AF_Script_ScaleMetricsFunc)NULL, diff --git a/src/autofit/aferrors.h b/src/autofit/aferrors.h index c2ed5fe..50e1a22 100644 --- a/src/autofit/aferrors.h +++ b/src/autofit/aferrors.h @@ -4,7 +4,7 @@ /* */ /* Autofitter error codes (specification only). */ /* */ -/* Copyright 2005 by */ +/* Copyright 2005, 2012 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -30,6 +30,7 @@ #undef __FTERRORS_H__ +#undef FT_ERR_PREFIX #define FT_ERR_PREFIX AF_Err_ #define FT_ERR_BASE FT_Mod_Err_Autofit diff --git a/src/autofit/afglobal.c b/src/autofit/afglobal.c index 3c5f02e..3e0c02d 100644 --- a/src/autofit/afglobal.c +++ b/src/autofit/afglobal.c @@ -43,7 +43,7 @@ #endif &af_latin_script_class, &af_cjk_script_class, - &af_indic_script_class, + &af_indic_script_class, NULL /* do not remove */ }; diff --git a/src/autofit/afindic.c b/src/autofit/afindic.c index c232cff..9c74838 100644 --- a/src/autofit/afindic.c +++ b/src/autofit/afindic.c @@ -113,11 +113,11 @@ }; - AF_DEFINE_SCRIPT_CLASS(af_indic_script_class, + AF_DEFINE_SCRIPT_CLASS( af_indic_script_class, AF_SCRIPT_INDIC, af_indic_uniranges, - sizeof( AF_CJKMetricsRec ), + sizeof ( AF_CJKMetricsRec ), (AF_Script_InitMetricsFunc) af_indic_metrics_init, (AF_Script_ScaleMetricsFunc)af_indic_metrics_scale, @@ -135,11 +135,11 @@ }; - AF_DEFINE_SCRIPT_CLASS(af_indic_script_class, + AF_DEFINE_SCRIPT_CLASS( af_indic_script_class, AF_SCRIPT_INDIC, af_indic_uniranges, - sizeof( AF_CJKMetricsRec ), + sizeof ( AF_CJKMetricsRec ), (AF_Script_InitMetricsFunc) NULL, (AF_Script_ScaleMetricsFunc)NULL, diff --git a/src/autofit/aflatin.c b/src/autofit/aflatin.c index 54fcf7f..30145a2 100644 --- a/src/autofit/aflatin.c +++ b/src/autofit/aflatin.c @@ -2341,11 +2341,11 @@ }; - AF_DEFINE_SCRIPT_CLASS(af_latin_script_class, + AF_DEFINE_SCRIPT_CLASS( af_latin_script_class, AF_SCRIPT_LATIN, af_latin_uniranges, - sizeof( AF_LatinMetricsRec ), + sizeof ( AF_LatinMetricsRec ), (AF_Script_InitMetricsFunc) af_latin_metrics_init, (AF_Script_ScaleMetricsFunc)af_latin_metrics_scale, diff --git a/src/autofit/aflatin2.c b/src/autofit/aflatin2.c index 23558b8..ea6af8d 100644 --- a/src/autofit/aflatin2.c +++ b/src/autofit/aflatin2.c @@ -133,7 +133,7 @@ dist = -dist; if ( num_widths < AF_LATIN_MAX_WIDTHS ) - axis->widths[ num_widths++ ].org = dist; + axis->widths[num_widths++].org = dist; } } @@ -1359,10 +1359,10 @@ af_latin2_hints_compute_blue_edges( AF_GlyphHints hints, AF_LatinMetrics metrics ) { - AF_AxisHints axis = &hints->axis[ AF_DIMENSION_VERT ]; + AF_AxisHints axis = &hints->axis[AF_DIMENSION_VERT]; AF_Edge edge = axis->edges; AF_Edge edge_limit = edge + axis->num_edges; - AF_LatinAxis latin = &metrics->axis[ AF_DIMENSION_VERT ]; + AF_LatinAxis latin = &metrics->axis[AF_DIMENSION_VERT]; FT_Fixed scale = latin->scale; FT_Pos best_dist0; /* initial threshold */ @@ -2356,11 +2356,11 @@ }; - AF_DEFINE_SCRIPT_CLASS(af_latin2_script_class, + AF_DEFINE_SCRIPT_CLASS( af_latin2_script_class, AF_SCRIPT_LATIN2, af_latin2_uniranges, - sizeof( AF_LatinMetricsRec ), + sizeof ( AF_LatinMetricsRec ), (AF_Script_InitMetricsFunc) af_latin2_metrics_init, (AF_Script_ScaleMetricsFunc)af_latin2_metrics_scale, diff --git a/src/autofit/afloader.c b/src/autofit/afloader.c index 966a0df..34ef9d8 100644 --- a/src/autofit/afloader.c +++ b/src/autofit/afloader.c @@ -4,7 +4,7 @@ /* */ /* Auto-fitter glyph loading routines (body). */ /* */ -/* Copyright 2003-2009, 2011 by */ +/* Copyright 2003-2009, 2011-2012 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -433,9 +433,10 @@ slot->metrics.horiAdvance = FT_MulFix( slot->metrics.horiAdvance, x_scale ); #else - if ( FT_IS_FIXED_WIDTH( slot->face ) || - ( af_face_globals_is_digit( loader->globals, glyph_index ) && - metrics->digits_have_same_width ) ) + if ( scaler->render_mode != FT_RENDER_MODE_LIGHT && + ( FT_IS_FIXED_WIDTH( slot->face ) || + ( af_face_globals_is_digit( loader->globals, glyph_index ) && + metrics->digits_have_same_width ) ) ) { slot->metrics.horiAdvance = FT_MulFix( slot->metrics.horiAdvance, metrics->scaler.x_scale ); @@ -465,7 +466,13 @@ if ( error ) goto Exit; - slot->outline = internal->loader->base.outline; + /* reassign all outline fields except flags to protect them */ + slot->outline.n_contours = internal->loader->base.outline.n_contours; + slot->outline.n_points = internal->loader->base.outline.n_points; + slot->outline.points = internal->loader->base.outline.points; + slot->outline.tags = internal->loader->base.outline.tags; + slot->outline.contours = internal->loader->base.outline.contours; + slot->format = FT_GLYPH_FORMAT_OUTLINE; } @@ -480,7 +487,7 @@ af_loader_load_glyph( AF_Loader loader, FT_Face face, FT_UInt gindex, - FT_UInt32 load_flags ) + FT_Int32 load_flags ) { FT_Error error; FT_Size size = face->size; diff --git a/src/autofit/afloader.h b/src/autofit/afloader.h index 3f91e1a..eec0e92 100644 --- a/src/autofit/afloader.h +++ b/src/autofit/afloader.h @@ -4,7 +4,7 @@ /* */ /* Auto-fitter glyph loading routines (specification). */ /* */ -/* Copyright 2003-2005, 2011 by */ +/* Copyright 2003-2005, 2011-2012 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -60,7 +60,7 @@ FT_BEGIN_HEADER af_loader_load_glyph( AF_Loader loader, FT_Face face, FT_UInt gindex, - FT_UInt32 load_flags ); + FT_Int32 load_flags ); /* */ diff --git a/src/autofit/afpic.c b/src/autofit/afpic.c index 3aefbc5..87074af 100644 --- a/src/autofit/afpic.c +++ b/src/autofit/afpic.c @@ -20,16 +20,20 @@ #include FT_FREETYPE_H #include FT_INTERNAL_OBJECTS_H #include "afpic.h" +#include "aferrors.h" #ifdef FT_CONFIG_OPTION_PIC /* forward declaration of PIC init functions from afmodule.c */ - void FT_Init_Class_af_autofitter_service( FT_Library, - FT_AutoHinter_ServiceRec* ); + void FT_Init_Class_af_autofitter_service( + FT_Library library, + FT_AutoHinter_ServiceRec* clazz ); /* forward declaration of PIC init functions from script classes */ #include "aflatin.h" +#ifdef FT_OPTION_AUTOFIT2 #include "aflatin2.h" +#endif #include "afcjk.h" #include "afdummy.h" #include "afindic.h" @@ -73,7 +77,7 @@ &container->af_script_classes_rec[ss]; } container->af_script_classes[AF_SCRIPT_CLASSES_COUNT - 1] = NULL; - + /* add call to initialization function when you add new scripts */ ss = 0; FT_Init_Class_af_dummy_script_class( diff --git a/src/autofit/afpic.h b/src/autofit/afpic.h index c1632e7..21b0ff9 100644 --- a/src/autofit/afpic.h +++ b/src/autofit/afpic.h @@ -19,7 +19,7 @@ #ifndef __AFPIC_H__ #define __AFPIC_H__ - + FT_BEGIN_HEADER #include FT_INTERNAL_PIC_H @@ -38,9 +38,9 @@ FT_BEGIN_HEADER #ifdef FT_OPTION_AUTOFIT2 #define AF_SCRIPT_CLASSES_COUNT 6 #else -#define AF_SCRIPT_CLASSES_COUNT 5 +#define AF_SCRIPT_CLASSES_COUNT 5 #endif -#define AF_SCRIPT_CLASSES_REC_COUNT ( AF_SCRIPT_CLASSES_COUNT - 1 ) +#define AF_SCRIPT_CLASSES_REC_COUNT ( AF_SCRIPT_CLASSES_COUNT - 1 ) typedef struct AFModulePIC_ { @@ -57,6 +57,13 @@ FT_BEGIN_HEADER #define AF_AF_AUTOFITTER_SERVICE_GET \ ( GET_PIC( library )->af_autofitter_service ) + /* see afpic.c for the implementation */ + void + autofit_module_class_pic_free( FT_Library library ); + + FT_Error + autofit_module_class_pic_init( FT_Library library ); + #endif /* FT_CONFIG_OPTION_PIC */ /* */ diff --git a/src/autofit/aftypes.h b/src/autofit/aftypes.h index 44997d1..21e442c 100644 --- a/src/autofit/aftypes.h +++ b/src/autofit/aftypes.h @@ -231,7 +231,7 @@ extern void* _af_debug_hints; AF_SCRIPT_NONE = 0, AF_SCRIPT_LATIN = 1, AF_SCRIPT_CJK = 2, - AF_SCRIPT_INDIC = 3, + AF_SCRIPT_INDIC = 3, #ifdef FT_OPTION_AUTOFIT2 AF_SCRIPT_LATIN2, #endif diff --git a/src/autofit/afwarp.c b/src/autofit/afwarp.c index d0d4850..34a97ff 100644 --- a/src/autofit/afwarp.c +++ b/src/autofit/afwarp.c @@ -352,7 +352,7 @@ { FT_Fixed best_scale = warper->best_scale; FT_Pos best_delta = warper->best_delta; - + hints->xmin_delta = FT_MulFix( X1, best_scale - org_scale ) + best_delta; diff --git a/src/base/basepic.c b/src/base/basepic.c index c0bccb6..d754eb1 100644 --- a/src/base/basepic.c +++ b/src/base/basepic.c @@ -24,18 +24,24 @@ #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*); + void FT_Init_Class_ft_outline_glyph_class( FT_Glyph_Class* clazz ); + void FT_Init_Class_ft_bitmap_glyph_class( FT_Glyph_Class* clazz ); + + /* forward declaration of PIC init function from ftrfork.c (not modularized) */ + void FT_Init_Table_raccess_guess_table( ft_raccess_guess_rec* record ); /* 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); + FT_Error + ft_create_default_module_classes( FT_Library library ); + + void + ft_destroy_default_module_classes( FT_Library library ); void - ft_base_pic_free( FT_Library library ) + ft_base_pic_free( FT_Library library ) { - FT_PIC_Container* pic_container = &library->pic_container; - FT_Memory memory = library->memory; + 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) */ @@ -48,17 +54,17 @@ FT_Error - ft_base_pic_init( FT_Library library ) + 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; + 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) ); + FT_MEM_SET( container, 0, sizeof ( *container ) ); pic_container->base = container; /* initialize default modules list and pointers */ @@ -67,12 +73,16 @@ 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); + FT_Init_Class_ft_outline_glyph_class( + &container->ft_outline_glyph_class ); + FT_Init_Class_ft_bitmap_glyph_class( + &container->ft_bitmap_glyph_class ); + FT_Init_Table_raccess_guess_table( + (ft_raccess_guess_rec*)&container->ft_raccess_guess_table); Exit: - if(error) - ft_base_pic_free(library); + if( error ) + ft_base_pic_free( library ); return error; } diff --git a/src/base/basepic.h b/src/base/basepic.h index bb17745..bf90bef 100644 --- a/src/base/basepic.h +++ b/src/base/basepic.h @@ -19,7 +19,7 @@ #ifndef __BASEPIC_H__ #define __BASEPIC_H__ - + FT_BEGIN_HEADER #include FT_INTERNAL_PIC_H @@ -28,28 +28,43 @@ FT_BEGIN_HEADER #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 +#ifdef FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK +#define FT_RACCESS_GUESS_TABLE_GET ft_raccess_guess_table +#endif #else /* FT_CONFIG_OPTION_PIC */ #include FT_GLYPH_H +#ifdef FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK +#include FT_INTERNAL_RFORK_H +#endif + + typedef struct BasePIC_ { FT_Module_Class** default_module_classes; FT_Glyph_Class ft_outline_glyph_class; FT_Glyph_Class ft_bitmap_glyph_class; +#ifdef FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK + ft_raccess_guess_rec ft_raccess_guess_table[FT_RACCESS_N_RULES]; +#endif } 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) +#ifdef FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK +#define FT_RACCESS_GUESS_TABLE_GET (GET_PIC(library)->ft_raccess_guess_table) +#endif + /* see basepic.c for the implementation. */ void - ft_base_pic_free( FT_Library library ); + ft_base_pic_free( FT_Library library ); FT_Error - ft_base_pic_init( FT_Library library ); + ft_base_pic_init( FT_Library library ); #endif /* FT_CONFIG_OPTION_PIC */ /* */ diff --git a/src/base/ftadvanc.c b/src/base/ftadvanc.c index 8ab7fcb..a8bb43d 100644 --- a/src/base/ftadvanc.c +++ b/src/base/ftadvanc.c @@ -4,7 +4,7 @@ /* */ /* Quick computation of advance widths (body). */ /* */ -/* Copyright 2008, 2009 by */ +/* Copyright 2008, 2009, 2011 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -129,7 +129,7 @@ { error = func( face, start, count, flags, padvances ); if ( !error ) - goto Exit; + return _ft_face_scale_advances( face, padvances, count, flags ); if ( error != FT_ERROR_BASE( FT_Err_Unimplemented_Feature ) ) return error; @@ -147,16 +147,13 @@ if ( error ) break; + /* scale from 26.6 to 16.16 */ padvances[nn] = ( flags & FT_LOAD_VERTICAL_LAYOUT ) - ? face->glyph->advance.y - : face->glyph->advance.x; + ? face->glyph->advance.y << 10 + : face->glyph->advance.x << 10; } - if ( error ) - return error; - - Exit: - return _ft_face_scale_advances( face, padvances, count, flags ); + return error; } diff --git a/src/base/ftbase.c b/src/base/ftbase.c index 6a27ea9..5e5d70e 100644 --- a/src/base/ftbase.c +++ b/src/base/ftbase.c @@ -34,7 +34,7 @@ #include "fttrigon.c" #include "ftutil.c" -#if defined( FT_MACINTOSH ) && !defined ( DARWIN_NO_CARBON ) +#ifdef FT_MACINTOSH #include "ftmac.c" #endif diff --git a/src/base/ftbase.h b/src/base/ftbase.h index 516f4bb..51a1db1 100644 --- a/src/base/ftbase.h +++ b/src/base/ftbase.h @@ -49,15 +49,15 @@ FT_BEGIN_HEADER FT_Face *aface ); -#if defined( FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK ) && \ - ( !defined( FT_MACINTOSH ) || defined( DARWIN_NO_CARBON ) ) +#if defined( FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK ) && \ + !defined( FT_MACINTOSH ) /* Mac OS X/Darwin kernel often changes recommended method to access */ /* the resource fork and older methods makes the kernel issue the */ /* warning of deprecated method. To calm it down, the methods based */ /* on Darwin VFS should be grouped and skip the rest methods after */ /* the case the resource is opened but found to lack a font in it. */ FT_LOCAL( FT_Bool ) - raccess_rule_by_darwin_vfs( FT_UInt rule_index ); + ft_raccess_rule_by_darwin_vfs( FT_Library library, FT_UInt rule_index ); #endif diff --git a/src/base/ftbitmap.c b/src/base/ftbitmap.c index 15c9d65..84fa322 100644 --- a/src/base/ftbitmap.c +++ b/src/base/ftbitmap.c @@ -231,7 +231,7 @@ 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; diff --git a/src/base/ftcalc.c b/src/base/ftcalc.c index 3892fab..2aeea04 100644 --- a/src/base/ftcalc.c +++ b/src/base/ftcalc.c @@ -4,7 +4,7 @@ /* */ /* Arithmetic computations (body). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2008 by */ +/* Copyright 1996-2006, 2008, 2012 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -307,7 +307,7 @@ q <<= 1; r |= lo >> 31; - if ( r >= (FT_UInt32)y ) + if ( r >= y ) { r -= y; q |= 1; @@ -373,7 +373,7 @@ if ( a <= 46340L && b <= 46340L && c <= 176095L && c > 0 ) a = ( a * b + ( c >> 1 ) ) / c; - else if ( c > 0 ) + else if ( (FT_Int32)c > 0 ) { FT_Int64 temp, temp2; @@ -412,7 +412,7 @@ if ( a <= 46340L && b <= 46340L && c > 0 ) a = a * b / c; - else if ( c > 0 ) + else if ( (FT_Int32)c > 0 ) { FT_Int64 temp; @@ -464,7 +464,7 @@ * Unfortunately, it doesn't work (at least not portably). * * It makes the assumption that right-shift on a negative signed value - * fills the leftmost bits by copying the sign bit. This is wrong. + * fills the leftmost bits by copying the sign bit. This is wrong. * According to K&R 2nd ed, section `A7.8 Shift Operators' on page 206, * the result of right-shift of a negative signed value is * implementation-defined. At least one implementation fills the @@ -544,7 +544,7 @@ s = (FT_Int32)a; a = FT_ABS( a ); s ^= (FT_Int32)b; b = FT_ABS( b ); - if ( b == 0 ) + if ( (FT_UInt32)b == 0 ) { /* check for division by 0 */ q = (FT_UInt32)0x7FFFFFFFL; @@ -552,15 +552,16 @@ else if ( ( a >> 16 ) == 0 ) { /* compute result directly */ - q = (FT_UInt32)( (a << 16) + (b >> 1) ) / (FT_UInt32)b; + q = (FT_UInt32)( ( a << 16 ) + ( b >> 1 ) ) / (FT_UInt32)b; } else { /* we need more bits; we have to do it by hand */ FT_Int64 temp, temp2; - temp.hi = (FT_Int32) (a >> 16); - temp.lo = (FT_UInt32)(a << 16); + + temp.hi = (FT_Int32) ( a >> 16 ); + temp.lo = (FT_UInt32)( a << 16 ); temp2.hi = 0; temp2.lo = (FT_UInt32)( b >> 1 ); FT_Add64( &temp, &temp2, &temp ); diff --git a/src/base/ftglyph.c b/src/base/ftglyph.c index b220508..591b57a 100644 --- a/src/base/ftglyph.c +++ b/src/base/ftglyph.c @@ -254,7 +254,7 @@ } - FT_DEFINE_GLYPH( ft_outline_glyph_class, + FT_DEFINE_GLYPH( ft_outline_glyph_class, sizeof ( FT_OutlineGlyphRec ), FT_GLYPH_FORMAT_OUTLINE, @@ -512,42 +512,42 @@ FT_Error error = FT_Err_Ok; FT_Glyph glyph; FT_BitmapGlyph bitmap = NULL; - const FT_Glyph_Class* clazz; -#ifdef FT_CONFIG_OPTION_PIC - FT_Library library = FT_GLYPH( glyph )->library; -#endif + /* FT_BITMAP_GLYPH_CLASS_GET derefers `library' in PIC mode */ + FT_Library library; /* check argument */ if ( !the_glyph ) goto Bad; - - /* we render the glyph into a glyph bitmap using a `dummy' glyph slot */ - /* then calling FT_Render_Glyph_Internal() */ - glyph = *the_glyph; if ( !glyph ) goto Bad; - clazz = glyph->clazz; + clazz = glyph->clazz; + library = glyph->library; + if ( !library || !clazz ) + goto Bad; /* when called with a bitmap glyph, do nothing and return successfully */ if ( clazz == FT_BITMAP_GLYPH_CLASS_GET ) goto Exit; - if ( !clazz || !clazz->glyph_prepare ) + if ( !clazz->glyph_prepare ) goto Bad; + /* we render the glyph into a glyph bitmap using a `dummy' glyph slot */ + /* then calling FT_Render_Glyph_Internal() */ + FT_MEM_ZERO( &dummy, sizeof ( dummy ) ); FT_MEM_ZERO( &dummy_internal, sizeof ( dummy_internal ) ); dummy.internal = &dummy_internal; - dummy.library = glyph->library; + dummy.library = library; dummy.format = clazz->glyph_format; /* create result bitmap glyph */ - error = ft_new_glyph( glyph->library, FT_BITMAP_GLYPH_CLASS_GET, + error = ft_new_glyph( library, FT_BITMAP_GLYPH_CLASS_GET, (FT_Glyph*)(void*)&bitmap ); if ( error ) goto Exit; diff --git a/src/base/ftinit.c b/src/base/ftinit.c index 305177a..91f8e2a 100644 --- a/src/base/ftinit.c +++ b/src/base/ftinit.c @@ -4,7 +4,7 @@ /* */ /* FreeType initialization layer (body). */ /* */ -/* Copyright 1996-2001, 2002, 2005, 2007, 2009 by */ +/* Copyright 1996-2001, 2002, 2005, 2007, 2009, 2012 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -54,8 +54,10 @@ #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; @@ -63,10 +65,8 @@ #define FT_USE_MODULE( type, x ) extern const type x; #endif - #include FT_CONFIG_MODULES_H - #undef FT_USE_MODULE #define FT_USE_MODULE( type, x ) (const FT_Module_Class*)&(x), @@ -77,8 +77,10 @@ 0 }; + #else /* FT_CONFIG_OPTION_PIC */ + #ifdef __cplusplus #define FT_EXTERNC extern "C" #else @@ -87,16 +89,19 @@ /* 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 ); +#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, +#define FT_USE_MODULE( type, x ) MODULE_CLASS_ ## x, enum { @@ -104,26 +109,31 @@ FT_NUM_MODULE_CLASSES }; - /* destroy all 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++; \ +#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 = (BasePIC*)library->pic_container.base; + FT_Module_Class* *classes; + FT_Memory memory; + FT_UInt i; + BasePIC* pic_container = (BasePIC*)library->pic_container.base; + if ( !pic_container->default_module_classes ) return; - memory = library->memory; + memory = library->memory; classes = pic_container->default_module_classes; - i = 0; + i = 0; #include FT_CONFIG_MODULES_H @@ -131,30 +141,37 @@ 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; \ +#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 = (BasePIC*)library->pic_container.base; - - memory = library->memory; + FT_Error error; + FT_Memory memory; + FT_Module_Class* *classes; + FT_Module_Class* clazz; + FT_UInt i; + BasePIC* pic_container = (BasePIC*)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) ) ) + 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++) + for ( i = 0; i < FT_NUM_MODULE_CLASSES; i++ ) classes[i] = 0; classes[FT_NUM_MODULE_CLASSES] = 0; @@ -162,16 +179,19 @@ #include FT_CONFIG_MODULES_H -Exit: - if (error) ft_destroy_default_module_classes( library ); - else pic_container->default_module_classes = classes; + Exit: + if ( error ) + ft_destroy_default_module_classes( library ); + else + pic_container->default_module_classes = classes; - return error; + return error; } #endif /* FT_CONFIG_OPTION_PIC */ + /* documentation is in ftmodapi.h */ FT_EXPORT_DEF( void ) @@ -181,9 +201,18 @@ Exit: const FT_Module_Class* const* cur; - /* test for valid `library' delayed to FT_Add_Module() */ + /* FT_DEFAULT_MODULES_GET dereferences `library' in PIC mode */ +#ifdef FT_CONFIG_OPTION_PIC + if ( !library ) + return; +#endif + + /* GCC 4.6 warns the type difference: + * FT_Module_Class** != const FT_Module_Class* const* + */ + cur = (const FT_Module_Class* const*)FT_DEFAULT_MODULES_GET; - cur = FT_DEFAULT_MODULES_GET; + /* test for valid `library' delayed to FT_Add_Module() */ while ( *cur ) { error = FT_Add_Module( library, *cur ); diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c index 64575af..36ee797 100644 --- a/src/base/ftobjs.c +++ b/src/base/ftobjs.c @@ -4,7 +4,7 @@ /* */ /* The FreeType private base classes (body). */ /* */ -/* Copyright 1996-2011 by */ +/* Copyright 1996-2012 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -445,6 +445,10 @@ else prev->next = cur->next; + /* finalize client-specific data */ + if ( slot->generic.finalizer ) + slot->generic.finalizer( slot ); + ft_glyphslot_done( slot ); FT_FREE( slot ); break; @@ -1187,7 +1191,7 @@ /* there's a Mac-specific extended implementation of FT_New_Face() */ /* in src/base/ftmac.c */ -#if !defined( FT_MACINTOSH ) || defined( DARWIN_NO_CARBON ) +#ifndef FT_MACINTOSH /* documentation is in freetype.h */ @@ -1211,7 +1215,7 @@ return FT_Open_Face( library, &args, face_index, aface ); } -#endif /* defined( FT_MACINTOSH ) && !defined( DARWIN_NO_CARBON ) */ +#endif /* documentation is in freetype.h */ @@ -1520,7 +1524,7 @@ } -#if !defined( FT_MACINTOSH ) || defined( DARWIN_NO_CARBON ) +#ifndef FT_MACINTOSH /* The resource header says we've got resource_cnt `POST' (type1) */ /* resources in this file. They all need to be coalesced into */ @@ -1875,7 +1879,7 @@ for ( i = 0; i < FT_RACCESS_N_RULES; i++ ) { - is_darwin_vfs = raccess_rule_by_darwin_vfs( i ); + is_darwin_vfs = ft_raccess_rule_by_darwin_vfs( library, i ); if ( is_darwin_vfs && vfs_rfork_has_no_font ) { FT_TRACE3(( "Skip rule %d: darwin vfs resource fork" @@ -4085,10 +4089,10 @@ /* all child faces. */ /* */ /* <InOut> */ - /* module :: A handle to the target driver object. */ + /* module :: A handle to the target driver object. */ /* */ /* <Note> */ - /* The driver _must_ be LOCKED! */ + /* The driver _must_ be LOCKED! */ /* */ static void Destroy_Module( FT_Module module ) @@ -4098,10 +4102,6 @@ FT_Library library = module->library; - /* finalize client-data - before anything else */ - if ( module->generic.finalizer ) - module->generic.finalizer( module ); - if ( library && library->auto_hinter == module ) library->auto_hinter = 0; @@ -4318,6 +4318,7 @@ FT_Module* cur = library->modules; FT_Module* limit = cur + library->num_modules; + for ( ; cur < limit; cur++ ) { if ( cur[0] != module ) @@ -4511,10 +4512,6 @@ memory = library->memory; - /* Discard client-data */ - if ( library->generic.finalizer ) - library->generic.finalizer( library ); - /* * Close all faces in the library. If we don't do this, we can have * some subtle memory leaks. diff --git a/src/base/ftoutln.c b/src/base/ftoutln.c index 356b156..9ae276d 100644 --- a/src/base/ftoutln.c +++ b/src/base/ftoutln.c @@ -4,7 +4,7 @@ /* */ /* FreeType outline management (body). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2010 by */ +/* Copyright 1996-2008, 2010, 2012 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -771,7 +771,7 @@ return 1; } - return ( n % 2 ); + return n & 1; } diff --git a/src/base/ftpic.c b/src/base/ftpic.c index d5271a9..b74e90d 100644 --- a/src/base/ftpic.c +++ b/src/base/ftpic.c @@ -26,15 +26,15 @@ /* documentation is in ftpic.h */ FT_BASE_DEF( FT_Error ) - ft_pic_container_init( FT_Library library ) + ft_pic_container_init( FT_Library library ) { - FT_PIC_Container* pic_container = &library->pic_container; - FT_Error error = FT_Err_Ok; + FT_PIC_Container* pic_container = &library->pic_container; + FT_Error error = FT_Err_Ok; - FT_MEM_SET( pic_container, 0, sizeof(*pic_container) ); + FT_MEM_SET( pic_container, 0, sizeof ( *pic_container ) ); error = ft_base_pic_init( library ); - if(error) + if ( error ) return error; return FT_Err_Ok; @@ -43,7 +43,7 @@ /* Destroy the contents of the container. */ FT_BASE_DEF( void ) - ft_pic_container_destroy( FT_Library library ) + ft_pic_container_destroy( FT_Library library ) { ft_base_pic_free( library ); } diff --git a/src/base/ftrfork.c b/src/base/ftrfork.c index 33768b0..01d8625 100644 --- a/src/base/ftrfork.c +++ b/src/base/ftrfork.c @@ -28,7 +28,7 @@ #include FT_INTERNAL_DEBUG_H #include FT_INTERNAL_STREAM_H #include FT_INTERNAL_RFORK_H - +#include "basepic.h" #undef FT_COMPONENT #define FT_COMPONENT trace_raccess @@ -253,14 +253,6 @@ /*************************************************************************/ /*************************************************************************/ - typedef FT_Error - (*raccess_guess_func)( FT_Library library, - FT_Stream stream, - char *base_file_name, - char **result_file_name, - FT_Long *result_offset ); - - static FT_Error raccess_guess_apple_double( FT_Library library, FT_Stream stream, @@ -325,6 +317,20 @@ FT_Long *result_offset ); + CONST_FT_RFORK_RULE_ARRAY_BEGIN(ft_raccess_guess_table, + ft_raccess_guess_rec) + CONST_FT_RFORK_RULE_ARRAY_ENTRY(apple_double, apple_double) + CONST_FT_RFORK_RULE_ARRAY_ENTRY(apple_single, apple_single) + CONST_FT_RFORK_RULE_ARRAY_ENTRY(darwin_ufs_export, darwin_ufs_export) + CONST_FT_RFORK_RULE_ARRAY_ENTRY(darwin_newvfs, darwin_newvfs) + CONST_FT_RFORK_RULE_ARRAY_ENTRY(darwin_hfsplus, darwin_hfsplus) + CONST_FT_RFORK_RULE_ARRAY_ENTRY(vfat, vfat) + CONST_FT_RFORK_RULE_ARRAY_ENTRY(linux_cap, linux_cap) + CONST_FT_RFORK_RULE_ARRAY_ENTRY(linux_double, linux_double) + CONST_FT_RFORK_RULE_ARRAY_ENTRY(linux_netatalk, linux_netatalk) + CONST_FT_RFORK_RULE_ARRAY_END + + /*************************************************************************/ /**** ****/ /**** Helper functions ****/ @@ -348,43 +354,6 @@ const char *original_name, const char *insertion ); - - typedef enum FT_RFork_Rule_ { - FT_RFork_Rule_invalid = -2, - FT_RFork_Rule_uknown, /* -1 */ - FT_RFork_Rule_apple_double, - FT_RFork_Rule_apple_single, - FT_RFork_Rule_darwin_ufs_export, - FT_RFork_Rule_darwin_newvfs, - FT_RFork_Rule_darwin_hfsplus, - FT_RFork_Rule_vfat, - FT_RFork_Rule_linux_cap, - FT_RFork_Rule_linux_double, - FT_RFork_Rule_linux_netatalk - } FT_RFork_Rule; - - /* For fast translation between rule index and rule type, - * the macros FT_RFORK_xxx should be kept consistent with - * the raccess_guess_funcs table - */ - typedef struct raccess_guess_rec_ { - raccess_guess_func func; - FT_RFork_Rule type; - } raccess_guess_rec; - - static raccess_guess_rec raccess_guess_table[FT_RACCESS_N_RULES] = - { - { raccess_guess_apple_double, FT_RFork_Rule_apple_double, }, - { raccess_guess_apple_single, FT_RFork_Rule_apple_single, }, - { raccess_guess_darwin_ufs_export, FT_RFork_Rule_darwin_ufs_export, }, - { raccess_guess_darwin_newvfs, FT_RFork_Rule_darwin_newvfs, }, - { raccess_guess_darwin_hfsplus, FT_RFork_Rule_darwin_hfsplus, }, - { raccess_guess_vfat, FT_RFork_Rule_vfat, }, - { raccess_guess_linux_cap, FT_RFork_Rule_linux_cap, }, - { raccess_guess_linux_double, FT_RFork_Rule_linux_double, }, - { raccess_guess_linux_netatalk, FT_RFork_Rule_linux_netatalk, }, - }; - FT_BASE_DEF( void ) FT_Raccess_Guess( FT_Library library, FT_Stream stream, @@ -407,7 +376,7 @@ if ( errors[i] ) continue ; - errors[i] = (raccess_guess_table[i].func)( library, + errors[i] = (FT_RACCESS_GUESS_TABLE_GET[i].func)( library, stream, base_name, &(new_names[i]), &(offsets[i]) ); @@ -417,21 +386,28 @@ } -#if !defined( FT_MACINTOSH ) || defined( DARWIN_NO_CARBON ) +#ifndef FT_MACINTOSH static FT_RFork_Rule - raccess_get_rule_type_from_rule_index( FT_UInt rule_index ) + raccess_get_rule_type_from_rule_index( FT_Library library, + FT_UInt rule_index ) { + FT_UNUSED( library ); + if ( rule_index >= FT_RACCESS_N_RULES ) return FT_RFork_Rule_invalid; - return raccess_guess_table[rule_index].type; + return FT_RACCESS_GUESS_TABLE_GET[rule_index].type; } + /* + * For this function, refer ftbase.h. + */ FT_LOCAL_DEF( FT_Bool ) - raccess_rule_by_darwin_vfs( FT_UInt rule_index ) + ft_raccess_rule_by_darwin_vfs( FT_Library library, + FT_UInt rule_index ) { - switch( raccess_get_rule_type_from_rule_index( rule_index ) ) + switch( raccess_get_rule_type_from_rule_index( library, rule_index ) ) { case FT_RFork_Rule_darwin_newvfs: case FT_RFork_Rule_darwin_hfsplus: diff --git a/src/cache/ftcbasic.c b/src/cache/ftcbasic.c index 09d793e..d4fc353 100644 --- a/src/cache/ftcbasic.c +++ b/src/cache/ftcbasic.c @@ -467,7 +467,7 @@ } - + #ifdef FT_CONFIG_OPTION_OLD_INTERNALS /* yet another backwards-legacy structure */ @@ -608,7 +608,7 @@ const FTC_SFamilyClassRec ftc_basic_sbit_family_class = { { - sizeof( FTC_BasicFamilyRec ), + sizeof ( FTC_BasicFamilyRec ), ftc_basic_family_compare, ftc_basic_family_init, 0, /* FTC_MruNode_ResetFunc */ diff --git a/src/cache/ftccmap.c b/src/cache/ftccmap.c index b7bd291..ad436ef 100644 --- a/src/cache/ftccmap.c +++ b/src/cache/ftccmap.c @@ -320,7 +320,7 @@ /* * If cmap_index is greater than the maximum number of cachable - * charmaps, we assume the request is from a legacy rogue client + * charmaps, we assume the request is from a legacy rogue client * using old internal header. See include/config/ftoption.h. */ if ( cmap_index > FT_MAX_CHARMAP_CACHEABLE && !no_cmap_change ) diff --git a/src/cff/cffdrivr.c b/src/cff/cffdrivr.c index bf2d016..eb4c14e 100644 --- a/src/cff/cffdrivr.c +++ b/src/cff/cffdrivr.c @@ -4,7 +4,7 @@ /* */ /* OpenType font driver implementation (body). */ /* */ -/* Copyright 1996-2011 by */ +/* Copyright 1996-2012 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -125,7 +125,7 @@ /*************************************************************************/ /* */ /* <Function> */ - /* Load_Glyph */ + /* cff_glyph_load */ /* */ /* <Description> */ /* A driver method used to load a glyph within a given glyph slot. */ @@ -149,10 +149,10 @@ /* FreeType error code. 0 means success. */ /* */ FT_CALLBACK_DEF( FT_Error ) - Load_Glyph( FT_GlyphSlot cffslot, /* CFF_GlyphSlot */ - FT_Size cffsize, /* CFF_Size */ - FT_UInt glyph_index, - FT_Int32 load_flags ) + cff_glyph_load( FT_GlyphSlot cffslot, /* CFF_GlyphSlot */ + FT_Size cffsize, /* CFF_Size */ + FT_UInt glyph_index, + FT_Int32 load_flags ) { FT_Error error; CFF_GlyphSlot slot = (CFF_GlyphSlot)cffslot; @@ -203,7 +203,7 @@ for ( nn = 0; nn < count; nn++ ) { - error = Load_Glyph( slot, face->size, start + nn, flags ); + error = cff_glyph_load( slot, face->size, start + nn, flags ); if ( error ) break; @@ -239,7 +239,7 @@ " cannot get glyph name from CFF & CEF fonts\n" " " " without the `PSNames' module\n" )); - error = CFF_Err_Unknown_File_Format; + error = CFF_Err_Missing_Module; goto Exit; } @@ -466,7 +466,7 @@ dict->cid_registry ); *registry = cff->registry; } - + if ( ordering ) { if ( cff->ordering == NULL ) @@ -489,7 +489,7 @@ *supplement = (FT_Int)dict->cid_supplement; } } - + Fail: return error; } @@ -599,19 +599,35 @@ cff_get_interface( FT_Module driver, /* CFF_Driver */ const char* module_interface ) { + FT_Library library; FT_Module sfnt; FT_Module_Interface result; + /* FT_CFF_SERVICES_GET derefers `library' in PIC mode */ +#ifdef FT_CONFIG_OPTION_PIC + if ( !driver ) + return NULL; + library = driver->library; + if ( !library ) + return NULL; +#endif + result = ft_service_list_lookup( FT_CFF_SERVICES_GET, module_interface ); if ( result != NULL ) - return result; + return result; + /* `driver' is not yet evaluated in non-PIC mode */ +#ifndef FT_CONFIG_OPTION_PIC if ( !driver ) return NULL; + library = driver->library; + if ( !library ) + return NULL; +#endif /* we pass our request to the `sfnt' module */ - sfnt = FT_Get_Module( driver->library, "sfnt" ); + sfnt = FT_Get_Module( library, "sfnt" ); return sfnt ? sfnt->clazz->get_interface( sfnt, module_interface ) : 0; } @@ -625,12 +641,13 @@ #define CFF_SIZE_SELECT 0 #endif - FT_DEFINE_DRIVER(cff_driver_class, + FT_DEFINE_DRIVER( cff_driver_class, + FT_MODULE_FONT_DRIVER | FT_MODULE_DRIVER_SCALABLE | FT_MODULE_DRIVER_HAS_HINTER, - sizeof( CFF_DriverRec ), + sizeof ( CFF_DriverRec ), "cff", 0x10000L, 0x20000L, @@ -642,9 +659,9 @@ cff_get_interface, /* now the specific driver fields */ - sizeof( TT_FaceRec ), - sizeof( CFF_SizeRec ), - sizeof( CFF_GlyphSlotRec ), + sizeof ( TT_FaceRec ), + sizeof ( CFF_SizeRec ), + sizeof ( CFF_GlyphSlotRec ), cff_face_init, cff_face_done, @@ -653,14 +670,14 @@ cff_slot_init, cff_slot_done, - ft_stub_set_char_sizes, /* FT_CONFIG_OPTION_OLD_INTERNALS */ + ft_stub_set_char_sizes, /* FT_CONFIG_OPTION_OLD_INTERNALS */ ft_stub_set_pixel_sizes, /* FT_CONFIG_OPTION_OLD_INTERNALS */ - Load_Glyph, + cff_glyph_load, cff_get_kerning, - 0, /* FT_Face_AttachFunc */ - cff_get_advances, /* FT_Face_GetAdvancesFunc */ + 0, /* FT_Face_AttachFunc */ + cff_get_advances, cff_size_request, diff --git a/src/cff/cfferrs.h b/src/cff/cfferrs.h index 1b2a5c9..801d73e 100644 --- a/src/cff/cfferrs.h +++ b/src/cff/cfferrs.h @@ -4,7 +4,7 @@ /* */ /* CFF error codes (specification only). */ /* */ -/* Copyright 2001 by */ +/* Copyright 2001, 2012 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 @@ #undef __FTERRORS_H__ +#undef FT_ERR_PREFIX #define FT_ERR_PREFIX CFF_Err_ #define FT_ERR_BASE FT_Mod_Err_CFF diff --git a/src/cff/cffgload.c b/src/cff/cffgload.c index cb06bdf..84847fd 100644 --- a/src/cff/cffgload.c +++ b/src/cff/cffgload.c @@ -4,7 +4,7 @@ /* */ /* OpenType Glyph Loader (body). */ /* */ -/* Copyright 1996-2011 by */ +/* Copyright 1996-2012 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -1513,11 +1513,9 @@ goto Stack_Underflow; /* if num_args isn't of the form 4n or 4n+1, */ - /* we reduce it to 4n+1 */ + /* we enforce it by clearing the second bit */ - nargs = num_args - num_args % 4; - if ( num_args - nargs > 0 ) - nargs += 1; + nargs = num_args & ~2; if ( cff_builder_start_point( builder, x, y ) ) goto Fail; @@ -1560,11 +1558,9 @@ goto Stack_Underflow; /* if num_args isn't of the form 4n or 4n+1, */ - /* we reduce it to 4n+1 */ + /* we enforce it by clearing the second bit */ - nargs = num_args - num_args % 4; - if ( num_args - nargs > 0 ) - nargs += 1; + nargs = num_args & ~2; if ( cff_builder_start_point( builder, x, y ) ) goto Fail; @@ -1612,11 +1608,9 @@ goto Stack_Underflow; /* if num_args isn't of the form 8n, 8n+1, 8n+4, or 8n+5, */ - /* we reduce it to the largest one which fits */ + /* we enforce it by clearing the second bit */ - nargs = num_args - num_args % 4; - if ( num_args - nargs > 0 ) - nargs += 1; + nargs = num_args & ~2; args -= nargs; if ( check_points( builder, ( nargs / 4 ) * 3 ) ) @@ -1963,6 +1957,7 @@ /* Save glyph width so that the subglyphs don't overwrite it. */ FT_Pos glyph_width = decoder->glyph_width; + error = cff_operator_seac( decoder, 0L, args[-4], args[-3], (FT_Int)( args[-2] >> 16 ), @@ -2705,7 +2700,7 @@ FT_Byte fd_index = cff_fd_select_get( &cff->fd_select, glyph_index ); - if ( fd_index >= cff->num_subfonts ) + if ( fd_index >= cff->num_subfonts ) fd_index = (FT_Byte)( cff->num_subfonts - 1 ); top_upm = cff->top_font.font_dict.units_per_em; @@ -2961,7 +2956,7 @@ if ( has_vertical_info ) metrics->vertBearingX = metrics->horiBearingX - metrics->horiAdvance / 2; - else + else { if ( load_flags & FT_LOAD_VERTICAL_LAYOUT ) ft_synthesize_vertical_metrics( metrics, diff --git a/src/cff/cffload.c b/src/cff/cffload.c index 8bbf474..2be6ba0 100644 --- a/src/cff/cffload.c +++ b/src/cff/cffload.c @@ -1458,7 +1458,7 @@ font->header_size < 4 || font->absolute_offsize > 4 ) { - FT_TRACE2(( "[not a CFF font header]\n" )); + FT_TRACE2(( " not a CFF font header\n" )); error = CFF_Err_Unknown_File_Format; goto Exit; } @@ -1576,7 +1576,7 @@ if ( dict->charstrings_offset == 0 ) { FT_ERROR(( "cff_font_load: no charstrings offset\n" )); - error = CFF_Err_Unknown_File_Format; + error = CFF_Err_Invalid_File_Format; goto Exit; } diff --git a/src/cff/cffload.h b/src/cff/cffload.h index c755de9..8049619 100644 --- a/src/cff/cffload.h +++ b/src/cff/cffload.h @@ -60,7 +60,7 @@ FT_BEGIN_HEADER FT_LOCAL( FT_Error ) - cff_font_load( FT_Library library, + cff_font_load( FT_Library library, FT_Stream stream, FT_Int face_index, CFF_Font font, diff --git a/src/cff/cffobjs.c b/src/cff/cffobjs.c index 15707a2..6ad0e50 100644 --- a/src/cff/cffobjs.c +++ b/src/cff/cffobjs.c @@ -4,7 +4,7 @@ /* */ /* OpenType objects manager (body). */ /* */ -/* Copyright 1996-2011 by */ +/* Copyright 1996-2012 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -403,7 +403,7 @@ FT_Int32 idx = 0; FT_Int32 length = strlen( name ) + 1; FT_Bool continue_search = 1; - + while ( continue_search ) { @@ -494,13 +494,19 @@ sfnt = (SFNT_Service)FT_Get_Module_Interface( library, "sfnt" ); if ( !sfnt ) - goto Bad_Format; + { + FT_ERROR(( "cff_face_init: cannot access `sfnt' module\n" )); + error = CFF_Err_Missing_Module; + goto Exit; + } FT_FACE_FIND_GLOBAL_SERVICE( face, psnames, POSTSCRIPT_CMAPS ); pshinter = (PSHinter_Service)FT_Get_Module_Interface( library, "pshinter" ); + FT_TRACE2(( "CFF driver\n" )); + /* create input stream from resource */ if ( FT_STREAM_SEEK( 0 ) ) goto Exit; @@ -511,8 +517,9 @@ { if ( face->format_tag != TTAG_OTTO ) /* `OTTO'; OpenType/CFF font */ { - FT_TRACE2(( "[not a valid OpenType/CFF font]\n" )); - goto Bad_Format; + FT_TRACE2(( " not an OpenType/CFF font\n" )); + error = CFF_Err_Unknown_File_Format; + goto Exit; } /* if we are performing a simple font format check, exit immediately */ @@ -604,7 +611,8 @@ " cannot open CFF & CEF fonts\n" " " " without the `PSNames' module\n" )); - goto Bad_Format; + error = CFF_Err_Missing_Module; + goto Exit; } #ifdef FT_DEBUG_LEVEL_TRACE @@ -772,7 +780,7 @@ char* family_name = NULL; - remove_subset_prefix( cffface->family_name ); + remove_subset_prefix( cffface->family_name ); if ( dict->family_name ) { @@ -819,7 +827,7 @@ style_name = cff_strcpy( memory, fullp ); /* remove the style part from the family name (if present) */ - remove_style( cffface->family_name, style_name ); + remove_style( cffface->family_name, style_name ); } break; } @@ -847,22 +855,22 @@ /* */ /* Compute face flags. */ /* */ - flags = (FT_UInt32)( FT_FACE_FLAG_SCALABLE | /* scalable outlines */ - FT_FACE_FLAG_HORIZONTAL | /* horizontal data */ - FT_FACE_FLAG_HINTER ); /* has native hinter */ + flags = FT_FACE_FLAG_SCALABLE | /* scalable outlines */ + FT_FACE_FLAG_HORIZONTAL | /* horizontal data */ + FT_FACE_FLAG_HINTER; /* has native hinter */ if ( sfnt_format ) - flags |= (FT_UInt32)FT_FACE_FLAG_SFNT; + flags |= FT_FACE_FLAG_SFNT; /* fixed width font? */ if ( dict->is_fixed_pitch ) - flags |= (FT_UInt32)FT_FACE_FLAG_FIXED_WIDTH; + flags |= FT_FACE_FLAG_FIXED_WIDTH; /* XXX: WE DO NOT SUPPORT KERNING METRICS IN THE GPOS TABLE FOR NOW */ #if 0 /* kerning available? */ if ( face->kern_pairs ) - flags |= (FT_UInt32)FT_FACE_FLAG_KERNING; + flags |= FT_FACE_FLAG_KERNING; #endif cffface->face_flags = flags; @@ -1014,10 +1022,6 @@ Exit: return error; - - Bad_Format: - error = CFF_Err_Unknown_File_Format; - goto Exit; } diff --git a/src/cff/cffpic.c b/src/cff/cffpic.c index 5d01bd4..1c19d58 100644 --- a/src/cff/cffpic.c +++ b/src/cff/cffpic.c @@ -19,40 +19,78 @@ #include <ft2build.h> #include FT_FREETYPE_H #include FT_INTERNAL_OBJECTS_H +#include "cffcmap.h" #include "cffpic.h" +#include "cfferrs.h" #ifdef FT_CONFIG_OPTION_PIC /* forward declaration of PIC init functions from cffdrivr.c */ - FT_Error FT_Create_Class_cff_services( FT_Library, FT_ServiceDescRec**); - void FT_Destroy_Class_cff_services( FT_Library, FT_ServiceDescRec*); - void FT_Init_Class_cff_service_ps_info( FT_Library, FT_Service_PsInfoRec*); - void FT_Init_Class_cff_service_glyph_dict( FT_Library, FT_Service_GlyphDictRec*); - void FT_Init_Class_cff_service_ps_name( FT_Library, FT_Service_PsFontNameRec*); - void FT_Init_Class_cff_service_get_cmap_info( FT_Library, FT_Service_TTCMapsRec*); - void FT_Init_Class_cff_service_cid_info( FT_Library, FT_Service_CIDRec*); + FT_Error + FT_Create_Class_cff_services( + FT_Library library, + FT_ServiceDescRec** output_class ); + + void + FT_Destroy_Class_cff_services( + FT_Library library, + FT_ServiceDescRec* clazz ); + + void + FT_Init_Class_cff_service_ps_info( + FT_Library library, + FT_Service_PsInfoRec* clazz ); + + void + FT_Init_Class_cff_service_glyph_dict( + FT_Library library, + FT_Service_GlyphDictRec* clazz ); + + void + FT_Init_Class_cff_service_ps_name( + FT_Library library, + FT_Service_PsFontNameRec* clazz ); + + void + FT_Init_Class_cff_service_get_cmap_info( + FT_Library library, + FT_Service_TTCMapsRec* clazz ); + + void + FT_Init_Class_cff_service_cid_info( + FT_Library library, + FT_Service_CIDRec* clazz ); /* forward declaration of PIC init functions from cffparse.c */ - FT_Error FT_Create_Class_cff_field_handlers( FT_Library, CFF_Field_Handler**); - void FT_Destroy_Class_cff_field_handlers( FT_Library, CFF_Field_Handler*); + FT_Error + FT_Create_Class_cff_field_handlers( + FT_Library library, + CFF_Field_Handler** output_class ); - /* forward declaration of PIC init functions from cffcmap.c */ - void FT_Init_Class_cff_cmap_encoding_class_rec( FT_Library, FT_CMap_ClassRec*); - void FT_Init_Class_cff_cmap_unicode_class_rec( FT_Library, FT_CMap_ClassRec*); + void + FT_Destroy_Class_cff_field_handlers( + FT_Library library, + CFF_Field_Handler* clazz ); void - cff_driver_class_pic_free( FT_Library library ) + cff_driver_class_pic_free( FT_Library library ) { - FT_PIC_Container* pic_container = &library->pic_container; - FT_Memory memory = library->memory; + FT_PIC_Container* pic_container = &library->pic_container; + FT_Memory memory = library->memory; + + if ( pic_container->cff ) { - CffModulePIC* container = (CffModulePIC*)pic_container->cff; - if(container->cff_services) - FT_Destroy_Class_cff_services(library, container->cff_services); + CffModulePIC* container = ( CffModulePIC* )pic_container->cff; + + + if ( container->cff_services ) + FT_Destroy_Class_cff_services( library, + container->cff_services ); container->cff_services = NULL; - if(container->cff_field_handlers) - FT_Destroy_Class_cff_field_handlers(library, container->cff_field_handlers); + if ( container->cff_field_handlers ) + FT_Destroy_Class_cff_field_handlers( + library, container->cff_field_handlers ); container->cff_field_handlers = NULL; FT_FREE( container ); pic_container->cff = NULL; @@ -76,22 +114,31 @@ pic_container->cff = container; /* initialize pointer table - this is how the module usually expects this data */ - error = FT_Create_Class_cff_services(library, &container->cff_services); - if(error) + error = FT_Create_Class_cff_services( library, + &container->cff_services ); + if ( error ) goto Exit; - error = FT_Create_Class_cff_field_handlers(library, &container->cff_field_handlers); - if(error) + error = FT_Create_Class_cff_field_handlers( + library, &container->cff_field_handlers ); + if ( error ) goto Exit; - FT_Init_Class_cff_service_ps_info(library, &container->cff_service_ps_info); - FT_Init_Class_cff_service_glyph_dict(library, &container->cff_service_glyph_dict); - FT_Init_Class_cff_service_ps_name(library, &container->cff_service_ps_name); - FT_Init_Class_cff_service_get_cmap_info(library, &container->cff_service_get_cmap_info); - FT_Init_Class_cff_service_cid_info(library, &container->cff_service_cid_info); - FT_Init_Class_cff_cmap_encoding_class_rec(library, &container->cff_cmap_encoding_class_rec); - FT_Init_Class_cff_cmap_unicode_class_rec(library, &container->cff_cmap_unicode_class_rec); + FT_Init_Class_cff_service_ps_info( + library, &container->cff_service_ps_info ); + FT_Init_Class_cff_service_glyph_dict( + library, &container->cff_service_glyph_dict ); + FT_Init_Class_cff_service_ps_name( + library, &container->cff_service_ps_name ); + FT_Init_Class_cff_service_get_cmap_info( + library, &container->cff_service_get_cmap_info ); + FT_Init_Class_cff_service_cid_info( + library, &container->cff_service_cid_info ); + FT_Init_Class_cff_cmap_encoding_class_rec( + library, &container->cff_cmap_encoding_class_rec ); + FT_Init_Class_cff_cmap_unicode_class_rec( + library, &container->cff_cmap_unicode_class_rec ); Exit: - if(error) - cff_driver_class_pic_free(library); + if ( error ) + cff_driver_class_pic_free( library ); return error; } diff --git a/src/cff/cffpic.h b/src/cff/cffpic.h index e29d068..342edd8 100644 --- a/src/cff/cffpic.h +++ b/src/cff/cffpic.h @@ -19,7 +19,7 @@ #ifndef __CFFPIC_H__ #define __CFFPIC_H__ - + FT_BEGIN_HEADER #include FT_INTERNAL_PIC_H @@ -68,6 +68,13 @@ FT_BEGIN_HEADER #define FT_CFF_CMAP_UNICODE_CLASS_REC_GET (GET_PIC(library)->cff_cmap_unicode_class_rec) #define FT_CFF_FIELD_HANDLERS_GET (GET_PIC(library)->cff_field_handlers) + /* see cffpic.c for the implementation */ + void + cff_driver_class_pic_free( FT_Library library ); + + FT_Error + cff_driver_class_pic_init( FT_Library library ); + #endif /* FT_CONFIG_OPTION_PIC */ /* */ diff --git a/src/cff/cfftypes.h b/src/cff/cfftypes.h index cae3689..7c99036 100644 --- a/src/cff/cfftypes.h +++ b/src/cff/cfftypes.h @@ -269,7 +269,7 @@ FT_BEGIN_HEADER /* since version 2.3.6 */ FT_String* registry; FT_String* ordering; - + } CFF_FontRec, *CFF_Font; diff --git a/src/psaux/afmparse.c b/src/psaux/afmparse.c index d7de373..5f3f9e6 100644 --- a/src/psaux/afmparse.c +++ b/src/psaux/afmparse.c @@ -4,7 +4,7 @@ /* */ /* AFM parser (body). */ /* */ -/* Copyright 2006, 2007, 2008, 2009, 2010 by */ +/* Copyright 2006-2010, 2012 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -631,9 +631,6 @@ tk->max_ptsize = shared_vals[3].u.f; tk->max_kern = shared_vals[4].u.f; - /* is this correct? */ - if ( tk->degree < 0 && tk->min_kern > 0 ) - tk->min_kern = -tk->min_kern; break; case AFM_TOKEN_ENDTRACKKERN: @@ -754,7 +751,7 @@ case AFM_TOKEN_ENDFONTMETRICS: fi->NumKernPair = n + 1; ft_qsort( fi->KernPairs, fi->NumKernPair, - sizeof( AFM_KernPairRec ), + sizeof ( AFM_KernPairRec ), afm_compare_kern_pairs ); return PSaux_Err_Ok; diff --git a/src/psaux/psauxerr.h b/src/psaux/psauxerr.h index d0baa3c..d52375f 100644 --- a/src/psaux/psauxerr.h +++ b/src/psaux/psauxerr.h @@ -4,7 +4,7 @@ /* */ /* PS auxiliary module error codes (specification only). */ /* */ -/* Copyright 2001 by */ +/* Copyright 2001, 2012 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -30,6 +30,7 @@ #undef __FTERRORS_H__ +#undef FT_ERR_PREFIX #define FT_ERR_PREFIX PSaux_Err_ #define FT_ERR_BASE FT_Mod_Err_PSaux diff --git a/src/psaux/psauxmod.c b/src/psaux/psauxmod.c index 4c3579f..4b1249d 100644 --- a/src/psaux/psauxmod.c +++ b/src/psaux/psauxmod.c @@ -123,7 +123,7 @@ const FT_Module_Class psaux_module_class = { 0, - sizeof( FT_ModuleRec ), + sizeof ( FT_ModuleRec ), "psaux", 0x20000L, 0x20000L, diff --git a/src/psaux/psauxmod.h b/src/psaux/psauxmod.h index 35e042d..1217236 100644 --- a/src/psaux/psauxmod.h +++ b/src/psaux/psauxmod.h @@ -28,7 +28,7 @@ FT_BEGIN_HEADER #ifdef FT_CONFIG_OPTION_PIC #error "this module does not support PIC yet" -#endif +#endif FT_EXPORT_VAR( const FT_Module_Class ) psaux_driver_class; diff --git a/src/psaux/psconv.c b/src/psaux/psconv.c index 1531d8f..9ea7fb9 100644 --- a/src/psaux/psconv.c +++ b/src/psaux/psconv.c @@ -4,7 +4,7 @@ /* */ /* Some convenience conversions (body). */ /* */ -/* Copyright 2006, 2008, 2009 by */ +/* Copyright 2006, 2008, 2009, 2012 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -79,7 +79,7 @@ FT_Bool sign = 0; - if ( p == limit || base < 2 || base > 36 ) + if ( p >= limit || base < 2 || base > 36 ) return 0; if ( *p == '-' || *p == '+' ) @@ -150,7 +150,7 @@ FT_Bool sign = 0; - if ( p == limit ) + if ( p >= limit ) return 0; if ( *p == '-' || *p == '+' ) @@ -346,7 +346,11 @@ #if 1 - p = *cursor; + p = *cursor; + + if ( p >= limit ) + return 0; + if ( n > (FT_UInt)( limit - p ) ) n = (FT_UInt)( limit - p ); @@ -434,6 +438,10 @@ #if 1 p = *cursor; + + if ( p >= limit ) + return 0; + if ( n > (FT_UInt)(limit - p) ) n = (FT_UInt)(limit - p); diff --git a/src/psaux/psobjs.c b/src/psaux/psobjs.c index a28b5fc..06df6e6 100644 --- a/src/psaux/psobjs.c +++ b/src/psaux/psobjs.c @@ -4,7 +4,7 @@ /* */ /* Auxiliary functions for PostScript fonts (body). */ /* */ -/* Copyright 1996-2011 by */ +/* Copyright 1996-2012 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -589,7 +589,7 @@ } Exit: - if ( cur == parser->cursor ) + if ( cur < limit && cur == parser->cursor ) { FT_ERROR(( "ps_parser_skip_PS_token:" " current token is `%c' which is self-delimiting\n" diff --git a/src/psaux/t1cmap.c b/src/psaux/t1cmap.c index f933e4d..9e5bd34 100644 --- a/src/psaux/t1cmap.c +++ b/src/psaux/t1cmap.c @@ -4,7 +4,7 @@ /* */ /* Type 1 character map support (body). */ /* */ -/* Copyright 2002, 2003, 2006, 2007 by */ +/* Copyright 2002, 2003, 2006, 2007, 2012 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -264,8 +264,8 @@ /*************************************************************************/ FT_CALLBACK_DEF( const char * ) - t1_get_glyph_name( T1_Face face, - FT_UInt idx ) + psaux_get_glyph_name( T1_Face face, + FT_UInt idx ) { return face->type1.glyph_names[idx]; } @@ -282,7 +282,7 @@ return psnames->unicodes_init( memory, unicodes, face->type1.num_glyphs, - (PS_GetGlyphNameFunc)&t1_get_glyph_name, + (PS_GetGlyphNameFunc)&psaux_get_glyph_name, (PS_FreeGlyphNameFunc)NULL, (FT_Pointer)face ); } diff --git a/src/psaux/t1decode.c b/src/psaux/t1decode.c index b3ccbdd..ea67841 100644 --- a/src/psaux/t1decode.c +++ b/src/psaux/t1decode.c @@ -199,7 +199,7 @@ #ifdef FT_CONFIG_OPTION_INCREMENTAL T1_Face face = (T1_Face)decoder->builder.face; -#endif +#endif if ( decoder->seac ) @@ -400,7 +400,7 @@ if ( decoder->buildchar && decoder->len_buildchar > 0 ) ft_memset( &decoder->buildchar[0], 0, - sizeof( decoder->buildchar[0] ) * decoder->len_buildchar ); + sizeof ( decoder->buildchar[0] ) * decoder->len_buildchar ); FT_TRACE4(( "\n" "Start charstring\n" )); @@ -880,7 +880,7 @@ ft_memcpy( &decoder->buildchar[idx], blend->weight_vector, blend->num_designs * - sizeof( blend->weight_vector[0] ) ); + sizeof ( blend->weight_vector[0] ) ); } break; @@ -1113,7 +1113,7 @@ FT_TRACE4(( "BuildCharArray = [ " )); for ( i = 0; i < decoder->len_buildchar; ++i ) - FT_TRACE4(( "%d ", decoder->buildchar[ i ] )); + FT_TRACE4(( "%d ", decoder->buildchar[i] )); FT_TRACE4(( "]\n" )); } diff --git a/src/pshinter/pshnterr.h b/src/pshinter/pshnterr.h index 3c0029f..7cc180f 100644 --- a/src/pshinter/pshnterr.h +++ b/src/pshinter/pshnterr.h @@ -4,7 +4,7 @@ /* */ /* PS Hinter error codes (specification only). */ /* */ -/* Copyright 2003 by */ +/* Copyright 2003, 2012 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 @@ #undef __FTERRORS_H__ +#undef FT_ERR_PREFIX #define FT_ERR_PREFIX PSH_Err_ #define FT_ERR_BASE FT_Mod_Err_PShinter diff --git a/src/pshinter/pshpic.c b/src/pshinter/pshpic.c index 5efb422..1e0f9a9 100644 --- a/src/pshinter/pshpic.c +++ b/src/pshinter/pshpic.c @@ -20,17 +20,22 @@ #include FT_FREETYPE_H #include FT_INTERNAL_OBJECTS_H #include "pshpic.h" +#include "pshnterr.h" #ifdef FT_CONFIG_OPTION_PIC /* forward declaration of PIC init functions from pshmod.c */ - void FT_Init_Class_pshinter_interface( FT_Library, PSHinter_Interface*); + void + FT_Init_Class_pshinter_interface( FT_Library library, + PSHinter_Interface* clazz ); void - pshinter_module_class_pic_free( FT_Library library ) + pshinter_module_class_pic_free( FT_Library library ) { - FT_PIC_Container* pic_container = &library->pic_container; - FT_Memory memory = library->memory; + FT_PIC_Container* pic_container = &library->pic_container; + FT_Memory memory = library->memory; + + if ( pic_container->pshinter ) { FT_FREE( pic_container->pshinter ); @@ -53,13 +58,14 @@ return error; FT_MEM_SET( container, 0, sizeof ( *container ) ); pic_container->pshinter = container; - + /* add call to initialization function when you add new scripts */ - FT_Init_Class_pshinter_interface(library, &container->pshinter_interface); + FT_Init_Class_pshinter_interface( + library, &container->pshinter_interface ); /*Exit:*/ - if(error) - pshinter_module_class_pic_free(library); + if( error ) + pshinter_module_class_pic_free( library ); return error; } diff --git a/src/pshinter/pshpic.h b/src/pshinter/pshpic.h index 3555d8e..c10bdd9 100644 --- a/src/pshinter/pshpic.h +++ b/src/pshinter/pshpic.h @@ -19,7 +19,7 @@ #ifndef __PSHPIC_H__ #define __PSHPIC_H__ - + FT_BEGIN_HEADER #include FT_INTERNAL_PIC_H @@ -40,6 +40,12 @@ FT_BEGIN_HEADER #define GET_PIC(lib) ((PSHinterPIC*)((lib)->pic_container.autofit)) #define FTPSHINTER_INTERFACE_GET (GET_PIC(library)->pshinter_interface) + /* see pshpic.c for the implementation */ + void + pshinter_module_class_pic_free( FT_Library library ); + + FT_Error + pshinter_module_class_pic_init( FT_Library library ); #endif /* FT_CONFIG_OPTION_PIC */ diff --git a/src/psnames/psmodule.c b/src/psnames/psmodule.c index 7528696..3619174 100644 --- a/src/psnames/psmodule.c +++ b/src/psnames/psmodule.c @@ -521,7 +521,7 @@ #ifdef FT_CONFIG_OPTION_ADOBE_GLYPH_LIST - FT_DEFINE_SERVICE_PSCMAPSREC(pscmaps_interface, + FT_DEFINE_SERVICE_PSCMAPSREC(pscmaps_interface, (PS_Unicode_ValueFunc) ps_unicode_value, (PS_Unicodes_InitFunc) ps_unicodes_init, (PS_Unicodes_CharIndexFunc)ps_unicodes_char_index, @@ -536,7 +536,7 @@ #else - FT_DEFINE_SERVICE_PSCMAPSREC(pscmaps_interface, + FT_DEFINE_SERVICE_PSCMAPSREC(pscmaps_interface, 0, 0, 0, @@ -552,7 +552,7 @@ #endif /* FT_CONFIG_OPTION_ADOBE_GLYPH_LIST */ - FT_DEFINE_SERVICEDESCREC1(pscmaps_services, + FT_DEFINE_SERVICEDESCREC1(pscmaps_services, FT_SERVICE_ID_POSTSCRIPT_CMAPS, &FT_PSCMAPS_INTERFACE_GET ) @@ -563,7 +563,19 @@ psnames_get_service( FT_Module module, const char* service_id ) { + /* FT_PSCMAPS_SERVICES_GET derefers `library' in PIC mode */ +#ifdef FT_CONFIG_OPTION_PIC + FT_Library library; + + + if ( !module ) + return NULL; + library = module->library; + if ( !library ) + return NULL; +#else FT_UNUSED( module ); +#endif return ft_service_list_lookup( FT_PSCMAPS_SERVICES_GET, service_id ); } @@ -578,7 +590,7 @@ #endif FT_DEFINE_MODULE(psnames_module_class, - + 0, /* this is not a font driver, nor a renderer */ sizeof ( FT_ModuleRec ), diff --git a/src/psnames/psnamerr.h b/src/psnames/psnamerr.h index ae1541d..acda7f9 100644 --- a/src/psnames/psnamerr.h +++ b/src/psnames/psnamerr.h @@ -4,7 +4,7 @@ /* */ /* PS names module error codes (specification only). */ /* */ -/* Copyright 2001 by */ +/* Copyright 2001, 2012 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -30,6 +30,7 @@ #undef __FTERRORS_H__ +#undef FT_ERR_PREFIX #define FT_ERR_PREFIX PSnames_Err_ #define FT_ERR_BASE FT_Mod_Err_PSnames diff --git a/src/psnames/pspic.c b/src/psnames/pspic.c index b9075d5..467ab73 100644 --- a/src/psnames/pspic.c +++ b/src/psnames/pspic.c @@ -20,24 +20,37 @@ #include FT_FREETYPE_H #include FT_INTERNAL_OBJECTS_H #include "pspic.h" +#include "psnamerr.h" #ifdef FT_CONFIG_OPTION_PIC /* forward declaration of PIC init functions from psmodule.c */ - FT_Error FT_Create_Class_pscmaps_services( FT_Library, FT_ServiceDescRec**); - void FT_Destroy_Class_pscmaps_services( FT_Library, FT_ServiceDescRec*); - void FT_Init_Class_pscmaps_interface( FT_Library, FT_Service_PsCMapsRec*); + FT_Error + FT_Create_Class_pscmaps_services( FT_Library library, + FT_ServiceDescRec** output_class ); + void + FT_Destroy_Class_pscmaps_services( FT_Library library, + FT_ServiceDescRec* clazz ); void - psnames_module_class_pic_free( FT_Library library ) + FT_Init_Class_pscmaps_interface( FT_Library library, + FT_Service_PsCMapsRec* clazz ); + + void + psnames_module_class_pic_free( FT_Library library ) { - FT_PIC_Container* pic_container = &library->pic_container; - FT_Memory memory = library->memory; + FT_PIC_Container* pic_container = &library->pic_container; + FT_Memory memory = library->memory; + + if ( pic_container->psnames ) { - PSModulePIC* container = (PSModulePIC*)pic_container->psnames; + PSModulePIC* container = (PSModulePIC*)pic_container->psnames; + + if(container->pscmaps_services) - FT_Destroy_Class_pscmaps_services(library, container->pscmaps_services); + FT_Destroy_Class_pscmaps_services( library, + container->pscmaps_services ); container->pscmaps_services = NULL; FT_FREE( container ); pic_container->psnames = NULL; @@ -57,18 +70,20 @@ /* allocate pointer, clear and set global container pointer */ if ( FT_ALLOC ( container, sizeof ( *container ) ) ) return error; - FT_MEM_SET( container, 0, sizeof(*container) ); + FT_MEM_SET( container, 0, sizeof ( *container ) ); pic_container->psnames = container; /* initialize pointer table - this is how the module usually expects this data */ - error = FT_Create_Class_pscmaps_services(library, &container->pscmaps_services); - if(error) + error = FT_Create_Class_pscmaps_services( + library, &container->pscmaps_services ); + if ( error ) goto Exit; - FT_Init_Class_pscmaps_interface(library, &container->pscmaps_interface); - + FT_Init_Class_pscmaps_interface( library, + &container->pscmaps_interface ); + Exit: - if(error) - psnames_module_class_pic_free(library); + if ( error ) + psnames_module_class_pic_free( library ); return error; } diff --git a/src/psnames/pspic.h b/src/psnames/pspic.h index 75a14fd..1169b89 100644 --- a/src/psnames/pspic.h +++ b/src/psnames/pspic.h @@ -19,7 +19,7 @@ #ifndef __PSPIC_H__ #define __PSPIC_H__ - + FT_BEGIN_HEADER #include FT_INTERNAL_PIC_H @@ -42,6 +42,13 @@ FT_BEGIN_HEADER #define FT_PSCMAPS_SERVICES_GET (GET_PIC(library)->pscmaps_services) #define FT_PSCMAPS_INTERFACE_GET (GET_PIC(library)->pscmaps_interface) + /* see pspic.c for the implementation */ + void + psnames_module_class_pic_free( FT_Library library ); + + FT_Error + psnames_module_class_pic_init( FT_Library library ); + #endif /* FT_CONFIG_OPTION_PIC */ /* */ diff --git a/src/raster/ftraster.c b/src/raster/ftraster.c index 55e2d0d..f85845e 100644 --- a/src/raster/ftraster.c +++ b/src/raster/ftraster.c @@ -4,7 +4,7 @@ /* */ /* The FreeType glyph rasterizer (body). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2005, 2007, 2008, 2009, 2010, 2011 by */ +/* Copyright 1996-2003, 2005, 2007-2012 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -369,18 +369,23 @@ /* Simple record used to implement a stack of bands, required */ /* by the sub-banding mechanism */ - typedef struct TBand_ + typedef struct black_TBand_ { Short y_min; /* band's minimum */ Short y_max; /* band's maximum */ - } TBand; + } black_TBand; #define AlignProfileSize \ ( ( sizeof ( TProfile ) + sizeof ( Alignment ) - 1 ) / sizeof ( long ) ) +#undef RAS_ARG +#undef RAS_ARGS +#undef RAS_VAR +#undef RAS_VARS + #ifdef FT_STATIC_RASTER @@ -396,8 +401,8 @@ #else /* !FT_STATIC_RASTER */ -#define RAS_ARGS PWorker worker, -#define RAS_ARG PWorker worker +#define RAS_ARGS black_PWorker worker, +#define RAS_ARG black_PWorker worker #define RAS_VARS worker, #define RAS_VAR worker @@ -408,7 +413,7 @@ #endif /* !FT_STATIC_RASTER */ - typedef struct TWorker_ TWorker, *PWorker; + typedef struct black_TWorker_ black_TWorker, *black_PWorker; /* prototypes used for sweep function dispatch */ @@ -428,6 +433,10 @@ /* NOTE: These operations are only valid on 2's complement processors */ +#undef FLOOR +#undef CEILING +#undef TRUNC +#undef SCALED #define FLOOR( x ) ( (x) & -ras.precision ) #define CEILING( x ) ( ( (x) + ras.precision - 1 ) & -ras.precision ) @@ -442,7 +451,7 @@ /* Thus, their offset can be coded with less opcodes, resulting in a */ /* smaller executable. */ - struct TWorker_ + struct black_TWorker_ { Int precision_bits; /* precision related variables */ Int precision; @@ -515,8 +524,8 @@ TPoint arcs[3 * MaxBezier + 1]; /* The Bezier stack */ - TBand band_stack[16]; /* band stack used for sub-banding */ - Int band_top; /* band stack top */ + black_TBand band_stack[16]; /* band stack used for sub-banding */ + Int band_top; /* band stack top */ #ifdef FT_RASTER_OPTION_ANTI_ALIASING @@ -540,20 +549,20 @@ }; - typedef struct TRaster_ + typedef struct black_TRaster_ { - char* buffer; - long buffer_size; - void* memory; - PWorker worker; - Byte grays[5]; - Short gray_width; + char* buffer; + long buffer_size; + void* memory; + black_PWorker worker; + Byte grays[5]; + Short gray_width; - } TRaster, *PRaster; + } black_TRaster, *black_PRaster; #ifdef FT_STATIC_RASTER - static TWorker cur_ras; + static black_TWorker cur_ras; #define ras cur_ras #else /* !FT_STATIC_RASTER */ @@ -3391,7 +3400,7 @@ static void - ft_black_init( PRaster raster ) + ft_black_init( black_PRaster raster ) { #ifdef FT_RASTER_OPTION_ANTI_ALIASING FT_UInt n; @@ -3419,7 +3428,7 @@ ft_black_new( void* memory, FT_Raster *araster ) { - static TRaster the_raster; + static black_TRaster the_raster; FT_UNUSED( memory ); @@ -3443,11 +3452,11 @@ static int - ft_black_new( FT_Memory memory, - PRaster *araster ) + ft_black_new( FT_Memory memory, + black_PRaster *araster ) { - FT_Error error; - PRaster raster = NULL; + FT_Error error; + black_PRaster raster = NULL; *araster = 0; @@ -3464,9 +3473,11 @@ static void - ft_black_done( PRaster raster ) + ft_black_done( black_PRaster raster ) { FT_Memory memory = (FT_Memory)raster->memory; + + FT_FREE( raster ); } @@ -3475,15 +3486,15 @@ static void - ft_black_reset( PRaster raster, - char* pool_base, - long pool_size ) + ft_black_reset( black_PRaster raster, + char* pool_base, + long pool_size ) { if ( raster ) { - if ( pool_base && pool_size >= (long)sizeof(TWorker) + 2048 ) + if ( pool_base && pool_size >= (long)sizeof ( black_TWorker ) + 2048 ) { - PWorker worker = (PWorker)pool_base; + black_PWorker worker = (black_PWorker)pool_base; raster->buffer = pool_base + ( ( sizeof ( *worker ) + 7 ) & ~7 ); @@ -3501,7 +3512,7 @@ static void - ft_black_set_mode( PRaster raster, + ft_black_set_mode( black_PRaster raster, unsigned long mode, const char* palette ) { @@ -3528,12 +3539,12 @@ static int - ft_black_render( PRaster raster, + ft_black_render( black_PRaster raster, const FT_Raster_Params* params ) { const FT_Outline* outline = (const FT_Outline*)params->source; const FT_Bitmap* target_map = params->target; - PWorker worker; + black_PWorker worker; if ( !raster || !raster->buffer || !raster->buffer_size ) diff --git a/src/raster/ftrend1.c b/src/raster/ftrend1.c index 28b1b58..859cb7d 100644 --- a/src/raster/ftrend1.c +++ b/src/raster/ftrend1.c @@ -244,10 +244,10 @@ } - FT_DEFINE_RENDERER(ft_raster1_renderer_class, - + FT_DEFINE_RENDERER( ft_raster1_renderer_class, + FT_MODULE_RENDERER, - sizeof( FT_RendererRec ), + sizeof ( FT_RendererRec ), "raster1", 0x10000L, @@ -275,11 +275,10 @@ /* to register it by hand in your application. It should only be */ /* used for backwards-compatibility with FT 1.x anyway. */ /* */ - FT_DEFINE_RENDERER(ft_raster5_renderer_class, - - + FT_DEFINE_RENDERER( ft_raster5_renderer_class, + FT_MODULE_RENDERER, - sizeof( FT_RendererRec ), + sizeof ( FT_RendererRec ), "raster5", 0x10000L, diff --git a/src/raster/rasterrs.h b/src/raster/rasterrs.h index 5df9a7a..ab85c00 100644 --- a/src/raster/rasterrs.h +++ b/src/raster/rasterrs.h @@ -4,7 +4,7 @@ /* */ /* monochrome renderer error codes (specification only). */ /* */ -/* Copyright 2001 by */ +/* Copyright 2001, 2012 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -30,6 +30,7 @@ #undef __FTERRORS_H__ +#undef FT_ERR_PREFIX #define FT_ERR_PREFIX Raster_Err_ #define FT_ERR_BASE FT_Mod_Err_Raster diff --git a/src/raster/rastpic.c b/src/raster/rastpic.c index e31c549..2883e3f 100644 --- a/src/raster/rastpic.c +++ b/src/raster/rastpic.c @@ -20,21 +20,25 @@ #include FT_FREETYPE_H #include FT_INTERNAL_OBJECTS_H #include "rastpic.h" +#include "rasterrs.h" #ifdef FT_CONFIG_OPTION_PIC /* forward declaration of PIC init functions from ftraster.c */ - void FT_Init_Class_ft_standard_raster(FT_Raster_Funcs*); + void + FT_Init_Class_ft_standard_raster( FT_Raster_Funcs* funcs ); void - ft_raster1_renderer_class_pic_free( FT_Library library ) + ft_raster1_renderer_class_pic_free( FT_Library library ) { - FT_PIC_Container* pic_container = &library->pic_container; - FT_Memory memory = library->memory; + FT_PIC_Container* pic_container = &library->pic_container; + FT_Memory memory = library->memory; + + if ( pic_container->raster ) { RasterPIC* container = (RasterPIC*)pic_container->raster; - if(--container->ref_count) + if ( --container->ref_count ) return; FT_FREE( container ); pic_container->raster = NULL; @@ -43,7 +47,7 @@ FT_Error - ft_raster1_renderer_class_pic_init( FT_Library library ) + ft_raster1_renderer_class_pic_init( FT_Library library ) { FT_PIC_Container* pic_container = &library->pic_container; FT_Error error = Raster_Err_Ok; @@ -51,7 +55,7 @@ FT_Memory memory = library->memory; - /* since this function also serve raster5 renderer, + /* since this function also serve raster5 renderer, it implements reference counting */ if ( pic_container->raster ) { @@ -60,28 +64,31 @@ } /* allocate pointer, clear and set global container pointer */ - if ( FT_ALLOC ( container, sizeof ( *container ) ) ) + if ( FT_ALLOC( container, sizeof ( *container ) ) ) return error; - FT_MEM_SET( container, 0, sizeof(*container) ); + FT_MEM_SET( container, 0, sizeof ( *container ) ); pic_container->raster = container; container->ref_count = 1; /* initialize pointer table - this is how the module usually expects this data */ - FT_Init_Class_ft_standard_raster(&container->ft_standard_raster); + FT_Init_Class_ft_standard_raster( &container->ft_standard_raster ); /*Exit:*/ - if(error) - ft_raster1_renderer_class_pic_free(library); + if( error ) + ft_raster1_renderer_class_pic_free( library ); return error; } /* re-route these init and free functions to the above functions */ - FT_Error ft_raster5_renderer_class_pic_init(FT_Library library) + FT_Error + ft_raster5_renderer_class_pic_init( FT_Library library ) { - return ft_raster1_renderer_class_pic_init(library); + return ft_raster1_renderer_class_pic_init( library ); } - void ft_raster5_renderer_class_pic_free(FT_Library library) + + void + ft_raster5_renderer_class_pic_free( FT_Library library ) { - ft_raster1_renderer_class_pic_free(library); + ft_raster1_renderer_class_pic_free( library ); } #endif /* FT_CONFIG_OPTION_PIC */ diff --git a/src/raster/rastpic.h b/src/raster/rastpic.h index dcd82b8..7822a24 100644 --- a/src/raster/rastpic.h +++ b/src/raster/rastpic.h @@ -19,7 +19,7 @@ #ifndef __RASTPIC_H__ #define __RASTPIC_H__ - + FT_BEGIN_HEADER #include FT_INTERNAL_PIC_H @@ -38,6 +38,19 @@ FT_BEGIN_HEADER #define GET_PIC(lib) ((RasterPIC*)((lib)->pic_container.raster)) #define FT_STANDARD_RASTER_GET (GET_PIC(library)->ft_standard_raster) + /* see rastpic.c for the implementation */ + void + ft_raster1_renderer_class_pic_free( FT_Library library ); + + void + ft_raster5_renderer_class_pic_free( FT_Library library ); + + FT_Error + ft_raster1_renderer_class_pic_init( FT_Library library ); + + FT_Error + ft_raster5_renderer_class_pic_init( FT_Library library ); + #endif /* FT_CONFIG_OPTION_PIC */ /* */ diff --git a/src/sfnt/sfdriver.c b/src/sfnt/sfdriver.c index 247aa67..847d83d 100644 --- a/src/sfnt/sfdriver.c +++ b/src/sfnt/sfdriver.c @@ -422,8 +422,19 @@ sfnt_get_interface( FT_Module module, const char* module_interface ) { - FT_UNUSED( module ); + /* FT_SFNT_SERVICES_GET derefers `library' in PIC mode */ +#ifdef FT_CONFIG_OPTION_PIC + FT_Library library; + + if ( !module ) + return NULL; + library = module->library; + if ( !library ) + return NULL; +#else + FT_UNUSED( module ); +#endif return ft_service_list_lookup( FT_SFNT_SERVICES_GET, module_interface ); } @@ -556,14 +567,14 @@ #endif /* FT_CONFIG_OPTION_OLD_INTERNALS */ #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS -#define PUT_EMBEDDED_BITMAPS(a) a +#define PUT_EMBEDDED_BITMAPS(a) a #else -#define PUT_EMBEDDED_BITMAPS(a) 0 +#define PUT_EMBEDDED_BITMAPS(a) 0 #endif #ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES -#define PUT_PS_NAMES(a) a +#define PUT_PS_NAMES(a) a #else -#define PUT_PS_NAMES(a) 0 +#define PUT_PS_NAMES(a) 0 #endif FT_DEFINE_SFNT_INTERFACE(sfnt_interface, @@ -637,9 +648,9 @@ FT_DEFINE_MODULE(sfnt_module_class, - + 0, /* not a font driver or renderer */ - sizeof( FT_ModuleRec ), + sizeof ( FT_ModuleRec ), "sfnt", /* driver name */ 0x10000L, /* driver version 1.0 */ diff --git a/src/sfnt/sferrors.h b/src/sfnt/sferrors.h index 27f90de..564a3fe 100644 --- a/src/sfnt/sferrors.h +++ b/src/sfnt/sferrors.h @@ -4,7 +4,7 @@ /* */ /* SFNT error codes (specification only). */ /* */ -/* Copyright 2001, 2004 by */ +/* Copyright 2001, 2004, 2012 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 @@ #undef __FTERRORS_H__ +#undef FT_ERR_PREFIX #define FT_ERR_PREFIX SFNT_Err_ #define FT_ERR_BASE FT_Mod_Err_SFNT diff --git a/src/sfnt/sfntpic.c b/src/sfnt/sfntpic.c index 53aca17..1372376 100644 --- a/src/sfnt/sfntpic.c +++ b/src/sfnt/sfntpic.c @@ -20,36 +20,73 @@ #include FT_FREETYPE_H #include FT_INTERNAL_OBJECTS_H #include "sfntpic.h" +#include "sferrors.h" #ifdef FT_CONFIG_OPTION_PIC /* forward declaration of PIC init functions from sfdriver.c */ - FT_Error FT_Create_Class_sfnt_services( FT_Library, FT_ServiceDescRec**); - void FT_Destroy_Class_sfnt_services( FT_Library, FT_ServiceDescRec*); - void FT_Init_Class_sfnt_service_bdf( FT_Service_BDFRec*); - void FT_Init_Class_sfnt_interface( FT_Library, SFNT_Interface*); - void FT_Init_Class_sfnt_service_glyph_dict( FT_Library, FT_Service_GlyphDictRec*); - void FT_Init_Class_sfnt_service_ps_name( FT_Library, FT_Service_PsFontNameRec*); - void FT_Init_Class_tt_service_get_cmap_info( FT_Library, FT_Service_TTCMapsRec*); - void FT_Init_Class_sfnt_service_sfnt_table( FT_Service_SFNT_TableRec*); + FT_Error + FT_Create_Class_sfnt_services( FT_Library library, + FT_ServiceDescRec** ouput_class ); + + void + FT_Destroy_Class_sfnt_services( FT_Library library, + FT_ServiceDescRec* clazz ); + + void + FT_Init_Class_sfnt_service_bdf( FT_Service_BDFRec* clazz ); + + void + FT_Init_Class_sfnt_interface( FT_Library library, + SFNT_Interface* clazz ); + + void + FT_Init_Class_sfnt_service_glyph_dict( + FT_Library library, + FT_Service_GlyphDictRec* clazz ); + + void + FT_Init_Class_sfnt_service_ps_name( + FT_Library library, + FT_Service_PsFontNameRec* clazz ); + + void + FT_Init_Class_tt_service_get_cmap_info( + FT_Library library, + FT_Service_TTCMapsRec* clazz ); + + void + FT_Init_Class_sfnt_service_sfnt_table( + FT_Service_SFNT_TableRec* clazz ); /* forward declaration of PIC init functions from ttcmap.c */ - FT_Error FT_Create_Class_tt_cmap_classes( FT_Library, TT_CMap_Class**); - void FT_Destroy_Class_tt_cmap_classes( FT_Library, TT_CMap_Class*); + FT_Error + FT_Create_Class_tt_cmap_classes( FT_Library library, + TT_CMap_Class** output_class ); + + void + FT_Destroy_Class_tt_cmap_classes( FT_Library library, + TT_CMap_Class* clazz ); void - sfnt_module_class_pic_free( FT_Library library ) + sfnt_module_class_pic_free( FT_Library library ) { - FT_PIC_Container* pic_container = &library->pic_container; - FT_Memory memory = library->memory; + FT_PIC_Container* pic_container = &library->pic_container; + FT_Memory memory = library->memory; + + if ( pic_container->sfnt ) { - sfntModulePIC* container = (sfntModulePIC*)pic_container->sfnt; - if(container->sfnt_services) - FT_Destroy_Class_sfnt_services(library, container->sfnt_services); + sfntModulePIC* container = (sfntModulePIC*)pic_container->sfnt; + + + if ( container->sfnt_services ) + FT_Destroy_Class_sfnt_services( library, + container->sfnt_services ); container->sfnt_services = NULL; - if(container->tt_cmap_classes) - FT_Destroy_Class_tt_cmap_classes(library, container->tt_cmap_classes); + if ( container->tt_cmap_classes ) + FT_Destroy_Class_tt_cmap_classes( library, + container->tt_cmap_classes ); container->tt_cmap_classes = NULL; FT_FREE( container ); pic_container->sfnt = NULL; @@ -73,24 +110,31 @@ pic_container->sfnt = container; /* initialize pointer table - this is how the module usually expects this data */ - error = FT_Create_Class_sfnt_services(library, &container->sfnt_services); - if(error) + error = FT_Create_Class_sfnt_services( library, + &container->sfnt_services ); + if ( error ) goto Exit; - error = FT_Create_Class_tt_cmap_classes(library, &container->tt_cmap_classes); - if(error) + error = FT_Create_Class_tt_cmap_classes( library, + &container->tt_cmap_classes ); + if ( error ) goto Exit; - FT_Init_Class_sfnt_service_glyph_dict(library, &container->sfnt_service_glyph_dict); - FT_Init_Class_sfnt_service_ps_name(library, &container->sfnt_service_ps_name); - FT_Init_Class_tt_service_get_cmap_info(library, &container->tt_service_get_cmap_info); - FT_Init_Class_sfnt_service_sfnt_table(&container->sfnt_service_sfnt_table); + + FT_Init_Class_sfnt_service_glyph_dict( + library, &container->sfnt_service_glyph_dict ); + FT_Init_Class_sfnt_service_ps_name( + library, &container->sfnt_service_ps_name ); + FT_Init_Class_tt_service_get_cmap_info( + library, &container->tt_service_get_cmap_info ); + FT_Init_Class_sfnt_service_sfnt_table( + &container->sfnt_service_sfnt_table ); #ifdef TT_CONFIG_OPTION_BDF - FT_Init_Class_sfnt_service_bdf(&container->sfnt_service_bdf); + FT_Init_Class_sfnt_service_bdf( &container->sfnt_service_bdf ); #endif - FT_Init_Class_sfnt_interface(library, &container->sfnt_interface); + FT_Init_Class_sfnt_interface( library, &container->sfnt_interface ); Exit: - if(error) - sfnt_module_class_pic_free(library); + if ( error ) + sfnt_module_class_pic_free( library ); return error; } diff --git a/src/sfnt/sfntpic.h b/src/sfnt/sfntpic.h index 6943b42..f7993d1 100644 --- a/src/sfnt/sfntpic.h +++ b/src/sfnt/sfntpic.h @@ -19,7 +19,7 @@ #ifndef __SFNTPIC_H__ #define __SFNTPIC_H__ - + FT_BEGIN_HEADER #include FT_INTERNAL_PIC_H @@ -76,6 +76,13 @@ typedef struct sfntModulePIC_ #define FT_SFNT_SERVICE_BDF_GET (GET_PIC(library)->sfnt_service_bdf) #define FT_SFNT_INTERFACE_GET (GET_PIC(library)->sfnt_interface) + /* see sfntpic.c for the implementation */ + void + sfnt_module_class_pic_free( FT_Library library ); + + FT_Error + sfnt_module_class_pic_init( FT_Library library ); + #endif /* FT_CONFIG_OPTION_PIC */ /* */ diff --git a/src/sfnt/sfobjs.c b/src/sfnt/sfobjs.c index 44471f6..d7be631 100644 --- a/src/sfnt/sfobjs.c +++ b/src/sfnt/sfobjs.c @@ -376,7 +376,10 @@ tag != TTAG_true && tag != TTAG_typ1 && tag != 0x00020000UL ) + { + FT_TRACE2(( " not a font using the SFNT container format\n" )); return SFNT_Err_Unknown_File_Format; + } face->ttc_header.tag = TTAG_ttcf; @@ -452,7 +455,10 @@ { sfnt = (SFNT_Service)FT_Get_Module_Interface( library, "sfnt" ); if ( !sfnt ) - return SFNT_Err_Invalid_File_Format; + { + FT_ERROR(( "sfnt_init_face: cannot access `sfnt' module\n" )); + return SFNT_Err_Missing_Module; + } face->sfnt = sfnt; face->goto_table = sfnt->goto_table; @@ -460,6 +466,8 @@ FT_FACE_FIND_GLOBAL_SERVICE( face, face->psnames, POSTSCRIPT_CMAPS ); + FT_TRACE2(( "SFNT driver\n" )); + error = sfnt_open_font( stream, face ); if ( error ) return error; diff --git a/src/sfnt/ttcmap.c b/src/sfnt/ttcmap.c index 544750a..1dfd987 100644 --- a/src/sfnt/ttcmap.c +++ b/src/sfnt/ttcmap.c @@ -3363,7 +3363,7 @@ return error; /* the location of the class instances follows the array of pointers */ - recs = (TT_CMap_ClassRec*) (((char*)clazz)+(sizeof(*clazz)*(i+1))); + recs = (TT_CMap_ClassRec*) (((char*)clazz)+(sizeof(*clazz)*(i+1))); i=0; #undef TTCMAPCITEM diff --git a/src/sfnt/ttcmap.h b/src/sfnt/ttcmap.h index 15a4a21..94f7978 100644 --- a/src/sfnt/ttcmap.h +++ b/src/sfnt/ttcmap.h @@ -70,7 +70,7 @@ FT_BEGIN_HEADER format_, validate_, get_cmap_info_ \ }; -#else /* FT_CONFIG_OPTION_PIC */ +#else /* FT_CONFIG_OPTION_PIC */ #define FT_DEFINE_TT_CMAP(class_, size_, init_, done_, char_index_, \ char_next_, char_var_index_, char_var_default_, variant_list_, \ @@ -92,9 +92,9 @@ FT_BEGIN_HEADER clazz->format = format_; \ clazz->validate = validate_; \ clazz->get_cmap_info = get_cmap_info_; \ - } + } -#endif /* FT_CONFIG_OPTION_PIC */ +#endif /* FT_CONFIG_OPTION_PIC */ typedef struct TT_ValidatorRec_ { diff --git a/src/smooth/ftgrays.c b/src/smooth/ftgrays.c index 895e748..4c0eea5 100644 --- a/src/smooth/ftgrays.c +++ b/src/smooth/ftgrays.c @@ -4,7 +4,7 @@ /* */ /* A new `perfect' anti-aliasing renderer (body). */ /* */ -/* Copyright 2000-2003, 2005-2011 by */ +/* Copyright 2000-2003, 2005-2012 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -232,10 +232,15 @@ typedef ptrdiff_t FT_PtrDist; /* as usual, for the speed hungry :-) */ +#undef RAS_ARG +#undef RAS_ARG_ +#undef RAS_VAR +#undef RAS_VAR_ + #ifndef FT_STATIC_RASTER -#define RAS_ARG PWorker worker -#define RAS_ARG_ PWorker worker, +#define RAS_ARG gray_PWorker worker +#define RAS_ARG_ gray_PWorker worker, #define RAS_VAR worker #define RAS_VAR_ worker, @@ -253,6 +258,11 @@ typedef ptrdiff_t FT_PtrDist; /* must be at least 6 bits! */ #define PIXEL_BITS 8 +#undef FLOOR +#undef CEILING +#undef TRUNC +#undef SCALED + #define ONE_PIXEL ( 1L << PIXEL_BITS ) #define PIXEL_MASK ( -1L << PIXEL_BITS ) #define TRUNC( x ) ( (TCoord)( (x) >> PIXEL_BITS ) ) @@ -310,15 +320,15 @@ typedef ptrdiff_t FT_PtrDist; typedef struct TCell_ { - TPos x; /* same with TWorker.ex */ - TCoord cover; /* same with TWorker.cover */ - TArea area; - PCell next; + TPos x; /* same with gray_TWorker.ex */ + TCoord cover; /* same with gray_TWorker.cover */ + TArea area; + PCell next; } TCell; - typedef struct TWorker_ + typedef struct gray_TWorker_ { TCoord ex, ey; TPos min_ex, max_ex; @@ -329,7 +339,7 @@ typedef ptrdiff_t FT_PtrDist; TCoord cover; int invalid; - PCell cells; + PCell cells; FT_PtrDist max_cells; FT_PtrDist num_cells; @@ -363,25 +373,25 @@ typedef ptrdiff_t FT_PtrDist; PCell* ycells; TPos ycount; - } TWorker, *PWorker; + } gray_TWorker, *gray_PWorker; #ifndef FT_STATIC_RASTER #define ras (*worker) #else - static TWorker ras; + static gray_TWorker ras; #endif - typedef struct TRaster_ + typedef struct gray_TRaster_ { - void* buffer; - long buffer_size; - int band_size; - void* memory; - PWorker worker; + void* buffer; + long buffer_size; + int band_size; + void* memory; + gray_PWorker worker; - } TRaster, *PRaster; + } gray_TRaster, *gray_PRaster; @@ -878,6 +888,8 @@ typedef ptrdiff_t FT_PtrDist; FT_Vector* arc; + levels = ras.lev_stack; + arc = ras.bez_stack; arc[0].x = UPSCALE( to->x ); arc[0].y = UPSCALE( to->y ); @@ -916,7 +928,6 @@ typedef ptrdiff_t FT_PtrDist; level++; } while ( dx > ONE_PIXEL / 4 ); - levels = ras.lev_stack; levels[0] = level; do @@ -1109,7 +1120,7 @@ typedef ptrdiff_t FT_PtrDist; static int gray_move_to( const FT_Vector* to, - PWorker worker ) + gray_PWorker worker ) { TPos x, y; @@ -1131,7 +1142,7 @@ typedef ptrdiff_t FT_PtrDist; static int gray_line_to( const FT_Vector* to, - PWorker worker ) + gray_PWorker worker ) { gray_render_line( RAS_VAR_ UPSCALE( to->x ), UPSCALE( to->y ) ); return 0; @@ -1141,7 +1152,7 @@ typedef ptrdiff_t FT_PtrDist; static int gray_conic_to( const FT_Vector* control, const FT_Vector* to, - PWorker worker ) + gray_PWorker worker ) { gray_render_conic( RAS_VAR_ control, to ); return 0; @@ -1152,7 +1163,7 @@ typedef ptrdiff_t FT_PtrDist; gray_cubic_to( const FT_Vector* control1, const FT_Vector* control2, const FT_Vector* to, - PWorker worker ) + gray_PWorker worker ) { gray_render_cubic( RAS_VAR_ control1, control2, to ); return 0; @@ -1163,7 +1174,7 @@ typedef ptrdiff_t FT_PtrDist; gray_render_span( int y, int count, const FT_Span* spans, - PWorker worker ) + gray_PWorker worker ) { unsigned char* p; FT_Bitmap* map = &worker->target; @@ -1675,11 +1686,11 @@ typedef ptrdiff_t FT_PtrDist; #endif /* _STANDALONE_ */ - typedef struct TBand_ + typedef struct gray_TBand_ { TPos min, max; - } TBand; + } gray_TBand; FT_DEFINE_OUTLINE_FUNCS(func_interface, (FT_Outline_MoveTo_Func) gray_move_to, @@ -1716,11 +1727,11 @@ typedef ptrdiff_t FT_PtrDist; static int gray_convert_glyph( RAS_ARG ) { - TBand bands[40]; - TBand* volatile band; - int volatile n, num_bands; - TPos volatile min, max, max_y; - FT_BBox* clip; + gray_TBand bands[40]; + gray_TBand* volatile band; + int volatile n, num_bands; + TPos volatile min, max, max_y; + FT_BBox* clip; /* Set up state in the raster object */ @@ -1784,7 +1795,7 @@ typedef ptrdiff_t FT_PtrDist; cell_start += sizeof ( TCell ) - cell_mod; cell_end = ras.buffer_size; - cell_end -= cell_end % sizeof( TCell ); + cell_end -= cell_end % sizeof ( TCell ); cells_max = (PCell)( (char*)ras.buffer + cell_end ); ras.cells = (PCell)( (char*)ras.buffer + cell_start ); @@ -1851,12 +1862,12 @@ typedef ptrdiff_t FT_PtrDist; static int - gray_raster_render( PRaster raster, + gray_raster_render( gray_PRaster raster, const FT_Raster_Params* params ) { const FT_Outline* outline = (const FT_Outline*)params->source; const FT_Bitmap* target_map = params->target; - PWorker worker; + gray_PWorker worker; if ( !raster || !raster->buffer || !raster->buffer_size ) @@ -1948,7 +1959,7 @@ typedef ptrdiff_t FT_PtrDist; gray_raster_new( void* memory, FT_Raster* araster ) { - static TRaster the_raster; + static gray_TRaster the_raster; FT_UNUSED( memory ); @@ -1973,15 +1984,15 @@ typedef ptrdiff_t FT_PtrDist; gray_raster_new( FT_Memory memory, FT_Raster* araster ) { - FT_Error error; - PRaster raster = NULL; + FT_Error error; + gray_PRaster raster = NULL; *araster = 0; - if ( !FT_ALLOC( raster, sizeof ( TRaster ) ) ) + if ( !FT_ALLOC( raster, sizeof ( gray_TRaster ) ) ) { raster->memory = memory; - *araster = (FT_Raster)raster; + *araster = (FT_Raster)raster; } return error; @@ -1991,7 +2002,7 @@ typedef ptrdiff_t FT_PtrDist; static void gray_raster_done( FT_Raster raster ) { - FT_Memory memory = (FT_Memory)((PRaster)raster)->memory; + FT_Memory memory = (FT_Memory)((gray_PRaster)raster)->memory; FT_FREE( raster ); @@ -2005,19 +2016,20 @@ typedef ptrdiff_t FT_PtrDist; char* pool_base, long pool_size ) { - PRaster rast = (PRaster)raster; + gray_PRaster rast = (gray_PRaster)raster; if ( raster ) { - if ( pool_base && pool_size >= (long)sizeof ( TWorker ) + 2048 ) + if ( pool_base && pool_size >= (long)sizeof ( gray_TWorker ) + 2048 ) { - PWorker worker = (PWorker)pool_base; + gray_PWorker worker = (gray_PWorker)pool_base; rast->worker = worker; rast->buffer = pool_base + - ( ( sizeof ( TWorker ) + sizeof ( TCell ) - 1 ) & + ( ( sizeof ( gray_TWorker ) + + sizeof ( TCell ) - 1 ) & ~( sizeof ( TCell ) - 1 ) ); rast->buffer_size = (long)( ( pool_base + pool_size ) - (char*)rast->buffer ) & diff --git a/src/smooth/ftsmerrs.h b/src/smooth/ftsmerrs.h index 0c2a2ec..413d2f1 100644 --- a/src/smooth/ftsmerrs.h +++ b/src/smooth/ftsmerrs.h @@ -4,7 +4,7 @@ /* */ /* smooth renderer error codes (specification only). */ /* */ -/* Copyright 2001 by */ +/* Copyright 2001, 2012 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -30,6 +30,7 @@ #undef __FTERRORS_H__ +#undef FT_ERR_PREFIX #define FT_ERR_PREFIX Smooth_Err_ #define FT_ERR_BASE FT_Mod_Err_Smooth diff --git a/src/smooth/ftsmooth.c b/src/smooth/ftsmooth.c index 1350a56..00499cc 100644 --- a/src/smooth/ftsmooth.c +++ b/src/smooth/ftsmooth.c @@ -4,7 +4,7 @@ /* */ /* Anti-aliasing renderer interface (body). */ /* */ -/* Copyright 2000-2006, 2009-2011 by */ +/* Copyright 2000-2006, 2009-2012 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -105,9 +105,9 @@ FT_Error error; FT_Outline* outline = NULL; FT_BBox cbox; - FT_UInt width, height, pitch; + FT_Pos width, height, pitch; #ifndef FT_CONFIG_OPTION_SUBPIXEL_RENDERING - FT_UInt height_org, width_org; + FT_Pos height_org, width_org; #endif FT_Bitmap* bitmap; FT_Memory memory; @@ -151,7 +151,7 @@ return Smooth_Err_Raster_Overflow; } else - width = (FT_UInt)( ( cbox.xMax - cbox.xMin ) >> 6 ); + width = ( cbox.xMax - cbox.xMin ) >> 6; if ( cbox.yMin < 0 && cbox.yMax > FT_INT_MAX + cbox.yMin ) { @@ -161,7 +161,7 @@ return Smooth_Err_Raster_Overflow; } else - height = (FT_UInt)( ( cbox.yMax - cbox.yMin ) >> 6 ); + height = ( cbox.yMax - cbox.yMin ) >> 6; bitmap = &slot->bitmap; memory = render->root.memory; @@ -223,7 +223,7 @@ /* Required check is ( pitch * height < FT_ULONG_MAX ), */ /* but we care realistic cases only. Always pitch <= width. */ - if ( width > 0x7FFFU || height > 0x7FFFU ) + if ( width > 0x7FFF || height > 0x7FFF ) { FT_ERROR(( "ft_smooth_render_generic: glyph too large: %u x %u\n", width, height )); @@ -421,10 +421,10 @@ } - FT_DEFINE_RENDERER(ft_smooth_renderer_class, + FT_DEFINE_RENDERER( ft_smooth_renderer_class, FT_MODULE_RENDERER, - sizeof( FT_RendererRec ), + sizeof ( FT_RendererRec ), "smooth", 0x10000L, @@ -448,10 +448,10 @@ ) - FT_DEFINE_RENDERER(ft_smooth_lcd_renderer_class, - + FT_DEFINE_RENDERER( ft_smooth_lcd_renderer_class, + FT_MODULE_RENDERER, - sizeof( FT_RendererRec ), + sizeof ( FT_RendererRec ), "smooth-lcd", 0x10000L, @@ -474,10 +474,10 @@ (FT_Raster_Funcs*) &FT_GRAYS_RASTER_GET ) - FT_DEFINE_RENDERER(ft_smooth_lcdv_renderer_class, + FT_DEFINE_RENDERER( ft_smooth_lcdv_renderer_class, FT_MODULE_RENDERER, - sizeof( FT_RendererRec ), + sizeof ( FT_RendererRec ), "smooth-lcdv", 0x10000L, diff --git a/src/smooth/ftspic.c b/src/smooth/ftspic.c index 7adaab1..601bcf9 100644 --- a/src/smooth/ftspic.c +++ b/src/smooth/ftspic.c @@ -20,21 +20,27 @@ #include FT_FREETYPE_H #include FT_INTERNAL_OBJECTS_H #include "ftspic.h" +#include "ftsmerrs.h" #ifdef FT_CONFIG_OPTION_PIC /* forward declaration of PIC init functions from ftgrays.c */ - void FT_Init_Class_ft_grays_raster(FT_Raster_Funcs*); + void + FT_Init_Class_ft_grays_raster( FT_Raster_Funcs* funcs ); void - ft_smooth_renderer_class_pic_free( FT_Library library ) + ft_smooth_renderer_class_pic_free( FT_Library library ) { - FT_PIC_Container* pic_container = &library->pic_container; - FT_Memory memory = library->memory; + FT_PIC_Container* pic_container = &library->pic_container; + FT_Memory memory = library->memory; + + if ( pic_container->smooth ) { - SmoothPIC* container = (SmoothPIC*)pic_container->smooth; - if(--container->ref_count) + SmoothPIC* container = (SmoothPIC*)pic_container->smooth; + + + if ( --container->ref_count ) return; FT_FREE( container ); pic_container->smooth = NULL; @@ -51,9 +57,9 @@ FT_Memory memory = library->memory; - /* since this function also serve smooth_lcd and smooth_lcdv renderers, + /* since this function also serve smooth_lcd and smooth_lcdv renderers, it implements reference counting */ - if(pic_container->smooth) + if ( pic_container->smooth ) { ((SmoothPIC*)pic_container->smooth)->ref_count++; return error; @@ -62,34 +68,37 @@ /* allocate pointer, clear and set global container pointer */ if ( FT_ALLOC ( container, sizeof ( *container ) ) ) return error; - FT_MEM_SET( container, 0, sizeof(*container) ); + FT_MEM_SET( container, 0, sizeof ( *container ) ); pic_container->smooth = container; container->ref_count = 1; /* initialize pointer table - this is how the module usually expects this data */ - FT_Init_Class_ft_grays_raster(&container->ft_grays_raster); + FT_Init_Class_ft_grays_raster( &container->ft_grays_raster ); /*Exit:*/ - if(error) - ft_smooth_renderer_class_pic_free(library); + if ( error ) + ft_smooth_renderer_class_pic_free( library ); return error; } /* re-route these init and free functions to the above functions */ - FT_Error ft_smooth_lcd_renderer_class_pic_init(FT_Library library) + FT_Error ft_smooth_lcd_renderer_class_pic_init( FT_Library library ) { - return ft_smooth_renderer_class_pic_init(library); + return ft_smooth_renderer_class_pic_init( library ); } - void ft_smooth_lcd_renderer_class_pic_free(FT_Library library) + + void ft_smooth_lcd_renderer_class_pic_free( FT_Library library ) { - ft_smooth_renderer_class_pic_free(library); + ft_smooth_renderer_class_pic_free( library ); } - FT_Error ft_smooth_lcdv_renderer_class_pic_init(FT_Library library) + + FT_Error ft_smooth_lcdv_renderer_class_pic_init( FT_Library library ) { - return ft_smooth_renderer_class_pic_init(library); + return ft_smooth_renderer_class_pic_init( library ); } - void ft_smooth_lcdv_renderer_class_pic_free(FT_Library library) + + void ft_smooth_lcdv_renderer_class_pic_free( FT_Library library ) { - ft_smooth_renderer_class_pic_free(library); + ft_smooth_renderer_class_pic_free( library ); } #endif /* FT_CONFIG_OPTION_PIC */ diff --git a/src/smooth/ftspic.h b/src/smooth/ftspic.h index c7e0ce9..4686f5e 100644 --- a/src/smooth/ftspic.h +++ b/src/smooth/ftspic.h @@ -19,7 +19,7 @@ #ifndef __FTSPIC_H__ #define __FTSPIC_H__ - + FT_BEGIN_HEADER #include FT_INTERNAL_PIC_H @@ -38,6 +38,25 @@ FT_BEGIN_HEADER #define GET_PIC(lib) ((SmoothPIC*)((lib)->pic_container.smooth)) #define FT_GRAYS_RASTER_GET (GET_PIC(library)->ft_grays_raster) + /* see ftspic.c for the implementation */ + void + ft_smooth_renderer_class_pic_free( FT_Library library ); + + void + ft_smooth_lcd_renderer_class_pic_free( FT_Library library ); + + void + ft_smooth_lcdv_renderer_class_pic_free( FT_Library library ); + + FT_Error + ft_smooth_renderer_class_pic_init( FT_Library library ); + + FT_Error + ft_smooth_lcd_renderer_class_pic_init( FT_Library library ); + + FT_Error + ft_smooth_lcdv_renderer_class_pic_init( FT_Library library ); + #endif /* FT_CONFIG_OPTION_PIC */ /* */ diff --git a/src/truetype/ttdriver.c b/src/truetype/ttdriver.c index e70a611..3669d45 100644 --- a/src/truetype/ttdriver.c +++ b/src/truetype/ttdriver.c @@ -4,7 +4,7 @@ /* */ /* TrueType font driver implementation (body). */ /* */ -/* Copyright 1996-2011 by */ +/* Copyright 1996-2012 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -258,7 +258,7 @@ /*************************************************************************/ /* */ /* <Function> */ - /* Load_Glyph */ + /* tt_glyph_load */ /* */ /* <Description> */ /* A driver method used to load a glyph within a given glyph slot. */ @@ -282,10 +282,10 @@ /* FreeType error code. 0 means success. */ /* */ static FT_Error - Load_Glyph( FT_GlyphSlot ttslot, /* TT_GlyphSlot */ - FT_Size ttsize, /* TT_Size */ - FT_UInt glyph_index, - FT_Int32 load_flags ) + tt_glyph_load( FT_GlyphSlot ttslot, /* TT_GlyphSlot */ + FT_Size ttsize, /* TT_Size */ + FT_UInt glyph_index, + FT_Int32 load_flags ) { TT_GlyphSlot slot = (TT_GlyphSlot)ttslot; TT_Size size = (TT_Size)ttsize; @@ -313,7 +313,7 @@ if ( load_flags & FT_LOAD_NO_HINTING ) { /* both FT_LOAD_NO_HINTING and FT_LOAD_NO_AUTOHINT */ - /* are necessary to disable hinting for tricky fonts */ + /* are necessary to disable hinting for tricky fonts */ if ( FT_IS_TRICKY( face ) ) load_flags &= ~FT_LOAD_NO_HINTING; @@ -402,19 +402,35 @@ tt_get_interface( FT_Module driver, /* TT_Driver */ const char* tt_interface ) { + FT_Library library; FT_Module_Interface result; FT_Module sfntd; SFNT_Service sfnt; + + /* FT_TT_SERVICES_GET derefers `library' in PIC mode */ +#ifdef FT_CONFIG_OPTION_PIC + if ( !driver ) + return NULL; + library = driver->library; + if ( !library ) + return NULL; +#endif + result = ft_service_list_lookup( FT_TT_SERVICES_GET, tt_interface ); if ( result != NULL ) return result; +#ifndef FT_CONFIG_OPTION_PIC if ( !driver ) return NULL; + library = driver->library; + if ( !library ) + return NULL; +#endif /* only return the default interface from the SFNT module */ - sfntd = FT_Get_Module( driver->library, "sfnt" ); + sfntd = FT_Get_Module( library, "sfnt" ); if ( sfntd ) { sfnt = (SFNT_Service)( sfntd->clazz->module_interface ); @@ -440,11 +456,10 @@ #define TT_SIZE_SELECT 0 #endif - FT_DEFINE_DRIVER(tt_driver_class, - - - FT_MODULE_FONT_DRIVER | - FT_MODULE_DRIVER_SCALABLE | + FT_DEFINE_DRIVER( tt_driver_class, + + FT_MODULE_FONT_DRIVER | + FT_MODULE_DRIVER_SCALABLE | TT_HINTER_FLAG, sizeof ( TT_DriverRec ), @@ -468,15 +483,15 @@ tt_size_init, tt_size_done, tt_slot_init, - 0, /* FT_Slot_DoneFunc */ + 0, /* FT_Slot_DoneFunc */ - ft_stub_set_char_sizes, /* FT_CONFIG_OPTION_OLD_INTERNALS */ + ft_stub_set_char_sizes, /* FT_CONFIG_OPTION_OLD_INTERNALS */ ft_stub_set_pixel_sizes, /* FT_CONFIG_OPTION_OLD_INTERNALS */ - Load_Glyph, + tt_glyph_load, tt_get_kerning, - 0, /* FT_Face_AttachFunc */ + 0, /* FT_Face_AttachFunc */ tt_get_advances, tt_size_request, diff --git a/src/truetype/tterrors.h b/src/truetype/tterrors.h index d317c70..78d138f 100644 --- a/src/truetype/tterrors.h +++ b/src/truetype/tterrors.h @@ -4,7 +4,7 @@ /* */ /* TrueType error codes (specification only). */ /* */ -/* Copyright 2001 by */ +/* Copyright 2001, 2012 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -30,6 +30,7 @@ #undef __FTERRORS_H__ +#undef FT_ERR_PREFIX #define FT_ERR_PREFIX TT_Err_ #define FT_ERR_BASE FT_Mod_Err_TrueType diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c index f35521e..ce8c888 100644 --- a/src/truetype/ttgload.c +++ b/src/truetype/ttgload.c @@ -4,7 +4,7 @@ /* */ /* TrueType Glyph Loader (body). */ /* */ -/* Copyright 1996-2011 */ +/* Copyright 1996-2012 */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -362,19 +362,21 @@ if ( n_contours >= 0xFFF || p + ( n_contours + 1 ) * 2 > limit ) goto Invalid_Outline; - prev_cont = FT_NEXT_USHORT( p ); + prev_cont = FT_NEXT_SHORT( p ); if ( n_contours > 0 ) cont[0] = prev_cont; + if ( prev_cont < 0 ) + goto Invalid_Outline; + for ( cont++; cont < cont_limit; cont++ ) { - cont[0] = FT_NEXT_USHORT( p ); + cont[0] = FT_NEXT_SHORT( p ); if ( cont[0] <= prev_cont ) { /* unordered contours: this is invalid */ - error = TT_Err_Invalid_Table; - goto Fail; + goto Invalid_Outline; } prev_cont = cont[0]; } @@ -392,13 +394,6 @@ if ( error ) goto Fail; - /* we'd better check the contours table right now */ - outline = &gloader->current.outline; - - for ( cont = outline->contours + 1; cont < cont_limit; cont++ ) - if ( cont[-1] >= cont[0] ) - goto Invalid_Outline; - /* reading the bytecode instructions */ load->glyph->control_len = 0; load->glyph->control_data = 0; @@ -439,6 +434,8 @@ p += n_ins; + outline = &gloader->current.outline; + /* reading the point tags */ flag = (FT_Byte*)outline->tags; flag_limit = flag + n_points; diff --git a/src/truetype/ttinterp.c b/src/truetype/ttinterp.c index c62c589..3acb24a 100644 --- a/src/truetype/ttinterp.c +++ b/src/truetype/ttinterp.c @@ -4,7 +4,7 @@ /* */ /* TrueType bytecode interpreter (body). */ /* */ -/* Copyright 1996-2011 */ +/* Copyright 1996-2012 */ /* by David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -715,7 +715,7 @@ FT_Error error; - if ( ( error = TT_Goto_CodeRange( exec, tt_coderange_glyph, 0 ) ) + if ( ( error = TT_Goto_CodeRange( exec, tt_coderange_glyph, 0 ) ) != TT_Err_Ok ) return error; @@ -1800,7 +1800,7 @@ /* NOTE: Because the last instruction of a program may be a CALL */ /* which will return to the first byte *after* the code */ - /* range, we test for AIP <= Size, instead of AIP < Size. */ + /* range, we test for aIP <= Size, instead of aIP < Size. */ if ( aIP > range->size ) { @@ -2757,7 +2757,7 @@ W = Vx * Vx + Vy * Vy; /* Now, we want that Sqrt( W ) = 0x4000 */ - /* Or 0x10000000 <= W < 0x10004000 */ + /* Or 0x10000000 <= W < 0x10004000 */ if ( Vx < 0 ) { @@ -3199,36 +3199,42 @@ } -#define DO_JROT \ - if ( args[1] != 0 ) \ - { \ - if ( args[0] == 0 && CUR.args == 0 ) \ - CUR.error = TT_Err_Bad_Argument; \ - CUR.IP += args[0]; \ - if ( CUR.IP < 0 ) \ - CUR.error = TT_Err_Bad_Argument; \ - CUR.step_ins = FALSE; \ +#define DO_JROT \ + if ( args[1] != 0 ) \ + { \ + if ( args[0] == 0 && CUR.args == 0 ) \ + CUR.error = TT_Err_Bad_Argument; \ + CUR.IP += args[0]; \ + if ( CUR.IP < 0 || \ + ( CUR.callTop > 0 && \ + CUR.IP > CUR.callStack[CUR.callTop - 1].Cur_End ) ) \ + CUR.error = TT_Err_Bad_Argument; \ + CUR.step_ins = FALSE; \ } -#define DO_JMPR \ - if ( args[0] == 0 && CUR.args == 0 ) \ - CUR.error = TT_Err_Bad_Argument; \ - CUR.IP += args[0]; \ - if ( CUR.IP < 0 ) \ - CUR.error = TT_Err_Bad_Argument; \ +#define DO_JMPR \ + if ( args[0] == 0 && CUR.args == 0 ) \ + CUR.error = TT_Err_Bad_Argument; \ + CUR.IP += args[0]; \ + if ( CUR.IP < 0 || \ + ( CUR.callTop > 0 && \ + CUR.IP > CUR.callStack[CUR.callTop - 1].Cur_End ) ) \ + CUR.error = TT_Err_Bad_Argument; \ CUR.step_ins = FALSE; -#define DO_JROF \ - if ( args[1] == 0 ) \ - { \ - if ( args[0] == 0 && CUR.args == 0 ) \ - CUR.error = TT_Err_Bad_Argument; \ - CUR.IP += args[0]; \ - if ( CUR.IP < 0 ) \ - CUR.error = TT_Err_Bad_Argument; \ - CUR.step_ins = FALSE; \ +#define DO_JROF \ + if ( args[1] == 0 ) \ + { \ + if ( args[0] == 0 && CUR.args == 0 ) \ + CUR.error = TT_Err_Bad_Argument; \ + CUR.IP += args[0]; \ + if ( CUR.IP < 0 || \ + ( CUR.callTop > 0 && \ + CUR.IP > CUR.callStack[CUR.callTop - 1].Cur_End ) ) \ + CUR.error = TT_Err_Bad_Argument; \ + CUR.step_ins = FALSE; \ } @@ -4471,7 +4477,7 @@ CUR.length = opcode_length[CUR.opcode]; if ( CUR.length < 0 ) { - if ( CUR.IP + 1 > CUR.codeSize ) + if ( CUR.IP + 1 >= CUR.codeSize ) goto Fail_Overflow; CUR.length = 2 - CUR.length * CUR.code[CUR.IP + 1]; } @@ -4640,6 +4646,7 @@ return; case 0x2D: /* ENDF */ + rec->end = CUR.IP; return; } } @@ -4757,6 +4764,7 @@ pCrec->Caller_IP = CUR.IP + 1; pCrec->Cur_Count = 1; pCrec->Cur_Restart = def->start; + pCrec->Cur_End = def->end; CUR.callTop++; @@ -4835,6 +4843,7 @@ pCrec->Caller_IP = CUR.IP + 1; pCrec->Cur_Count = (FT_Int)args[0]; pCrec->Cur_Restart = def->start; + pCrec->Cur_End = def->end; CUR.callTop++; @@ -5050,8 +5059,8 @@ /* Opcode range: 0x46-0x47 */ /* Stack: uint32 --> f26.6 */ /* */ - /* BULLSHIT: Measures from the original glyph must be taken along the */ - /* dual projection vector! */ + /* XXX: UNDOCUMENTED: Measures from the original glyph must be taken */ + /* along the dual projection vector! */ /* */ static void Ins_GC( INS_ARG ) @@ -5123,14 +5132,14 @@ /* Opcode range: 0x49-0x4A */ /* Stack: uint32 uint32 --> f26.6 */ /* */ - /* BULLSHIT: Measure taken in the original glyph must be along the dual */ - /* projection vector. */ + /* XXX: UNDOCUMENTED: Measure taken in the original glyph must be along */ + /* the dual projection vector. */ /* */ - /* Second BULLSHIT: Flag attributes are inverted! */ - /* 0 => measure distance in original outline */ - /* 1 => measure distance in grid-fitted outline */ + /* XXX: UNDOCUMENTED: Flag attributes are inverted! */ + /* 0 => measure distance in original outline */ + /* 1 => measure distance in grid-fitted outline */ /* */ - /* Third one: `zp0 - zp1', and not `zp2 - zp1! */ + /* XXX: UNDOCUMENTED: `zp0 - zp1', and not `zp2 - zp1! */ /* */ static void Ins_MD( INS_ARG ) @@ -5761,21 +5770,25 @@ /* Opcode range: 0x34-35 */ /* Stack: uint32 --> */ /* */ + /* UNDOCUMENTED: According to Greg Hitchcock, there is one (virtual) */ + /* contour in the twilight zone, namely contour number */ + /* zero. */ + /* */ static void Ins_SHC( INS_ARG ) { - TT_GlyphZoneRec zp; - FT_UShort refp; - FT_F26Dot6 dx, - dy; + TT_GlyphZoneRec zp; + FT_UShort refp; + FT_F26Dot6 dx, dy; - FT_Short contour; - FT_UShort first_point, last_point, i; + FT_Short contour, bounds; + FT_UShort start, limit, i; contour = (FT_UShort)args[0]; + bounds = ( CUR.GS.gep2 == 0 ) ? 1 : CUR.zp2.n_contours; - if ( BOUNDS( contour, CUR.pts.n_contours ) ) + if ( BOUNDS( contour, bounds ) ) { if ( CUR.pedantic_hinting ) CUR.error = TT_Err_Invalid_Reference; @@ -5786,25 +5799,19 @@ return; if ( contour == 0 ) - first_point = 0; + start = 0; else - first_point = (FT_UShort)( CUR.pts.contours[contour - 1] + 1 - - CUR.pts.first_point ); + start = (FT_UShort)( CUR.zp2.contours[contour - 1] + 1 - + CUR.zp2.first_point ); - last_point = (FT_UShort)( CUR.pts.contours[contour] - - CUR.pts.first_point ); - - /* XXX: this is probably wrong... at least it prevents memory */ - /* corruption when zp2 is the twilight zone */ - if ( BOUNDS( last_point, CUR.zp2.n_points ) ) - { - if ( CUR.zp2.n_points > 0 ) - last_point = (FT_UShort)(CUR.zp2.n_points - 1); - else - last_point = 0; - } + /* we use the number of points if in the twilight zone */ + if ( CUR.GS.gep2 == 0 ) + limit = CUR.zp2.n_points; + else + limit = (FT_UShort)( CUR.zp2.contours[contour] - + CUR.zp2.first_point + 1 ); - for ( i = first_point; i <= last_point; i++ ) + for ( i = start; i < limit; i++ ) { if ( zp.cur != CUR.zp2.cur || refp != i ) MOVE_Zp2_Point( i, dx, dy, TRUE ); @@ -5826,7 +5833,7 @@ FT_F26Dot6 dx, dy; - FT_UShort last_point, i; + FT_UShort limit, i; if ( BOUNDS( args[0], 2 ) ) @@ -5839,28 +5846,19 @@ if ( COMPUTE_Point_Displacement( &dx, &dy, &zp, &refp ) ) return; - /* XXX: UNDOCUMENTED! SHZ doesn't move the phantom points. */ - /* Twilight zone has no contours, so use `n_points'. */ - /* Normal zone's `n_points' includes phantoms, so must */ - /* use end of last contour. */ - if ( CUR.GS.gep2 == 0 && CUR.zp2.n_points > 0 ) - last_point = (FT_UShort)( CUR.zp2.n_points - 1 ); + /* XXX: UNDOCUMENTED! SHZ doesn't move the phantom points. */ + /* Twilight zone has no real contours, so use `n_points'. */ + /* Normal zone's `n_points' includes phantoms, so must */ + /* use end of last contour. */ + if ( CUR.GS.gep2 == 0 ) + limit = (FT_UShort)CUR.zp2.n_points; else if ( CUR.GS.gep2 == 1 && CUR.zp2.n_contours > 0 ) - { - last_point = (FT_UShort)( CUR.zp2.contours[CUR.zp2.n_contours - 1] ); - - if ( BOUNDS( last_point, CUR.zp2.n_points ) ) - { - if ( CUR.pedantic_hinting ) - CUR.error = TT_Err_Invalid_Reference; - return; - } - } + limit = (FT_UShort)( CUR.zp2.contours[CUR.zp2.n_contours - 1] + 1 ); else - last_point = 0; + limit = 0; /* XXX: UNDOCUMENTED! SHZ doesn't touch the points */ - for ( i = 0; i <= last_point; i++ ) + for ( i = 0; i < limit; i++ ) { if ( zp.cur != CUR.zp2.cur || refp != i ) MOVE_Zp2_Point( i, dx, dy, FALSE ); @@ -6266,7 +6264,7 @@ CUR.zp1.org[point].y = CUR.zp0.org[CUR.GS.rp0].y + TT_MulFix14( (FT_UInt32)cvt_dist, CUR.GS.freeVector.y ); - CUR.zp1.cur[point] = CUR.zp0.cur[point]; + CUR.zp1.cur[point] = CUR.zp1.org[point]; } org_dist = CUR_Func_dualproj( &CUR.zp1.org[point], @@ -6575,9 +6573,21 @@ if ( twilight ) old_range = CUR_Func_dualproj( &CUR.zp1.org[CUR.GS.rp2], orus_base ); - else + else if ( CUR.metrics.x_scale == CUR.metrics.y_scale ) old_range = CUR_Func_dualproj( &CUR.zp1.orus[CUR.GS.rp2], orus_base ); + else + { + FT_Vector vec; + + + vec.x = TT_MULFIX( CUR.zp1.orus[CUR.GS.rp2].x - orus_base->x, + CUR.metrics.x_scale ); + vec.y = TT_MULFIX( CUR.zp1.orus[CUR.GS.rp2].y - orus_base->y, + CUR.metrics.y_scale ); + + old_range = CUR_fast_dualproj( &vec ); + } cur_range = CUR_Func_project ( &CUR.zp1.cur[CUR.GS.rp2], cur_base ); } @@ -6601,8 +6611,20 @@ if ( twilight ) org_dist = CUR_Func_dualproj( &CUR.zp2.org[point], orus_base ); - else + else if ( CUR.metrics.x_scale == CUR.metrics.y_scale ) org_dist = CUR_Func_dualproj( &CUR.zp2.orus[point], orus_base ); + else + { + FT_Vector vec; + + + vec.x = TT_MULFIX( CUR.zp2.orus[point].x - orus_base->x, + CUR.metrics.x_scale ); + vec.y = TT_MULFIX( CUR.zp2.orus[point].y - orus_base->y, + CUR.metrics.y_scale ); + + org_dist = CUR_fast_dualproj( &vec ); + } cur_dist = CUR_Func_project ( &CUR.zp2.cur[point], cur_base ); @@ -7149,6 +7171,7 @@ call->Caller_IP = CUR.IP + 1; call->Cur_Count = 1; call->Cur_Restart = def->start; + call->Cur_End = def->end; INS_Goto_CodeRange( def->range, def->start ); @@ -7521,7 +7544,7 @@ if ( ( CUR.length = opcode_length[CUR.opcode] ) < 0 ) { - if ( CUR.IP + 1 > CUR.codeSize ) + if ( CUR.IP + 1 >= CUR.codeSize ) goto LErrorCodeOverflow_; CUR.length = 2 - CUR.length * CUR.code[CUR.IP + 1]; @@ -8157,6 +8180,7 @@ callrec->Caller_IP = CUR.IP + 1; callrec->Cur_Count = 1; callrec->Cur_Restart = def->start; + callrec->Cur_End = def->end; if ( INS_Goto_CodeRange( def->range, def->start ) == FAILURE ) goto LErrorLabel_; @@ -8230,7 +8254,7 @@ if ( CUR.error && !CUR.instruction_trap ) { FT_TRACE1(( " The interpreter returned error 0x%x\n", CUR.error )); - exc->size->cvt_ready = FALSE; + exc->size->cvt_ready = FALSE; } return CUR.error; diff --git a/src/truetype/ttinterp.h b/src/truetype/ttinterp.h index c480dfa..6d0fc03 100644 --- a/src/truetype/ttinterp.h +++ b/src/truetype/ttinterp.h @@ -102,6 +102,7 @@ FT_BEGIN_HEADER FT_Long Caller_IP; FT_Long Cur_Count; FT_Long Cur_Restart; + FT_Long Cur_End; } TT_CallRec, *TT_CallStack; diff --git a/src/truetype/ttobjs.c b/src/truetype/ttobjs.c index d77c3c4..814c713 100644 --- a/src/truetype/ttobjs.c +++ b/src/truetype/ttobjs.c @@ -328,7 +328,7 @@ FT_MEM_SET( num_matched_ids, 0, - sizeof( int ) * TRICK_SFNT_IDS_NUM_FACES ); + sizeof ( int ) * TRICK_SFNT_IDS_NUM_FACES ); has_cvt = FALSE; has_fpgm = FALSE; has_prep = FALSE; @@ -493,10 +493,17 @@ TT_Face face = (TT_Face)ttface; + FT_TRACE2(( "TTF driver\n" )); + library = ttface->driver->root.library; - sfnt = (SFNT_Service)FT_Get_Module_Interface( library, "sfnt" ); + + sfnt = (SFNT_Service)FT_Get_Module_Interface( library, "sfnt" ); if ( !sfnt ) - goto Bad_Format; + { + FT_ERROR(( "tt_face_init: cannot access `sfnt' module\n" )); + error = TT_Err_Missing_Module; + goto Exit; + } /* create input stream from resource */ if ( FT_STREAM_SEEK( 0 ) ) @@ -514,7 +521,7 @@ face->format_tag != 0x00020000L && /* CJK fonts for Win 3.1 */ face->format_tag != TTAG_true ) /* Mac fonts */ { - FT_TRACE2(( "[not a valid TTF font]\n" )); + FT_TRACE2(( " not a TTF font\n" )); goto Bad_Format; } diff --git a/src/truetype/ttobjs.h b/src/truetype/ttobjs.h index 087b3c2..47e4129 100644 --- a/src/truetype/ttobjs.h +++ b/src/truetype/ttobjs.h @@ -4,7 +4,7 @@ /* */ /* Objects manager (specification). */ /* */ -/* Copyright 1996-2009, 2011 by */ +/* Copyright 1996-2009, 2011-2012 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -175,6 +175,7 @@ FT_BEGIN_HEADER { FT_Int range; /* in which code range is it located? */ FT_Long start; /* where does it start? */ + FT_Long end; /* where does it end? */ FT_UInt opc; /* function #, or instruction code */ FT_Bool active; /* is it active? */ diff --git a/src/truetype/ttpic.c b/src/truetype/ttpic.c index 5d72574..65ca845 100644 --- a/src/truetype/ttpic.c +++ b/src/truetype/ttpic.c @@ -20,25 +20,41 @@ #include FT_FREETYPE_H #include FT_INTERNAL_OBJECTS_H #include "ttpic.h" +#include "tterrors.h" #ifdef FT_CONFIG_OPTION_PIC /* forward declaration of PIC init functions from ttdriver.c */ - FT_Error FT_Create_Class_tt_services( FT_Library, FT_ServiceDescRec**); - void FT_Destroy_Class_tt_services( FT_Library, FT_ServiceDescRec*); - void FT_Init_Class_tt_service_gx_multi_masters(FT_Service_MultiMastersRec*); - void FT_Init_Class_tt_service_truetype_glyf(FT_Service_TTGlyfRec*); + FT_Error + FT_Create_Class_tt_services( FT_Library library, + FT_ServiceDescRec** output_class ); + + void + FT_Destroy_Class_tt_services( FT_Library library, + FT_ServiceDescRec* clazz ); + + void + FT_Init_Class_tt_service_gx_multi_masters( + FT_Service_MultiMastersRec* sv_mm ); + + void + FT_Init_Class_tt_service_truetype_glyf( + FT_Service_TTGlyfRec* sv_ttglyf ); void - tt_driver_class_pic_free( FT_Library library ) + tt_driver_class_pic_free( FT_Library library ) { - FT_PIC_Container* pic_container = &library->pic_container; - FT_Memory memory = library->memory; + FT_PIC_Container* pic_container = &library->pic_container; + FT_Memory memory = library->memory; + + if ( pic_container->truetype ) { - TTModulePIC* container = (TTModulePIC*)pic_container->truetype; - if(container->tt_services) - FT_Destroy_Class_tt_services(library, container->tt_services); + TTModulePIC* container = (TTModulePIC*)pic_container->truetype; + + + if ( container->tt_services ) + FT_Destroy_Class_tt_services( library, container->tt_services ); container->tt_services = NULL; FT_FREE( container ); pic_container->truetype = NULL; @@ -58,20 +74,23 @@ /* allocate pointer, clear and set global container pointer */ if ( FT_ALLOC ( container, sizeof ( *container ) ) ) return error; - FT_MEM_SET( container, 0, sizeof(*container) ); + FT_MEM_SET( container, 0, sizeof ( *container ) ); pic_container->truetype = container; /* initialize pointer table - this is how the module usually expects this data */ - error = FT_Create_Class_tt_services(library, &container->tt_services); - if(error) + error = FT_Create_Class_tt_services( library, + &container->tt_services ); + if ( error ) goto Exit; #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT - FT_Init_Class_tt_service_gx_multi_masters(&container->tt_service_gx_multi_masters); + FT_Init_Class_tt_service_gx_multi_masters( + &container->tt_service_gx_multi_masters ); #endif - FT_Init_Class_tt_service_truetype_glyf(&container->tt_service_truetype_glyf); + FT_Init_Class_tt_service_truetype_glyf( + &container->tt_service_truetype_glyf ); Exit: - if(error) - tt_driver_class_pic_free(library); + if ( error ) + tt_driver_class_pic_free( library ); return error; } diff --git a/src/truetype/ttpic.h b/src/truetype/ttpic.h index 84de0fe..48f43a5 100644 --- a/src/truetype/ttpic.h +++ b/src/truetype/ttpic.h @@ -19,7 +19,7 @@ #ifndef __TTPIC_H__ #define __TTPIC_H__ - + FT_BEGIN_HEADER #ifndef FT_CONFIG_OPTION_PIC @@ -47,6 +47,13 @@ FT_BEGIN_HEADER #define FT_TT_SERVICE_GX_MULTI_MASTERS_GET (GET_PIC(library)->tt_service_gx_multi_masters) #define FT_TT_SERVICE_TRUETYPE_GLYF_GET (GET_PIC(library)->tt_service_truetype_glyf) + /* see ttpic.c for the implementation */ + void + tt_driver_class_pic_free( FT_Library library ); + + FT_Error + tt_driver_class_pic_init( FT_Library library ); + #endif /* FT_CONFIG_OPTION_PIC */ /* */ diff --git a/src/truetype/ttpload.c b/src/truetype/ttpload.c index 818b29d..bb6005d 100644 --- a/src/truetype/ttpload.c +++ b/src/truetype/ttpload.c @@ -4,7 +4,7 @@ /* */ /* TrueType-specific tables loader (body). */ /* */ -/* Copyright 1996-2002, 2004-2011 by */ +/* Copyright 1996-2002, 2004-2012 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -211,22 +211,22 @@ } /* Check broken location data */ - if ( pos1 >= face->glyf_len ) + if ( pos1 > face->glyf_len ) { FT_TRACE1(( "tt_face_get_location:" - " too large offset=0x%08lx found for gid=0x%04lx," - " exceeding the end of glyf table (0x%08lx)\n", - pos1, gindex, face->glyf_len )); + " too large offset=0x%08lx found for gid=0x%04lx," + " exceeding the end of glyf table (0x%08lx)\n", + pos1, gindex, face->glyf_len )); *asize = 0; return 0; } - if ( pos2 >= face->glyf_len ) + if ( pos2 > face->glyf_len ) { FT_TRACE1(( "tt_face_get_location:" - " too large offset=0x%08lx found for gid=0x%04lx," - " truncate at the end of glyf table (0x%08lx)\n", - pos2, gindex + 1, face->glyf_len )); + " too large offset=0x%08lx found for gid=0x%04lx," + " truncate at the end of glyf table (0x%08lx)\n", + pos2, gindex + 1, face->glyf_len )); pos2 = face->glyf_len; } |