diff --git a/include/freetype/internal/ftobjs.h b/include/freetype/internal/ftobjs.h index a15bab448..a1ed6c25d 100644 --- a/include/freetype/internal/ftobjs.h +++ b/include/freetype/internal/ftobjs.h @@ -106,25 +106,25 @@ } FT_ModuleRec; /* typecast an object to a FT_Module */ - #define FT_MODULE(x) ((FT_Module)(x)) - #define FT_MODULE_CLASS(x) FT_MODULE(x)->clazz - #define FT_MODULE_LIBRARY(x) FT_MODULE(x)->library - #define FT_MODULE_MEMORY(x) FT_MODULE(x)->memory +#define FT_MODULE(x) ((FT_Module)(x)) +#define FT_MODULE_CLASS(x) FT_MODULE(x)->clazz +#define FT_MODULE_LIBRARY(x) FT_MODULE(x)->library +#define FT_MODULE_MEMORY(x) FT_MODULE(x)->memory - #define FT_MODULE_IS_DRIVER(x) (FT_MODULE_CLASS(x)->module_flags & \ - ft_module_font_driver ) +#define FT_MODULE_IS_DRIVER(x) (FT_MODULE_CLASS(x)->module_flags & \ + ft_module_font_driver ) - #define FT_MODULE_IS_DRIVER(x) (FT_MODULE_CLASS(x)->module_flags & \ - ft_module_font_driver ) +#define FT_MODULE_IS_DRIVER(x) (FT_MODULE_CLASS(x)->module_flags & \ + ft_module_font_driver ) - #define FT_MODULE_IS_RENDERER(x) (FT_MODULE_CLASS(x)->module_flags & \ - ft_module_renderer ) +#define FT_MODULE_IS_RENDERER(x) (FT_MODULE_CLASS(x)->module_flags & \ + ft_module_renderer ) - #define FT_DRIVER_IS_SCALABLE(x) (FT_MODULE_CLASS(x)->module_flags & \ - ft_module_driver_scalable ) +#define FT_DRIVER_IS_SCALABLE(x) (FT_MODULE_CLASS(x)->module_flags & \ + ft_module_driver_scalable ) - #define FT_DRIVER_USES_OUTLINES(x) !(FT_MODULE_CLASS(x)->module_flags & \ - ft_module_driver_no_outlines ) +#define FT_DRIVER_USES_OUTLINES(x) !(FT_MODULE_CLASS(x)->module_flags & \ + ft_module_driver_no_outlines ) /*************************************************************************/ @@ -141,19 +141,19 @@ /* a few macros used to perform easy typecasts with minimal brain damage */ - #define FT_FACE(x) ((FT_Face)x) - #define FT_SIZE(x) ((FT_Size)x) - #define FT_SLOT(x) ((FT_GlyphSlot)x) +#define FT_FACE(x) ((FT_Face)x) +#define FT_SIZE(x) ((FT_Size)x) +#define FT_SLOT(x) ((FT_GlyphSlot)x) - #define FT_FACE_DRIVER(x) FT_FACE(x)->driver - #define FT_FACE_LIBRARY(x) FT_FACE_DRIVER(x)->root.library - #define FT_FACE_MEMORY(x) FT_FACE(x)->memory +#define FT_FACE_DRIVER(x) FT_FACE(x)->driver +#define FT_FACE_LIBRARY(x) FT_FACE_DRIVER(x)->root.library +#define FT_FACE_MEMORY(x) FT_FACE(x)->memory - #define FT_SIZE_FACE(x) FT_SIZE(x)->face - #define FT_SLOT_FACE(x) FT_SLOT(x)->face +#define FT_SIZE_FACE(x) FT_SIZE(x)->face +#define FT_SLOT_FACE(x) FT_SLOT(x)->face - #define FT_FACE_SLOT(x) FT_FACE(x)->glyph - #define FT_FACE_SIZE(x) FT_FACE(x)->size +#define FT_FACE_SLOT(x) FT_FACE(x)->glyph +#define FT_FACE_SIZE(x) FT_FACE(x)->size /* this must be kept exported - this will be used later in our own */ @@ -248,7 +248,7 @@ /*************************************************************************/ /*************************************************************************/ - #define FT_RENDERER(x) ((FT_Renderer)(x)) +#define FT_RENDERER(x) ((FT_Renderer)(x)) typedef struct FT_RendererRec_ { @@ -275,10 +275,10 @@ /*************************************************************************/ /* typecast a module into a driver easily */ - #define FT_DRIVER(x) ((FT_Driver)(x)) +#define FT_DRIVER(x) ((FT_Driver)(x)) /* typecast a module as a driver, and get its driver class */ - #define FT_DRIVER_CLASS(x) FT_DRIVER(x)->clazz +#define FT_DRIVER_CLASS(x) FT_DRIVER(x)->clazz /*************************************************************************/ /* */ diff --git a/include/freetype/internal/t2types.h b/include/freetype/internal/t2types.h index 2b015891b..39608a0fb 100644 --- a/include/freetype/internal/t2types.h +++ b/include/freetype/internal/t2types.h @@ -175,8 +175,8 @@ } CFF_SubFont; - /* maximum number of sub-fonts in a CID-keyed file */ - #define CFF_MAX_CID_FONTS 16 + /* maximum number of sub-fonts in a CID-keyed file */ +#define CFF_MAX_CID_FONTS 16 typedef struct CFF_Font_ { diff --git a/include/freetype/t1tables.h b/include/freetype/t1tables.h index 479c2d587..77feb9d45 100644 --- a/include/freetype/t1tables.h +++ b/include/freetype/t1tables.h @@ -140,13 +140,13 @@ } T1_Blend_Flags; /* maximum number of multiple-masters designs, per-se the spec */ - #define T1_MAX_MM_DESIGNS 16 +#define T1_MAX_MM_DESIGNS 16 /* maximum number of multiple-masters axis, per-se the spec */ - #define T1_MAX_MM_AXIS 4 +#define T1_MAX_MM_AXIS 4 /* maximum number of elements in a design map */ - #define T1_MAX_MM_MAP_POINTS 20 +#define T1_MAX_MM_MAP_POINTS 20 /* this structure is used to store the BlendDesignMap entry for an axis */ typedef struct T1_DesignMap_ diff --git a/src/base/ftcalc.c b/src/base/ftcalc.c index e0fdb7462..4d8bae64b 100644 --- a/src/base/ftcalc.c +++ b/src/base/ftcalc.c @@ -50,19 +50,19 @@ static const FT_Long ft_square_roots[63] = { - 1, 1, 2, 3, 4, 5, 8, 11, - 16, 22, 32, 45, 64, 90, 128, 181, - 256, 362, 512, 724, 1024, 1448, 2048, 2896, - 4096, 5892, 8192, 11585, 16384, 23170, 32768, 46340, + 1L, 1L, 2L, 3L, 4L, 5L, 8L, 11L, + 16L, 22L, 32L, 45L, 64L, 90L, 128L, 181L, + 256L, 362L, 512L, 724L, 1024L, 1448L, 2048L, 2896L, + 4096L, 5892L, 8192L, 11585L, 16384L, 23170L, 32768L, 46340L, - 65536, 92681, 131072, 185363, 262144, 370727, - 524288, 741455, 1048576, 1482910, 2097152, 2965820, - 4194304, 5931641, 8388608, 11863283, 16777216, 23726566, + 65536L, 92681L, 131072L, 185363L, 262144L, 370727L, + 524288L, 741455L, 1048576L, 1482910L, 2097152L, 2965820L, + 4194304L, 5931641L, 8388608L, 11863283L, 16777216L, 23726566L, - 33554432, 47453132, 67108864, 94906265, - 134217728, 189812531, 268435456, 379625062, - 536870912, 759250125, 1073741824, 1518500250, - 2147483647 + 33554432L, 47453132L, 67108864L, 94906265L, + 134217728L, 189812531L, 268435456L, 379625062L, + 536870912L, 759250125L, 1073741824L, 1518500250L, + 2147483647L }; #else @@ -102,8 +102,8 @@ root >>= 1; mask >>= 2; - } - while ( mask != 0 ); + + } while ( mask != 0 ); return root; } @@ -289,8 +289,8 @@ { s = r; r = ( r + l / r ) >> 1; - } - while ( r > s || r * r > l ); + + } while ( r > s || r * r > l ); return r; } @@ -487,14 +487,14 @@ } else { - /* we need more bits, we'll have to do it by hand */ + /* we need more bits; we have to do it by hand */ FT_Word32 c; q = ( a / b ) << 16; c = a % b; - /* we must compute C*0x10000/B; we simply shift C and B so */ + /* we must compute C*0x10000/B: we simply shift C and B so */ /* C becomes smaller than 16 bits */ while ( c >> 16 ) { @@ -601,7 +601,7 @@ if ( s < 0 ) { z->lo = (FT_Word32)-(FT_Int32)z->lo; - z->hi = ~z->hi + !(z->lo); + z->hi = ~z->hi + !( z->lo ); } } @@ -636,7 +636,7 @@ if ( s < 0 ) { x->lo = (FT_Word32)-(FT_Int32)x->lo; - x->hi = ~x->hi + !(x->lo); + x->hi = ~x->hi + !( x->lo ); } s ^= y; y = ABS( y ); @@ -759,8 +759,8 @@ r = ( r + FT_Div64by32( l, r ) ) >> 1; FT_MulTo64( r, r, &l2 ); FT_Sub64 ( l, &l2, &l2 ); - } - while ( r > s || (FT_Int32)l2.hi < 0 ); + + } while ( r > s || (FT_Int32)l2.hi < 0 ); return r; } diff --git a/src/base/ftdebug.c b/src/base/ftdebug.c index 72c44a3b0..32da7897e 100644 --- a/src/base/ftdebug.c +++ b/src/base/ftdebug.c @@ -103,7 +103,7 @@ if ( component >= trace_max ) return; - /* if component is `trace_any', then change _all_ levels at once */ + /* if component is `trace_any', change _all_ levels at once */ if ( component == trace_any ) { int n; diff --git a/src/base/ftextend.c b/src/base/ftextend.c index 0ac950156..782bb3e04 100644 --- a/src/base/ftextend.c +++ b/src/base/ftextend.c @@ -152,7 +152,8 @@ cur->offset = registry->cur_offset; registry->num_extensions++; - registry->cur_offset += ( cur->size + FT_ALIGNMENT-1 ) & -FT_ALIGNMENT; + registry->cur_offset += + ( cur->size + FT_ALIGNMENT - 1 ) & -FT_ALIGNMENT; FT_TRACE1(( "FT_Register_Extension: `%s' successfully registered\n", cur->id )); @@ -180,12 +181,12 @@ /* extension interface. */ /* */ /* */ - /* A pointer to the extension block. */ + /* A generic pointer to the extension block. */ /* */ FT_EXPORT_FUNC( void* ) FT_Get_Extension( FT_Face face, const char* extension_id, - void* *extension_interface ) + void** extension_interface ) { FT_Extension_Registry* registry; @@ -296,7 +297,7 @@ face->extensions = 0; - /* load extensions registry, exit successfully if none is there */ + /* load extensions registry; exit successfully if none is there */ registry = (FT_Extension_Registry*)face->driver->extensions; if ( !registry ) diff --git a/src/base/ftglyph.c b/src/base/ftglyph.c index 472143cf2..7d9f44342 100644 --- a/src/base/ftglyph.c +++ b/src/base/ftglyph.c @@ -42,6 +42,7 @@ #define FT_COMPONENT trace_glyph + /* a helper function to avoid duplication of code */ static void ft_prepare_glyph( FT_Glyph glyph, FT_Face face, @@ -122,13 +123,13 @@ FT_Vector* origin, FT_BitmapGlyph* abitglyph ) { - FT_Error error; - FT_Memory memory; + FT_Error error; + FT_Memory memory; - FT_BitmapGlyph bitglyph; - FT_Glyph glyph; - FT_Pos origin_x = 0; - FT_Pos origin_y = 0; + FT_BitmapGlyph bitglyph; + FT_Glyph glyph; + FT_Pos origin_x = 0; + FT_Pos origin_y = 0; if ( !face ) @@ -171,6 +172,7 @@ /* now, handle bitmap and outline glyph images */ memory = face->memory; + switch ( face->glyph->format ) { case ft_glyph_format_bitmap: @@ -230,7 +232,7 @@ else pitch = ( width + 7 ) >> 3; - size = pitch * height; + size = pitch * height; if ( ALLOC( bitglyph, sizeof ( *bitglyph ) ) ) goto Exit; @@ -318,7 +320,7 @@ FT_OutlineGlyph glyph; - /* test for valid face delayed to FT_Load_Glyph() */ + /* test for valid `face' delayed to FT_Load_Glyph() */ if ( !vecglyph ) return FT_Err_Invalid_Argument; @@ -529,7 +531,7 @@ v = d; } - /* check that we're not trying to normalize zero! */ + /* check that we are not trying to normalize zero! */ if ( u == 0 ) return 0; @@ -630,8 +632,8 @@ /* Compute the orientation of path filling. It differs between TrueType */ /* and Type1 formats. We could use the `ft_outline_reverse_fill' flag, */ - /* but it's better to re-compute it directly (it seems that this flag */ - /* isn't correctly set for some weird composite glyphs for now). */ + /* but it is better to re-compute it directly (it seems that this flag */ + /* isn't correctly set for some weird composite glyphs currently). */ /* */ /* We do this by computing bounding box points, and computing their */ /* curvature. */ @@ -645,6 +647,7 @@ FT_BBox indices; int n, last; + indices.xMin = -1; indices.yMin = -1; indices.xMax = -1; @@ -756,7 +759,7 @@ d = distance; - if ( (outline->flags[n] & FT_Curve_Tag_On) == 0 ) + if ( ( outline->flags[n] & FT_Curve_Tag_On ) == 0 ) d *= 2; /* Check discriminant for parallel vectors */ @@ -781,6 +784,7 @@ /* Vectors are nearly parallel */ FT_Pos x, y; + x = distance + cur.x + FT_MulFix( d, u.x + v.x ) / 2; y = distance + cur.y + FT_MulFix( d, u.y + v.y ) / 2; diff --git a/src/base/ftinit.c b/src/base/ftinit.c index 1a6e44022..702f2c954 100644 --- a/src/base/ftinit.c +++ b/src/base/ftinit.c @@ -84,7 +84,8 @@ const FT_Module_Class* ft_default_modules[] = FT_Error error; const FT_Module_Class** cur; - /* test for valid library delayed to FT_Add_Module() */ + + /* test for valid `library' delayed to FT_Add_Module() */ cur = ft_default_modules; while ( *cur ) @@ -114,7 +115,7 @@ const FT_Module_Class* ft_default_modules[] = /* library :: A handle to a new library object. */ /* */ /* */ - /* FreeTyoe error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ FT_EXPORT_FUNC( FT_Error ) FT_Init_FreeType( FT_Library* library ) { @@ -128,13 +129,12 @@ const FT_Module_Class* ft_default_modules[] = memory = FT_New_Memory(); if ( !memory ) { - FT_ERROR(( "FT_Init_FreeType:" )); - FT_ERROR(( " cannot find memory manager\n" )); + FT_ERROR(( "FT_Init_FreeType: cannot find memory manager\n" )); return FT_Err_Unimplemented_Feature; } - /* builds a library out of it, then fill it with the set of */ - /* default drivers. */ + /* build a library out of it, then fill it with the set of */ + /* default drivers. */ error = FT_New_Library( memory, library ); if ( !error ) diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c index aa129938a..e4b727158 100644 --- a/src/base/ftobjs.c +++ b/src/base/ftobjs.c @@ -201,6 +201,7 @@ } } + /*************************************************************************/ /*************************************************************************/ /*************************************************************************/ @@ -224,6 +225,7 @@ /* */ /* */ /* The function expects a valid `astream' parameter. */ + /* */ static FT_Error ft_new_input_stream( FT_Library library, FT_Open_Args* args, @@ -315,6 +317,7 @@ #undef FT_COMPONENT #define FT_COMPONENT trace_objs + /*************************************************************************/ /*************************************************************************/ /*************************************************************************/ @@ -416,14 +419,15 @@ FT_Memory memory = loader->memory; - FT_GlyphLoader_Reset(loader); + FT_GlyphLoader_Reset( loader ); FREE( loader ); } } /* re-adjust the `current' outline fields */ - static void FT_GlyphLoader_Adjust_Points( FT_GlyphLoader* loader ) + static + void FT_GlyphLoader_Adjust_Points( FT_GlyphLoader* loader ) { FT_Outline* base = &loader->base.outline; FT_Outline* current = &loader->current.outline; @@ -432,7 +436,7 @@ current->points = base->points + base->n_points; current->tags = base->tags + base->n_points; current->contours = base->contours + base->n_contours; - + /* handle extra points table - if any */ if ( loader->use_extra ) loader->current.extra_points = @@ -440,13 +444,13 @@ } - - BASE_FUNC(FT_Error) FT_GlyphLoader_Create_Extra( FT_GlyphLoader* loader ) + BASE_FUNC( FT_Error ) FT_GlyphLoader_Create_Extra( + FT_GlyphLoader* loader ) { FT_Error error; FT_Memory memory = loader->memory; - + if ( !ALLOC_ARRAY( loader->base.extra_points, loader->max_points, FT_Vector ) ) { @@ -458,7 +462,8 @@ /* re-adjust the `current' subglyphs field */ - static void FT_GlyphLoader_Adjust_Subglyphs( FT_GlyphLoader* loader ) + static + void FT_GlyphLoader_Adjust_Subglyphs( FT_GlyphLoader* loader ) { FT_GlyphLoad* base = &loader->base; FT_GlyphLoad* current = &loader->current; @@ -471,6 +476,7 @@ /* Ensure that we can add `n_points' and `n_contours' to our glyph. this */ /* function reallocates its outline tables if necessary. Note that it */ /* DOESN'T change the number of points within the loader! */ + /* */ BASE_FUNC( FT_Error ) FT_GlyphLoader_Check_Points( FT_GlyphLoader* loader, FT_UInt n_points, @@ -482,7 +488,7 @@ FT_Outline* current = &loader->current.outline; FT_Bool adjust = 1; - FT_UInt new_max; + FT_UInt new_max; /* check points & tags */ @@ -530,6 +536,7 @@ /* Ensure that we can add `n_subglyphs' to our glyph. this function */ /* reallocates its subglyphs table if necessary. Note that it DOES */ /* NOT change the number of subglyphs within the loader! */ + /* */ BASE_FUNC( FT_Error ) FT_GlyphLoader_Check_Subglyphs( FT_GlyphLoader* loader, FT_UInt n_subs ) @@ -599,42 +606,41 @@ } - BASE_FUNC( FT_Error ) FT_GlyphLoader_Copy_Points( - FT_GlyphLoader* target, - FT_GlyphLoader* source ) + BASE_FUNC( FT_Error ) FT_GlyphLoader_Copy_Points( FT_GlyphLoader* target, + FT_GlyphLoader* source ) { FT_Error error; FT_UInt num_points = source->base.outline.n_points; FT_UInt num_contours = source->base.outline.n_contours; - + error = FT_GlyphLoader_Check_Points( target, num_points, num_contours ); if ( !error ) { FT_Outline* out = &target->base.outline; FT_Outline* in = &source->base.outline; - + MEM_Copy( out->points, in->points, num_points * sizeof ( FT_Vector ) ); MEM_Copy( out->tags, in->tags, num_points * sizeof ( char ) ); MEM_Copy( out->contours, in->contours, num_contours * sizeof ( short ) ); - + /* do we need to copy the extra points? */ if ( target->use_extra && source->use_extra ) MEM_Copy( target->base.extra_points, source->base.extra_points, num_points * sizeof ( FT_Vector ) ); - + out->n_points = num_points; out->n_contours = num_contours; - + FT_GlyphLoader_Adjust_Points( target ); } - return error; - } + return error; + } /*************************************************************************/ @@ -649,7 +655,9 @@ /*************************************************************************/ /*************************************************************************/ - static FT_Error ft_glyphslot_init( FT_GlyphSlot slot ) + + static + FT_Error ft_glyphslot_init( FT_GlyphSlot slot ) { FT_Driver driver = slot->face->driver; FT_Driver_Class* clazz = driver->clazz; @@ -667,9 +675,11 @@ } - static void ft_glyphslot_clear( FT_GlyphSlot slot ) + static + void ft_glyphslot_clear( FT_GlyphSlot slot ) { /* clear all public fields in the glyph slot */ + MEM_Set( &slot->metrics, 0, sizeof ( slot->metrics ) ); MEM_Set( &slot->outline, 0, sizeof ( slot->outline ) ); MEM_Set( &slot->bitmap, 0, sizeof ( slot->bitmap ) ); @@ -688,7 +698,8 @@ } - static void ft_glyphslot_done( FT_GlyphSlot slot ) + static + void ft_glyphslot_done( FT_GlyphSlot slot ) { FT_Driver driver = slot->face->driver; FT_Driver_Class* clazz = driver->clazz; @@ -741,11 +752,11 @@ FT_GlyphSlot slot; - *aslot = 0; - if ( !face || !aslot || !face->driver ) return FT_Err_Invalid_Argument; + *aslot = 0; + driver = face->driver; clazz = driver->clazz; memory = driver->root.memory; @@ -814,10 +825,6 @@ } - /* forward declaration */ - static FT_Renderer ft_lookup_glyph_renderer( FT_GlyphSlot slot ); - - /*************************************************************************/ /* */ /* */ @@ -852,8 +859,8 @@ if ( !matrix ) { face->transform_matrix.xx = 0x10000L; - face->transform_matrix.xy = 0L; - face->transform_matrix.yx = 0L; + face->transform_matrix.xy = 0; + face->transform_matrix.yx = 0; face->transform_matrix.yy = 0x10000L; matrix = &face->transform_matrix; } @@ -881,8 +888,9 @@ } - static FT_Renderer ft_lookup_glyph_renderer( FT_GlyphSlot slot ); - + static FT_Renderer ft_lookup_glyph_renderer( FT_GlyphSlot slot ); + + /*************************************************************************/ /* */ /* */ @@ -964,17 +972,17 @@ { /* get renderer */ FT_Renderer renderer = ft_lookup_glyph_renderer( slot ); - + if ( renderer ) error = renderer->clazz->transform_glyph( renderer, slot, &face->transform_matrix, &face->transform_delta ); - /* transform advance */ - FT_Vector_Transform( &slot->advance, &face->transform_matrix ); + /* transform advance */ + FT_Vector_Transform( &slot->advance, &face->transform_matrix ); } - Exit: + Exit: return error; } @@ -1021,7 +1029,7 @@ FT_ULong char_code, FT_Int load_flags ) { - FT_UInt glyph_index; + FT_UInt glyph_index; if ( !face ) @@ -1092,14 +1100,15 @@ } - static void Destroy_Driver( FT_Driver driver ) + static + void Destroy_Driver( FT_Driver driver ) { FT_List_Finalize( &driver->faces_list, (FT_List_Destructor)destroy_face, driver->root.memory, driver ); - /* see if we need to drop the driver's glyph loader */ + /* check whether we need to drop the driver's glyph loader */ if ( FT_DRIVER_USES_OUTLINES( driver ) ) FT_GlyphLoader_Done( driver->glyph_loader ); } @@ -1130,7 +1139,7 @@ clazz = driver->clazz; memory = driver->root.memory; - /* allocate the face object, and perform basic initialization */ + /* allocate the face object and perform basic initialization */ if ( ALLOC( face, clazz->face_object_size ) ) goto Fail; @@ -1257,11 +1266,11 @@ /* `*face'. Its return value should be 0 if the resource is */ /* recognized, or non-zero if not. */ /* */ - FT_EXPORT_FUNC( FT_Error ) FT_New_Memory_Face( FT_Library library, - void* file_base, - FT_Long file_size, - FT_Long face_index, - FT_Face* face ) + FT_EXPORT_FUNC( FT_Error ) FT_New_Memory_Face( FT_Library library, + void* file_base, + FT_Long file_size, + FT_Long face_index, + FT_Face* face ) { FT_Open_Args args; @@ -1341,12 +1350,13 @@ /* create input stream */ error = ft_new_input_stream( library, args, &stream ); - if ( error ) goto Exit; + if ( error ) + goto Exit; memory = library->memory; /* If the font driver is specified in the `args' structure, use */ - /* it. Otherwise, we'll scan the list of registered drivers. */ + /* it. Otherwise, we scan the list of registered drivers. */ if ( args->flags & ft_open_driver && args->driver ) { driver = FT_DRIVER( args->driver ); @@ -1390,6 +1400,7 @@ FT_Int num_params = 0; FT_Parameter* params = 0; + driver = FT_DRIVER( cur[0] ); if ( args->flags & ft_open_params ) @@ -1418,7 +1429,7 @@ Success: FT_TRACE4(( "FT_New_Face: New face object, adding to list\n" )); - /* set the EXTERNAL_STREAM bit for FT_Done_Face */ + /* set the FT_FACE_FLAG_EXTERNAL_STREAM bit for FT_Done_Face */ if ( args->flags & ft_open_stream && args->stream ) face->face_flags |= FT_FACE_FLAG_EXTERNAL_STREAM; @@ -1437,9 +1448,11 @@ FT_TRACE4(( "FT_Open_Face: Creating glyph slot\n" )); + error = FT_New_GlyphSlot( face, &slot ); - if ( error ) goto Fail; - + if ( error ) + goto Fail; + face->glyph = slot; } @@ -1449,9 +1462,11 @@ FT_TRACE4(( "FT_Open_Face: Creating size object\n" )); + error = FT_New_Size( face, &size ); - if ( error ) goto Fail; - + if ( error ) + goto Fail; + face->size = size; } @@ -1472,6 +1487,7 @@ Exit: FT_TRACE4(( "FT_Open_Face: Return %d\n", error )); + return error; } @@ -1552,8 +1568,8 @@ /* when invoking this function. Most drivers simply do not implement */ /* file attachments. */ /* */ - FT_EXPORT_FUNC( FT_Error ) FT_Attach_Stream( FT_Face face, - FT_Open_Args* parameters ) + FT_EXPORT_FUNC( FT_Error ) FT_Attach_Stream( FT_Face face, + FT_Open_Args* parameters ) { FT_Stream stream; FT_Error error; @@ -1620,7 +1636,7 @@ { driver = face->driver; memory = driver->root.memory; - + /* find face in driver's list */ node = FT_List_Find( &driver->faces_list, face ); if ( node ) @@ -1628,7 +1644,7 @@ /* remove face object from the driver's list */ FT_List_Remove( &driver->faces_list, node ); FREE( node ); - + /* now destroy the object proper */ destroy_face( memory, face, driver ); error = FT_Err_Ok; @@ -1667,11 +1683,11 @@ FT_ListNode node = 0; - *asize = 0; - if ( !face || !asize || !face->driver ) return FT_Err_Invalid_Handle; + *asize = 0; + driver = face->driver; clazz = driver->clazz; memory = face->memory; @@ -1764,10 +1780,12 @@ } - static void ft_recompute_scaled_metrics( FT_Face face, - FT_Size_Metrics* metrics ) - { + static + void ft_recompute_scaled_metrics( FT_Face face, + FT_Size_Metrics* metrics ) + { /* Compute root ascender, descender, test height, and max_advance */ + metrics->ascender = ( FT_MulFix( face->ascender, metrics->y_scale ) + 32 ) & -64; @@ -1838,13 +1856,13 @@ if ( !char_width ) char_width = char_height; - + else if ( !char_height ) char_height = char_width; if ( !horz_resolution ) horz_resolution = 72; - + if ( !vert_resolution ) vert_resolution = 72; @@ -1853,15 +1871,17 @@ memory = driver->root.memory; /* default processing -- this can be overridden by the driver */ - if ( char_width < 1 * 64 ) char_width = 1 * 64; - if ( char_height < 1 * 64 ) char_height = 1 * 64; + if ( char_width < 1 * 64 ) + char_width = 1 * 64; + if ( char_height < 1 * 64 ) + char_height = 1 * 64; /* Compute pixel sizes in 26.6 units */ dim_x = ( ( ( char_width * horz_resolution ) / 72 ) + 32 ) & -64; dim_y = ( ( ( char_height * vert_resolution ) / 72 ) + 32 ) & -64; - metrics->x_ppem = (FT_UShort)(dim_x >> 6); - metrics->y_ppem = (FT_UShort)(dim_y >> 6); + metrics->x_ppem = (FT_UShort)( dim_x >> 6 ); + metrics->y_ppem = (FT_UShort)( dim_y >> 6 ); metrics->x_scale = 0x10000L; metrics->y_scale = 0x10000L; @@ -1932,8 +1952,10 @@ else if ( pixel_height == 0 ) pixel_height = pixel_width; - if ( pixel_width < 1 ) pixel_width = 1; - if ( pixel_height < 1 ) pixel_height = 1; + if ( pixel_width < 1 ) + pixel_width = 1; + if ( pixel_height < 1 ) + pixel_height = 1; metrics->x_ppem = pixel_width; metrics->y_ppem = pixel_height; @@ -2067,6 +2089,7 @@ return 0; } } + return FT_Err_Invalid_Argument; } @@ -2088,8 +2111,8 @@ /* FreeType error code. 0 means success. */ /* */ /* */ - /* This function will return an error when the charmap is not part */ - /* of the face (i.e., if it is not listed in the face->charmaps[] */ + /* This function will return an error if the charmap is not part of */ + /* the face (i.e., if it is not listed in the face->charmaps[] */ /* table). */ /* */ FT_EXPORT_FUNC( FT_Error ) FT_Set_Charmap( FT_Face face, @@ -2213,75 +2236,86 @@ /*************************************************************************/ /*************************************************************************/ - /* lookup a renderer by glyph format in the library's list */ - BASE_FUNC(FT_Renderer) FT_Lookup_Renderer( FT_Library library, - FT_Glyph_Format format, - FT_ListNode *node ) + /* lookup a renderer by glyph format in the library's list */ + BASE_FUNC( FT_Renderer ) FT_Lookup_Renderer( FT_Library library, + FT_Glyph_Format format, + FT_ListNode* node ) { - FT_ListNode cur = library->renderers.head; + FT_ListNode cur; FT_Renderer result = 0; - - if (node) + + if ( !library ) + goto Exit; + + cur = library->renderers.head; + + if ( node ) { - if (*node) + if ( *node ) cur = (*node)->next; *node = 0; } - + while ( cur ) { FT_Renderer renderer = FT_RENDERER( cur->data ); - + if ( renderer->glyph_format == format ) { if ( node ) *node = cur; - + result = renderer; break; } cur = cur->next; } + Exit: return result; } - - static FT_Renderer ft_lookup_glyph_renderer( FT_GlyphSlot slot ) - { - FT_Face face = slot->face; - FT_Library library = FT_FACE_LIBRARY( face ); - FT_Renderer result = library->cur_renderer; - + static + FT_Renderer ft_lookup_glyph_renderer( FT_GlyphSlot slot ) + { + FT_Face face = slot->face; + FT_Library library = FT_FACE_LIBRARY( face ); + FT_Renderer result = library->cur_renderer; + + if ( !result || result->glyph_format != slot->format ) result = FT_Lookup_Renderer( library, slot->format, 0 ); return result; } - - static void ft_set_current_renderer( FT_Library library ) + + static + void ft_set_current_renderer( FT_Library library ) { FT_Renderer renderer; + renderer = FT_Lookup_Renderer( library, ft_glyph_format_outline, 0 ); library->cur_renderer = renderer; } - static FT_Error ft_add_renderer( FT_Module module ) + static + FT_Error ft_add_renderer( FT_Module module ) { FT_Library library = module->library; FT_Memory memory = library->memory; FT_Error error; FT_ListNode node; - + + if ( ALLOC( node, sizeof ( *node ) ) ) goto Exit; - + { FT_Renderer render = FT_RENDERER( module ); FT_Renderer_Class* clazz = (FT_Renderer_Class*)module->clazz; @@ -2289,7 +2323,7 @@ render->clazz = clazz; render->glyph_format = clazz->glyph_format; - + /* allocate raster object if needed */ if ( clazz->glyph_format == ft_glyph_format_outline && clazz->raster_class->raster_new ) @@ -2297,11 +2331,11 @@ error = clazz->raster_class->raster_new( memory, &render->raster ); if ( error ) goto Fail; - + render->raster_render = clazz->raster_class->raster_render; render->render = clazz->render_glyph; - } - + } + /* add to list */ node->data = module; FT_List_Add( &library->renderers, node ); @@ -2315,10 +2349,11 @@ Exit: return error; - } + } - static void ft_remove_renderer( FT_Module module ) + static + void ft_remove_renderer( FT_Module module ) { FT_Library library = module->library; FT_Memory memory = library->memory; @@ -2329,16 +2364,16 @@ if ( node ) { FT_Renderer render = FT_RENDERER( module ); - + /* release raster object, if any */ if ( render->raster ) render->clazz->raster_class->raster_done( render->raster ); - + /* remove from list */ FT_List_Remove( &library->renderers, node ); FREE( node ); - + ft_set_current_renderer( library ); } } @@ -2370,8 +2405,10 @@ FT_EXPORT_FUNC( FT_Renderer ) FT_Get_Renderer( FT_Library library, FT_Glyph_Format format ) { + /* test for valid `library' delayed to FT_Lookup_Renderer() */ + return FT_Lookup_Renderer( library, format, 0 ); - } + } /*************************************************************************/ @@ -2400,14 +2437,20 @@ /* */ /* This doesn't change the current renderer for other formats. */ /* */ - FT_EXPORT_DEF( FT_Error ) FT_Set_Renderer( FT_Library library, - FT_Renderer renderer, - FT_UInt num_params, - FT_Parameter* parameters ) + FT_EXPORT_DEF( FT_Error ) FT_Set_Renderer( FT_Library library, + FT_Renderer renderer, + FT_UInt num_params, + FT_Parameter* parameters ) { FT_ListNode node; FT_Error error = FT_Err_Ok; - + + + if ( !library ) + return FT_Err_Invalid_Library_Handle; + + if ( !renderer ) + return FT_Err_Invalid_Argument; node = FT_List_Find( &library->renderers, renderer ); if ( !node ) @@ -2417,14 +2460,14 @@ } FT_List_Up( &library->renderers, node ); - + if ( renderer->glyph_format == ft_glyph_format_outline ) library->cur_renderer = renderer; - + if ( num_params > 0 ) { FTRenderer_setMode set_mode = renderer->clazz->set_mode; - + for ( ; num_params > 0; num_params-- ) { @@ -2433,66 +2476,35 @@ break; } } - + Exit: return error; - } + } - /************************************************************************* - * - * - * FT_Render_Glyph - * - * - * Converts a given glyph image to a bitmap. It does so by inspecting - * the glyph image format, find the relevant renderer, and invoke it - * - * - * slot :: handle to the glyph slot containing the image to - * convert - * - * render_mode :: a set of bit flags indicating which kind of bitmap - * to render. For now, only 'ft_render_mode_anti_alias' - * is supported by the available renderers, but others - * could appear later (e.g. LCD or TV optimised) - * - * - * Error code. 0 means success. - * - * - * in case of success, the renderer will be used to convert glyph - * images in the renderer's known format into bitmaps. - * - * This doesn't change the current renderer for other formats.. - * - * The slot's native image should be considered lost after the - * conversion.. - * - *************************************************************************/ - LOCAL_FUNC - FT_Error FT_Render_Glyph_Internal( FT_Library library, - FT_GlyphSlot slot, - FT_UInt render_mode ) + FT_Error FT_Render_Glyph_Internal( FT_Library library, + FT_GlyphSlot slot, + FT_UInt render_mode ) { FT_Error error = FT_Err_Ok; FT_Renderer renderer; - - /* if it's already a bitmap, no need to do anything */ - switch (slot->format) + + /* if it is already a bitmap, no need to do anything */ + switch ( slot->format ) { - case ft_glyph_format_bitmap: /* already a bitmap, don't do anything */ - break; - - default: + case ft_glyph_format_bitmap: /* already a bitmap, don't do anything */ + break; + + default: { FT_ListNode node = 0; FT_Bool update = 0; - + + /* small shortcut for the very common case */ - if (slot->format == ft_glyph_format_outline) + if ( slot->format == ft_glyph_format_outline ) { renderer = library->cur_renderer; node = library->renderers.head; @@ -2501,46 +2513,80 @@ renderer = FT_Lookup_Renderer( library, slot->format, &node ); error = FT_Err_Unimplemented_Feature; - while (renderer) + while ( renderer ) { error = renderer->render( renderer, slot, render_mode, 0 ); - if (!error || error != FT_Err_Cannot_Render_Glyph) break; + if ( !error || error != FT_Err_Cannot_Render_Glyph ) + break; - /* FT_Err_Cannot_Render_Glyph is returned when the render mode */ + /* FT_Err_Cannot_Render_Glyph is returned if the render mode */ /* is unsupported by the current renderer for this glyph image */ - /* format.. */ - - /* now, look for another renderer that supports the same */ - /* format.. */ + /* format. */ + + /* now, look for another renderer that supports the same */ + /* format. */ renderer = FT_Lookup_Renderer( library, slot->format, &node ); update = 1; } /* if we changed the current renderer for the glyph image format */ - /* we need to select it as the next current one.. */ - if (!error && update && renderer) + /* we need to select it as the next current one */ + if ( !error && update && renderer ) FT_Set_Renderer( library, renderer, 0, 0 ); } } - + return error; } - - FT_EXPORT_FUNC(FT_Error) FT_Render_Glyph( FT_GlyphSlot slot, - FT_UInt render_mode ) + /*************************************************************************/ + /* */ + /* */ + /* FT_Render_Glyph */ + /* */ + /* */ + /* Converts a given glyph image to a bitmap. It does so by */ + /* inspecting the glyph image format, find the relevant renderer, and */ + /* invoke it. */ + /* */ + /* */ + /* slot :: A handle to the glyph slot containing the image to */ + /* convert. */ + /* */ + /* render_mode :: A set of bit flags indicating which kind of bitmap */ + /* to render. For now, only */ + /* `ft_render_mode_anti_alias' is supported by the */ + /* available renderers, but others could appear later */ + /* (e.g. optimized for TV or LCD). */ + /* */ + /* */ + /* FreeType error code. 0 means success. */ + /* */ + /* */ + /* In case of success, the renderer will be used to convert glyph */ + /* images in the renderer's known format into bitmaps. */ + /* */ + /* This doesn't change the current renderer for other formats. */ + /* */ + /* The slot's native image should be considered lost after the */ + /* conversion. */ + /* */ + FT_EXPORT_FUNC( FT_Error ) FT_Render_Glyph( FT_GlyphSlot slot, + FT_UInt render_mode ) { FT_Library library; - - if (!slot) + + + if ( !slot ) return FT_Err_Invalid_Argument; - - library = FT_FACE_LIBRARY(slot->face); + + library = FT_FACE_LIBRARY( slot->face ); + return FT_Render_Glyph_Internal( library, slot, render_mode ); } - + /*************************************************************************/ /*************************************************************************/ /*************************************************************************/ @@ -2625,10 +2671,13 @@ FT_UInt nn; -#define FREETYPE_VER_FIXED ( ( (FT_Long)FREETYPE_MAJOR << 16 ) | \ - FREETYPE_MINOR ) +#define FREETYPE_VER_FIXED ( ( (FT_Long)FREETYPE_MAJOR << 16 ) | \ + FREETYPE_MINOR ) - if ( !library || !clazz ) + if ( !library ) + return FT_Err_Invalid_Library_Handle; + + if ( !clazz ) return FT_Err_Invalid_Argument; /* check freetype version */ @@ -2665,13 +2714,13 @@ if ( ALLOC( module,clazz->module_size ) ) goto Exit; - /* base initialisation */ + /* base initialization */ module->library = library; module->memory = memory; module->clazz = (FT_Module_Class*)clazz; - /* if the module is a renderer - this must be performed before */ - /* the normal module initialization. */ + /* check whether the module is a renderer - this must be performed */ + /* before the normal module initialization */ if ( FT_MODULE_IS_RENDERER( module ) ) { /* add to the renderers list */ @@ -2686,7 +2735,7 @@ /* allocate glyph loader if needed */ FT_Driver driver = FT_DRIVER( module ); - + driver->clazz = (FT_Driver_Class*)module->clazz; if ( FT_DRIVER_USES_OUTLINES( driver ) ) { @@ -2705,20 +2754,20 @@ /* add module to the library's table */ library->modules[library->num_modules++] = module; - + Exit: return error; - + Fail: if ( FT_MODULE_IS_DRIVER( module ) ) { FT_Driver driver = FT_DRIVER( module ); - + if ( FT_DRIVER_USES_OUTLINES( driver ) ) FT_GlyphLoader_Done( driver->glyph_loader ); } - + if ( FT_MODULE_IS_RENDERER( module ) ) { FT_Renderer renderer = FT_RENDERER( module ); @@ -2756,11 +2805,17 @@ FT_EXPORT_FUNC( FT_Module ) FT_Get_Module( FT_Library library, const char* module_name ) { - FT_Module result = 0; - FT_Module* cur = library->modules; - FT_Module* limit = cur + library->num_modules; + FT_Module result = 0; + FT_Module* cur; + FT_Module* limit; + if ( !library || !module_name ) + return result; + + cur = library->modules; + limit = cur + library->num_modules; + for ( ; cur < limit; cur++ ) if ( strcmp( cur[0]->clazz->module_name, module_name ) == 0 ) { @@ -2793,17 +2848,19 @@ /* You should better be familiar with FreeType internals to know */ /* which module to look for, and what its interface is :-) */ /* */ - FT_EXPORT_FUNC(const void*) FT_Get_Module_Interface( - FT_Library library, - const char* mod_name ) + FT_EXPORT_FUNC( const void* ) FT_Get_Module_Interface( + FT_Library library, + const char* mod_name ) { FT_Module module; - + + + /* test for valid `library' delayed to FT_Get_Module() */ module = FT_Get_Module( library, mod_name ); return module ? module->clazz->module_interface : 0; - } + } /*************************************************************************/ @@ -2815,9 +2872,9 @@ /* Removes a given module from a library instance. */ /* */ /* */ - /* library :: A handle to a library object. */ + /* library :: A handle to a library object. */ /* */ - /* module :: A handle to a module object. */ + /* module :: A handle to a module object. */ /* */ /* */ /* FreeType error code. 0 means success. */ @@ -2829,7 +2886,11 @@ FT_Module module ) { /* try to find the module from the table, then remove it from there */ - if ( library && module ) + + if ( !library ) + return FT_Err_Invalid_Library_Handle; + + if ( module ) { FT_Module* cur = library->modules; FT_Module* limit = cur + library->num_modules; @@ -2837,7 +2898,7 @@ for ( ; cur < limit; cur++ ) { - if (cur[0] == module) + if ( cur[0] == module ) { /* remove it from the table */ library->num_modules--; diff --git a/src/base/ftoutln.c b/src/base/ftoutln.c index b9a4c21b0..76497d32a 100644 --- a/src/base/ftoutln.c +++ b/src/base/ftoutln.c @@ -174,50 +174,48 @@ } case FT_Curve_Tag_Conic: /* consume conic arcs */ + v_control.x = SCALED( point->x ); + v_control.y = SCALED( point->y ); + + Do_Conic: + if ( point < limit ) { - v_control.x = SCALED( point->x ); - v_control.y = SCALED( point->y ); + FT_Vector vec; + FT_Vector v_middle; - Do_Conic: - if ( point < limit ) + + point++; + tags++; + tag = FT_CURVE_TAG( tags[0] ); + + vec.x = SCALED( point->x ); + vec.y = SCALED( point->y ); + + if ( tag == FT_Curve_Tag_On ) { - FT_Vector vec; - FT_Vector v_middle; - - - point++; - tags++; - tag = FT_CURVE_TAG( tags[0] ); - - vec.x = SCALED( point->x ); - vec.y = SCALED( point->y ); - - if ( tag == FT_Curve_Tag_On ) - { - error = interface->conic_to( &v_control, &vec, user ); - if ( error ) - goto Exit; - continue; - } - - if ( tag != FT_Curve_Tag_Conic ) - goto Invalid_Outline; - - v_middle.x = ( v_control.x + vec.x ) / 2; - v_middle.y = ( v_control.y + vec.y ) / 2; - - error = interface->conic_to( &v_control, &v_middle, user ); + error = interface->conic_to( &v_control, &vec, user ); if ( error ) goto Exit; - - v_control = vec; - goto Do_Conic; + continue; } - error = interface->conic_to( &v_control, &v_start, user ); - goto Close; + if ( tag != FT_Curve_Tag_Conic ) + goto Invalid_Outline; + + v_middle.x = ( v_control.x + vec.x ) / 2; + v_middle.y = ( v_control.y + vec.y ) / 2; + + error = interface->conic_to( &v_control, &v_middle, user ); + if ( error ) + goto Exit; + + v_control = vec; + goto Do_Conic; } + error = interface->conic_to( &v_control, &v_start, user ); + goto Close; + default: /* FT_Curve_Tag_Cubic */ { FT_Vector vec1, vec2; @@ -256,7 +254,7 @@ /* close the contour with a line segment */ error = interface->line_to( &v_start, user ); - Close: + Close: if ( error ) goto Exit; @@ -549,6 +547,7 @@ char* q = outline->tags + last; char swap; + while ( p < q ) { swap = *p; @@ -604,34 +603,46 @@ FT_Outline* outline, FT_Raster_Params* params ) { - FT_Error error; - FT_Bool update = 0; - FT_Renderer renderer = library->cur_renderer; - FT_ListNode node = library->renderers.head; + FT_Error error; + FT_Bool update = 0; + FT_Renderer renderer; + FT_ListNode node; + + + if ( !library ) + return FT_Err_Invalid_Library_Handle; + + if ( !params ) + return FT_Err_Invalid_Argument; + + renderer = library->cur_renderer; + node = library->renderers.head; params->source = (void*)outline; - + error = FT_Err_Cannot_Render_Glyph; - while (renderer) + while ( renderer ) { error = renderer->raster_render( renderer->raster, params ); - if (!error || error != FT_Err_Cannot_Render_Glyph) break; + if ( !error || error != FT_Err_Cannot_Render_Glyph ) + break; /* FT_Err_Cannot_Render_Glyph is returned when the render mode */ /* is unsupported by the current renderer for this glyph image */ - /* format.. */ - - /* now, look for another renderer that supports the same */ - /* format.. */ - renderer = FT_Lookup_Renderer( library, ft_glyph_format_outline, &node ); + /* format */ + + /* now, look for another renderer that supports the same */ + /* format */ + renderer = FT_Lookup_Renderer( library, ft_glyph_format_outline, + &node ); update = 1; } /* if we changed the current renderer for the glyph image format */ - /* we need to select it as the next current one.. */ - if (!error && update && renderer) + /* we need to select it as the next current one */ + if ( !error && update && renderer ) FT_Set_Renderer( library, renderer, 0, 0 ); - + return error; } @@ -675,7 +686,7 @@ if ( !bitmap ) return FT_Err_Invalid_Argument; - /* other checks are delayed to FT_Outline_Render */ + /* other checks are delayed to FT_Outline_Render() */ params.target = bitmap; params.flags = 0; @@ -713,6 +724,9 @@ FT_Pos xz, yz; + if ( !vector || !matrix ) + return; + xz = FT_MulFix( vector->x, matrix->xx ) + FT_MulFix( vector->y, matrix->xy ); @@ -750,7 +764,7 @@ { FT_Vector* vec = outline->points; FT_Vector* limit = vec + outline->n_points; - + for ( ; vec < limit; vec++ ) FT_Vector_Transform( vec, matrix ); diff --git a/src/base/ftstream.c b/src/base/ftstream.c index f2fc2ee23..c1cb12224 100644 --- a/src/base/ftstream.c +++ b/src/base/ftstream.c @@ -374,9 +374,9 @@ BASE_FUNC( FT_Short ) FT_Read_Short( FT_Stream stream, FT_Error* error ) { - char reads[2]; - char* p = 0; - FT_Short result = 0; + char reads[2]; + char* p = 0; + FT_Short result = 0; FT_Assert( stream ); @@ -645,27 +645,24 @@ *(FT_UShort*)p = (FT_UShort)value; break; - /* A slight note regarding the following: */ - /* */ - /* SIZEOF_INT is defined in */ - /* and gives the size in bytes of the "int" type on the */ - /* current platform.. */ - /* */ - /* Only on 16-bit systems can the value of SIZEOF_INT be */ - /* less than 4. In this case SIZEOF_LONG is always 4 */ - /* */ - /* On a 64-bit system, SIZEOF_LONG can be 8, which is */ - /* handled by the default case.. */ - /* */ - + /* SIZEOF_INT is defined in */ + /* and gives the size in bytes of the `int' type on the */ + /* current platform. */ + /* */ + /* Only on 16-bit systems the value of SIZEOF_INT can be */ + /* less than 4. In this case SIZEOF_LONG is always 4. */ + /* */ + /* On a 64-bit system, SIZEOF_LONG can be 8, which is */ + /* handled by the default case. */ + /* */ #if SIZEOF_INT == 4 case 4: - *(FT_UInt*)p = (FT_UInt)value; - break; + *(FT_UInt*)p = (FT_UInt)value; + break; #endif default: - *(FT_ULong*)p = (FT_ULong)value; + *(FT_ULong*)p = (FT_ULong)value; } /* go to next field */ diff --git a/src/base/ftsystem.c b/src/base/ftsystem.c index 434a6dbad..12494028c 100644 --- a/src/base/ftsystem.c +++ b/src/base/ftsystem.c @@ -44,8 +44,9 @@ /*************************************************************************/ /* */ - /* It is not necessary to do any error checking here. This will be done */ - /* by the higher level routines like FT_Alloc() or FT_Realloc(). */ + /* It is not necessary to do any error checking for the */ + /* allocation-related functions. This will be done by the higher level */ + /* routines like FT_Alloc() or FT_Realloc(). */ /* */ /*************************************************************************/ @@ -234,6 +235,9 @@ FILE* file; + if ( !stream ) + return FT_Err_Invalid_Stream_Handle; + file = fopen( filepathname, "rb" ); if ( !file ) { diff --git a/src/cff/t2driver.c b/src/cff/t2driver.c index cf3149a48..9864058fe 100644 --- a/src/cff/t2driver.c +++ b/src/cff/t2driver.c @@ -303,12 +303,12 @@ 0x20000L, 0, /* module-specific interface */ - + (FT_Module_Constructor)T2_Init_Driver, (FT_Module_Destructor) T2_Done_Driver, (FT_Module_Requester) t2_get_interface, }, - + /* now the specific driver fields */ sizeof( TT_FaceRec ), sizeof( FT_SizeRec ), @@ -323,7 +323,7 @@ (FTDriver_setCharSizes) 0, (FTDriver_setPixelSizes)0, - + (FTDriver_loadGlyph) Load_Glyph, (FTDriver_getCharIndex) Get_Char_Index, diff --git a/src/cff/t2gload.c b/src/cff/t2gload.c index b4eb7d961..75c8eba2d 100644 --- a/src/cff/t2gload.c +++ b/src/cff/t2gload.c @@ -233,7 +233,7 @@ { FT_GlyphLoader* loader = glyph->root.loader; - + builder->loader = loader; builder->base = &loader->base.outline; builder->current = &loader->current.outline; @@ -351,29 +351,31 @@ } - /* this function is used to select the locals subrs array */ + /* this function is used to select the locals subrs array */ LOCAL_DEF - void T2_Prepare_Decoder( T2_Decoder* decoder, - FT_UInt glyph_index ) + void T2_Prepare_Decoder( T2_Decoder* decoder, + FT_UInt glyph_index ) { CFF_Font* cff = (CFF_Font*)decoder->builder.face->extra.data; CFF_SubFont* sub = &cff->top_font; - + + /* manage CID fonts */ - if (cff->num_subfonts >= 1) + if ( cff->num_subfonts >= 1 ) { FT_Byte fd_index = CFF_Get_FD( &cff->fd_select, glyph_index ); + + sub = cff->subfonts[fd_index]; } - - decoder->num_locals = sub->num_local_subrs; - decoder->locals = sub->local_subrs; - decoder->locals_bias = t2_compute_bias( decoder->num_locals ); + + decoder->num_locals = sub->num_local_subrs; + decoder->locals = sub->local_subrs; + decoder->locals_bias = t2_compute_bias( decoder->num_locals ); decoder->glyph_width = sub->private_dict.default_width; decoder->nominal_width = sub->private_dict.nominal_width; - } - + } /* check that there is enough room for `count' more points */ @@ -382,7 +384,7 @@ FT_Int count ) { return FT_GlyphLoader_Check_Points( builder->loader, count, 0 ); - } + } /* add a new point, do not check space */ @@ -447,7 +449,7 @@ { if ( outline->n_contours > 0 ) outline->contours[outline->n_contours - 1] = outline->n_points - 1; - + outline->n_contours++; } @@ -528,6 +530,7 @@ FT_Fixed seed; FT_Fixed* stack; + /* set default width */ decoder->num_hints = 0; decoder->read_width = 1; @@ -1087,10 +1090,12 @@ case t2_op_rlinecurve: { - FT_Int num_lines = (num_args-6)/2; + FT_Int num_lines = ( num_args - 6 ) / 2; + + FT_TRACE4(( " rlinecurve" )); - if ( num_args < 8 || (num_args-6) & 1) + if ( num_args < 8 || ( num_args - 6 ) & 1 ) goto Stack_Underflow; if ( start_point( builder, x, y ) || @@ -1100,7 +1105,7 @@ args = stack; /* first, add the line segments */ - while (num_lines > 0) + while ( num_lines > 0 ) { x += args[0]; y += args[1]; @@ -1109,7 +1114,7 @@ num_lines--; } - /* then, the curve */ + /* then the curve */ x += args[0]; y += args[1]; add_point( builder, x, y, 0 ); @@ -1125,12 +1130,12 @@ case t2_op_rcurveline: { - FT_Int num_curves = (num_args-2)/6; + FT_Int num_curves = ( num_args - 2 ) / 6; FT_TRACE4(( " rcurveline" )); - if ( num_args < 8 || (num_args-2) % 6 ) + if ( num_args < 8 || ( num_args - 2 ) % 6 ) goto Stack_Underflow; if ( start_point ( builder, x, y ) || @@ -1138,8 +1143,9 @@ goto Memory_Error; args = stack; + /* first, add the curves */ - while (num_curves > 0) + while ( num_curves > 0 ) { x += args[0]; y += args[1]; @@ -1153,6 +1159,7 @@ args += 6; num_curves--; } + /* then the final line */ x += args[0]; y += args[1]; @@ -1549,15 +1556,15 @@ return error; Syntax_Error: - FT_TRACE4(( "** Syntax Error **" )); + FT_TRACE4(( "T2_Parse_CharStrings: syntax error!" )); return T2_Err_Invalid_File_Format; Stack_Underflow: - FT_TRACE4(( "** Stack underflow **" )); + FT_TRACE4(( "T2_Parse_CharStrings: stack underflow!" )); return T2_Err_Too_Few_Arguments; Stack_Overflow: - FT_TRACE4(( "** Stack overflow**" )); + FT_TRACE4(( "T2_Parse_CharStrings: stack overflow!" )); return T2_Err_Stack_Overflow; Memory_Error: diff --git a/src/cff/t2gload.h b/src/cff/t2gload.h index 605ba5e19..5117f34f5 100644 --- a/src/cff/t2gload.h +++ b/src/cff/t2gload.h @@ -167,8 +167,8 @@ T2_GlyphSlot slot ); LOCAL_DEF - void T2_Prepare_Decoder( T2_Decoder* decoder, - FT_UInt glyph_index ); + void T2_Prepare_Decoder( T2_Decoder* decoder, + FT_UInt glyph_index ); #if 0 /* unused until we support pure CFF fonts */ diff --git a/src/cff/t2load.c b/src/cff/t2load.c index 95015a638..704048989 100644 --- a/src/cff/t2load.c +++ b/src/cff/t2load.c @@ -318,26 +318,27 @@ #endif /* 0 */ - /**********************************************************************/ - /**********************************************************************/ - /*** ***/ - /*** FD Select table support ***/ - /*** ***/ - /*** ***/ - /**********************************************************************/ - /**********************************************************************/ + + /*************************************************************************/ + /*************************************************************************/ + /*** ***/ + /*** FD Select table support ***/ + /*** ***/ + /*************************************************************************/ + /*************************************************************************/ + static void CFF_Done_FD_Select( CFF_FD_Select* select, FT_Stream stream ) { - if (select->data) + if ( select->data ) RELEASE_Frame( select->data ); - + select->data_size = 0; select->format = 0; select->range_count = 0; - } + } static @@ -349,42 +350,44 @@ FT_Error error; FT_Byte format; FT_UInt num_ranges; - + + /* read format */ - if ( FILE_Seek(offset) || READ_Byte(format) ) + if ( FILE_Seek( offset ) || READ_Byte( format ) ) goto Exit; select->format = format; select->cache_count = 0; /* clear cache */ - switch (format) + + switch ( format ) { - case 0: /* format 0, that's simple */ - { - select->data_size = num_glyphs; - goto Load_Data; - } - - - case 3: /* format 3, a tad more complex */ - { - if ( READ_UShort(num_ranges) ) - goto Exit; - - select->data_size = num_ranges*3+2; - - Load_Data: - if ( EXTRACT_Frame( select->data_size, select->data ) ) - goto Exit; - } - break; - - - default: /* humm.. that's wrong */ - error = FT_Err_Invalid_File_Format; + case 0: /* format 0, that's simple */ + { + select->data_size = num_glyphs; + goto Load_Data; + } + + case 3: /* format 3, a tad more complex */ + { + if ( READ_UShort( num_ranges ) ) + goto Exit; + + select->data_size = num_ranges * 3 + 2; + + Load_Data: + if ( EXTRACT_Frame( select->data_size, select->data ) ) + goto Exit; + } + break; + + + default: /* humm... that's wrong */ + error = FT_Err_Invalid_File_Format; } + Exit: return error; - } + } LOCAL_FUNC @@ -392,68 +395,70 @@ FT_UInt glyph_index ) { FT_Byte fd = 0; - - switch (select->format) + + + switch ( select->format ) { - case 0: - fd = select->data[glyph_index]; + case 0: + fd = select->data[glyph_index]; + break; + + case 3: + /* first, compare to cache */ + if ( (FT_UInt)(glyph_index-select->cache_first) < select->cache_count ) + { + fd = select->cache_fd; break; - - case 3: - /* first, compare to cache */ - if ((FT_UInt)(glyph_index-select->cache_first) < select->cache_count) + } + + /* then, lookup the ranges array */ + { + FT_Byte* p = select->data; + FT_Byte* p_limit = p + select->data_size; + FT_Byte fd2; + FT_UInt first, limit; + + + first = NEXT_UShort( p ); + do { - fd = select->cache_fd; - break; - } - - /* then, lookup the ranges array */ - { - FT_Byte* p = select->data; - FT_Byte* p_limit = p + select->data_size; - FT_Byte fd2; - FT_UInt first, limit; - - first = NEXT_UShort(p); - do + if ( glyph_index < first ) + break; + + fd2 = *p++; + limit = NEXT_UShort( p ); + + if ( glyph_index < limit ) { - if (glyph_index < first) - break; - - fd2 = *p++; - limit = NEXT_UShort(p); - - if (glyph_index < limit) - { - fd = fd2; - - /* update cache */ - select->cache_first = first; - select->cache_count = limit-first; - select->cache_fd = fd2; - break; - } - first = limit; + fd = fd2; + + /* update cache */ + select->cache_first = first; + select->cache_count = limit-first; + select->cache_fd = fd2; + break; } - while (p < p_limit); - } - break; - - default: - ; + first = limit; + } while ( p < p_limit ); + } + break; + + default: + ; } + return fd; - } + } - /**********************************************************************/ - /**********************************************************************/ - /*** ***/ - /*** CFF font support ***/ - /*** ***/ - /*** ***/ - /**********************************************************************/ - /**********************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + /*** ***/ + /*** CFF font support ***/ + /*** ***/ + /*************************************************************************/ + /*************************************************************************/ + static FT_Error CFF_Load_SubFont( CFF_SubFont* font, @@ -462,12 +467,13 @@ FT_Stream stream, FT_ULong base_offset ) { - FT_Error error; - T2_Parser parser; - FT_Byte* dict; - FT_ULong dict_len; + FT_Error error; + T2_Parser parser; + FT_Byte* dict; + FT_ULong dict_len; CFF_Font_Dict* top = &font->font_dict; - CFF_Private* priv = &font->private_dict; + CFF_Private* priv = &font->private_dict; + T2_Parser_Init( &parser, T2CODE_TOPDICT, &font->font_dict ); @@ -494,11 +500,11 @@ goto Exit; /* parse the private dictionary, if any */ - if ( top->private_offset && top->private_size) + if ( top->private_offset && top->private_size ) { /* set defaults */ - MEM_Set( priv, 0, sizeof(*priv) ); - + MEM_Set( priv, 0, sizeof ( *priv ) ); + priv->blue_shift = 7; priv->blue_fuzz = 1; priv->lenIV = -1; @@ -508,7 +514,7 @@ T2_Parser_Init( &parser, T2CODE_PRIVATE, priv ); if ( FILE_Seek( base_offset + font->font_dict.private_offset ) || - ACCESS_Frame( font->font_dict.private_size ) ) + ACCESS_Frame( font->font_dict.private_size ) ) goto Exit; error = T2_Parser_Run( &parser, @@ -529,7 +535,7 @@ error = t2_new_cff_index( &font->local_subrs_index, stream, 1 ); if ( error ) goto Exit; - + font->num_local_subrs = font->local_subrs_index.count; error = t2_explicit_cff_index( &font->local_subrs_index, &font->local_subrs ); @@ -544,13 +550,12 @@ void CFF_Done_SubFont( FT_Memory memory, CFF_SubFont* subfont ) { - if (subfont) + if ( subfont ) { t2_done_cff_index( &subfont->local_subrs_index ); FREE( subfont->local_subrs ); } - } - + } LOCAL_FUNC @@ -599,7 +604,7 @@ /* read the name, top dict, string and global subrs index */ error = t2_new_cff_index( &font->name_index, stream, 0 ) || - t2_new_cff_index( &font->font_dict_index, stream, 0 ) || + t2_new_cff_index( &font->font_dict_index, stream, 0 ) || t2_new_cff_index( &font->string_index, stream, 0 ) || t2_new_cff_index( &font->global_subrs_index, stream, 1 ); if ( error ) @@ -615,16 +620,16 @@ } /* in case of a font format check, simply exit now */ - if (face_index < 0) + if ( face_index < 0 ) goto Exit; - + /* now, parse the top-level font dictionary */ error = CFF_Load_SubFont( &font->top_font, &font->font_dict_index, face_index, stream, base_offset ); - if (error) + if ( error ) goto Exit; /* now, check for a CID font */ @@ -634,20 +639,22 @@ CFF_SubFont* sub; FT_UInt index; + /* this is a CID-keyed font, we must now allocate a table of */ - /* sub-fonts, then load each of them separately.. */ + /* sub-fonts, then load each of them separately */ if ( FILE_Seek( base_offset + dict->cid_fd_array_offset ) ) goto Exit; - + error = t2_new_cff_index( &fd_index, stream, 0 ); - if (error) goto Exit; - - if (fd_index.count > CFF_MAX_CID_FONTS) + if ( error ) + goto Exit; + + if ( fd_index.count > CFF_MAX_CID_FONTS ) { FT_ERROR(( "T2_Load_CFF_Font: FD array too large in CID font\n" )); goto Fail_CID; } - + /* allocate & read each font dict independently */ font->num_subfonts = fd_index.count; if ( ALLOC_ARRAY( sub, fd_index.count, CFF_SubFont ) ) @@ -656,13 +663,15 @@ /* setup pointer table */ for ( index = 0; index < fd_index.count; index++ ) font->subfonts[index] = sub + index; - + /* now load each sub font independently */ for ( index = 0; index < fd_index.count; index++ ) { sub = font->subfonts[index]; - error = CFF_Load_SubFont( sub, &fd_index, index, stream, base_offset ); - if (error) goto Fail_CID; + error = CFF_Load_SubFont( sub, &fd_index, index, + stream, base_offset ); + if ( error ) + goto Fail_CID; } /* now load the FD Select array */ @@ -673,8 +682,8 @@ Fail_CID: t2_done_cff_index( &fd_index ); - - if (error) + + if ( error ) goto Exit; } else @@ -713,28 +722,27 @@ } - - LOCAL_FUNC void T2_Done_CFF_Font( CFF_Font* font ) { FT_Memory memory = font->memory; FT_UInt index; + t2_done_cff_index( &font->global_subrs_index ); t2_done_cff_index( &font->string_index ); t2_done_cff_index( &font->font_dict_index ); t2_done_cff_index( &font->name_index ); t2_done_cff_index( &font->charstrings_index ); - + /* release font dictionaries */ for ( index = 0; index < font->num_subfonts; index++ ) CFF_Done_SubFont( memory, font->subfonts[index] ); - + CFF_Done_SubFont( memory, &font->top_font ); - + CFF_Done_FD_Select( &font->fd_select, font->stream ); - + FREE( font->global_subrs ); FREE( font->font_name ); } diff --git a/src/cff/t2objs.c b/src/cff/t2objs.c index 5c0b0a825..2de766c89 100644 --- a/src/cff/t2objs.c +++ b/src/cff/t2objs.c @@ -198,7 +198,7 @@ #ifdef TT_CONFIG_OPTION_EXTEND_ENGINE return TT_Init_Extensions( driver ); #else - UNUSED(driver); + UNUSED( driver ); return T2_Err_Ok; #endif } @@ -222,7 +222,7 @@ #ifdef TT_CONFIG_OPTION_EXTEND_ENGINE TT_Done_Extensions( driver ); #else - UNUSED(driver); + UNUSED( driver ); #endif } diff --git a/src/cff/t2parse.c b/src/cff/t2parse.c index 8238a81cb..1d4fc5a84 100644 --- a/src/cff/t2parse.c +++ b/src/cff/t2parse.c @@ -280,9 +280,9 @@ FT_Error parse_font_matrix( T2_Parser* parser ) { CFF_Font_Dict* dict = (CFF_Font_Dict*)parser->object; - FT_Matrix* matrix = &dict->font_matrix; - FT_Byte** data = parser->stack; - FT_Error error; + FT_Matrix* matrix = &dict->font_matrix; + FT_Byte** data = parser->stack; + FT_Error error; error = T2_Err_Stack_Underflow; @@ -304,9 +304,9 @@ FT_Error parse_font_bbox( T2_Parser* parser ) { CFF_Font_Dict* dict = (CFF_Font_Dict*)parser->object; - FT_BBox* bbox = &dict->font_bbox; - FT_Byte** data = parser->stack; - FT_Error error; + FT_BBox* bbox = &dict->font_bbox; + FT_Byte** data = parser->stack; + FT_Error error; error = T2_Err_Stack_Underflow; @@ -328,8 +328,8 @@ FT_Error parse_private_dict( T2_Parser* parser ) { CFF_Font_Dict* dict = (CFF_Font_Dict*)parser->object; - FT_Byte** data = parser->stack; - FT_Error error; + FT_Byte** data = parser->stack; + FT_Error error; error = T2_Err_Stack_Underflow; @@ -349,8 +349,8 @@ FT_Error parse_cid_ros( T2_Parser* parser ) { CFF_Font_Dict* dict = (CFF_Font_Dict*)parser->object; - FT_Byte** data = parser->stack; - FT_Error error; + FT_Byte** data = parser->stack; + FT_Error error; error = T2_Err_Stack_Underflow; @@ -395,7 +395,7 @@ code | T2CODE, \ (FT_UInt)(char*)&T2_REF( T2TYPE, name ), \ sizeof( T2_REF( T2TYPE, name ) ), \ - 0, 0, 0 \ + 0, 0, 0 \ }, #undef T2_FIELD_DELTA @@ -478,7 +478,8 @@ /* and look for it in our current list. */ FT_UInt code; - FT_UInt num_args = (FT_UInt)(parser->top - parser->stack); + FT_UInt num_args = (FT_UInt) + ( parser->top - parser->stack ); const T2_Field_Handler* field; @@ -516,28 +517,35 @@ case t2_kind_fixed: val = t2_parse_fixed( parser->stack ); - /* A slight note regarding the following: */ - /* */ - /* SIZEOF_INT is defined in */ - /* and gives the size in bytes of the "int" type on the */ - /* current platform.. */ - /* */ - /* Only on 16-bit systems can the value of SIZEOF_INT be */ - /* less than 4. In this case SIZEOF_LONG is always 4 */ - /* */ - /* On a 64-bit system, SIZEOF_LONG can be 8, which is */ - /* handled by the default case.. */ - /* */ - + /* SIZEOF_INT is defined in */ + /* and gives the size in bytes of the `int' type on the */ + /* current platform. */ + /* */ + /* Only on 16-bit systems the value of SIZEOF_INT can be */ + /* less than 4. In this case SIZEOF_LONG is always 4. */ + /* */ + /* On a 64-bit system, SIZEOF_LONG can be 8, which is */ + /* handled by the default case. */ + /* */ Store_Number: switch ( field->size ) { - case 1: *(FT_Byte*)q = (FT_Byte)val; break; - case 2: *(FT_Short*)q = (FT_Short)val; break; + case 1: + *(FT_Byte*)q = (FT_Byte)val; + break; + + case 2: + *(FT_Short*)q = (FT_Short)val; + break; + #if SIZEOF_INT == 4 - case 4: *(FT_Int*)q = (FT_Int)val; break; + case 4: + *(FT_Int*)q = (FT_Int)val; + break; #endif - default: *(FT_Long*)q = val; + + default: + *(FT_Long*)q = val; } break; diff --git a/src/cid/cidafm.c b/src/cid/cidafm.c index 86b2bce05..3b1bd2673 100644 --- a/src/cid/cidafm.c +++ b/src/cid/cidafm.c @@ -40,7 +40,7 @@ LOCAL_FUNC void CID_Done_AFM( FT_Memory memory, - CID_AFM* afm ) + CID_AFM* afm ) { FREE( afm->kern_pairs ); afm->num_pairs = 0; @@ -162,15 +162,15 @@ FT_Error CID_Read_AFM( FT_Face cid_face, FT_Stream stream ) { - FT_Error error; - FT_Memory memory = stream->memory; - FT_Byte* start; - FT_Byte* limit; - FT_Byte* p; - FT_Int count = 0; - CID_Kern_Pair* pair; - T1_Font* type1 = &((T1_Face)t1_face)->type1; - CID_AFM* afm = 0; + FT_Error error; + FT_Memory memory = stream->memory; + FT_Byte* start; + FT_Byte* limit; + FT_Byte* p; + FT_Int count = 0; + CID_Kern_Pair* pair; + T1_Font* type1 = &((T1_Face)t1_face)->type1; + CID_AFM* afm = 0; if ( ACCESS_Frame( stream->size ) ) @@ -194,7 +194,7 @@ goto Exit; /* allocate the pairs */ - if ( ALLOC( afm, sizeof ( *afm ) ) || + if ( ALLOC( afm, sizeof ( *afm ) ) || ALLOC_ARRAY( afm->kern_pairs, count, CID_Kern_Pair ) ) goto Exit; @@ -245,7 +245,7 @@ /* find the kerning for a given glyph pair */ LOCAL_FUNC - void CID_Get_Kerning( CID_AFM* afm, + void CID_Get_Kerning( CID_AFM* afm, FT_UInt glyph1, FT_UInt glyph2, FT_Vector* kerning ) diff --git a/src/cid/cidgload.c b/src/cid/cidgload.c index 96519306f..152758330 100644 --- a/src/cid/cidgload.c +++ b/src/cid/cidgload.c @@ -143,8 +143,8 @@ /* glyph :: The current glyph object. */ /* */ LOCAL_FUNC - void CID_Init_Builder( CID_Builder* builder, - CID_Face face, + void CID_Init_Builder( CID_Builder* builder, + CID_Face face, CID_Size size, CID_GlyphSlot glyph ) { @@ -159,11 +159,11 @@ { FT_GlyphLoader* loader = glyph->root.loader; - + builder->loader = loader; builder->base = &loader->base.outline; builder->current = &loader->current.outline; - + FT_GlyphLoader_Rewind( loader ); } @@ -202,6 +202,7 @@ { CID_GlyphSlot glyph = builder->glyph; + if ( glyph ) glyph->root.outline = *builder->base; } @@ -299,7 +300,7 @@ { if ( outline->n_contours > 0 ) outline->contours[outline->n_contours - 1] = outline->n_points - 1; - + outline->n_contours++; } return error; @@ -454,7 +455,7 @@ error = FT_GlyphLoader_Check_Subglyphs( loader, 2 ); if ( error ) goto Exit; - + subg = loader->current.subglyphs; /* subglyph 0 = base character */ @@ -474,13 +475,13 @@ /* set up remaining glyph fields */ glyph->num_subglyphs = 2; glyph->format = ft_glyph_format_composite; - + loader->current.num_subglyphs = 2; } /* First load `bchar' in builder */ /* now load the unscaled outline */ - if ( decoder->builder.loader ) + if ( decoder->builder.loader ) FT_GlyphLoader_Prepare( decoder->builder.loader ); error = cid_load_glyph( decoder, bchar_index ); /* load one glyph */ @@ -516,7 +517,7 @@ { FT_Outline dummy; - + dummy.n_points = base->n_points - n_base_points; dummy.points = base->points + n_base_points; FT_Outline_Translate( &dummy, adx - asb, ady ); @@ -585,9 +586,9 @@ /* now, execute loop */ while ( ip < limit ) { - FT_Int* top = decoder->top; + FT_Int* top = decoder->top; CID_Operator op = op_none; - FT_Long value = 0; + FT_Long value = 0; /********************************************************************/ @@ -1376,8 +1377,8 @@ LOCAL_FUNC FT_Error CID_Load_Glyph( CID_GlyphSlot glyph, CID_Size size, - FT_Int glyph_index, - FT_Int load_flags ) + FT_Int glyph_index, + FT_Int load_flags ) { FT_Error error; CID_Decoder decoder; diff --git a/src/cid/cidgload.h b/src/cid/cidgload.h index b4bc0c411..555586a21 100644 --- a/src/cid/cidgload.h +++ b/src/cid/cidgload.h @@ -82,7 +82,7 @@ { FT_Memory memory; CID_Face face; - CID_GlyphSlot glyph; + CID_GlyphSlot glyph; FT_GlyphLoader* loader; FT_Outline* base; FT_Outline* current; @@ -142,8 +142,8 @@ LOCAL_DEF - void CID_Init_Builder( CID_Builder* builder, - CID_Face face, + void CID_Init_Builder( CID_Builder* builder, + CID_Face face, CID_Size size, CID_GlyphSlot glyph ); @@ -173,8 +173,8 @@ LOCAL_DEF FT_Error CID_Load_Glyph( CID_GlyphSlot glyph, CID_Size size, - FT_Int glyph_index, - FT_Int load_flags ); + FT_Int glyph_index, + FT_Int load_flags ); #ifdef __cplusplus diff --git a/src/cid/cidload.c b/src/cid/cidload.c index 41b823da3..1a0b53880 100644 --- a/src/cid/cidload.c +++ b/src/cid/cidload.c @@ -83,8 +83,8 @@ static - FT_Error cid_load_keyword( CID_Face face, - CID_Loader* loader, + FT_Error cid_load_keyword( CID_Face face, + CID_Loader* loader, const CID_Field_Rec* keyword ) { FT_Error error; diff --git a/src/cid/cidobjs.h b/src/cid/cidobjs.h index bbc391df5..aec06c864 100644 --- a/src/cid/cidobjs.h +++ b/src/cid/cidobjs.h @@ -38,7 +38,7 @@ /*************************************************************************/ /* */ /* */ - /* CID_Driver */ + /* CID_Driver */ /* */ /* */ /* A handle to a Type 1 driver object. */ @@ -49,7 +49,7 @@ /*************************************************************************/ /* */ /* */ - /* CID_Size */ + /* CID_Size */ /* */ /* */ /* A handle to a Type 1 size object. */ @@ -60,7 +60,7 @@ /*************************************************************************/ /* */ /* */ - /* CID_GlyphSlot */ + /* CID_GlyphSlot */ /* */ /* */ /* A handle to a Type 1 glyph slot object. */ @@ -71,7 +71,7 @@ /*************************************************************************/ /* */ /* */ - /* CID_CharMap */ + /* CID_CharMap */ /* */ /* */ /* A handle to a Type 1 character mapping object. */ @@ -81,7 +81,7 @@ /* The driver is responsible for making up charmap objects */ /* corresponding to these tables. */ /* */ - typedef struct CID_CharMapRec_* CID_CharMap; + typedef struct CID_CharMapRec_* CID_CharMap; /*************************************************************************/ @@ -99,7 +99,7 @@ } CID_SizeRec; - typedef struct CID_GlyphSlotRec_ + typedef struct CID_GlyphSlotRec_ { FT_GlyphSlotRec root; diff --git a/src/cid/cidparse.c b/src/cid/cidparse.c index e70d62268..d4ec6bcd9 100644 --- a/src/cid/cidparse.c +++ b/src/cid/cidparse.c @@ -42,7 +42,7 @@ /*************************************************************************/ /*************************************************************************/ /***** *****/ - /***** IMPLEMENTATION OF CID_TABLE OBJECT *****/ + /***** IMPLEMENTATION OF CID_TABLE OBJECT *****/ /***** *****/ /*************************************************************************/ /*************************************************************************/ @@ -52,10 +52,10 @@ /*************************************************************************/ /* */ /* */ - /* CID_New_Table */ + /* CID_New_Table */ /* */ /* */ - /* Initializes a CID_Table. */ + /* Initializes a CID_Table. */ /* */ /* */ /* table :: The address of the target table. */ @@ -71,8 +71,8 @@ /* */ LOCAL_FUNC FT_Error CID_New_Table( CID_Table* table, - FT_Int count, - FT_Memory memory ) + FT_Int count, + FT_Memory memory ) { FT_Error error; @@ -99,7 +99,7 @@ static void shift_elements( CID_Table* table, - FT_Byte* old_base ) + FT_Byte* old_base ) { FT_Long delta = table->block - old_base; FT_Byte** offset = table->elements; @@ -117,7 +117,7 @@ static FT_Error reallocate_t1_table( CID_Table* table, - FT_Int new_size ) + FT_Int new_size ) { FT_Memory memory = table->memory; FT_Byte* old_base = table->block; @@ -141,10 +141,10 @@ /*************************************************************************/ /* */ /* */ - /* CID_Add_Table */ + /* CID_Add_Table */ /* */ /* */ - /* Adds an object to a CID_Table, possibly growing its memory block. */ + /* Adds an object to a CID_Table, possibly growing its memory block. */ /* */ /* */ /* table :: The target table. */ @@ -162,9 +162,9 @@ /* */ LOCAL_FUNC FT_Error CID_Add_Table( CID_Table* table, - FT_Int index, - void* object, - FT_Int length ) + FT_Int index, + void* object, + FT_Int length ) { if ( index < 0 || index > table->max_elems ) { @@ -202,10 +202,10 @@ /*************************************************************************/ /* */ /* */ - /* CID_Done_Table */ + /* CID_Done_Table */ /* */ /* */ - /* Finalizes a CID_Table (reallocate it to its current cursor). */ + /* Finalizes a CID_Table (reallocate it to its current cursor). */ /* */ /* */ /* table :: The target table. */ @@ -292,7 +292,7 @@ LOCAL_FUNC - void CID_ToToken( CID_Parser* parser, + void CID_ToToken( CID_Parser* parser, CID_Token_Rec* token ) { FT_Byte* cur; @@ -376,10 +376,10 @@ LOCAL_FUNC - void CID_ToTokenArray( CID_Parser* parser, + void CID_ToTokenArray( CID_Parser* parser, CID_Token_Rec* tokens, - FT_UInt max_tokens, - FT_Int* pnum_tokens ) + FT_UInt max_tokens, + FT_Int* pnum_tokens ) { CID_Token_Rec master; @@ -390,8 +390,8 @@ if ( master.type == t1_token_array ) { - FT_Byte* old_cursor = parser->cursor; - FT_Byte* old_limit = parser->limit; + FT_Byte* old_cursor = parser->cursor; + FT_Byte* old_limit = parser->limit; CID_Token_Rec* cur = tokens; CID_Token_Rec* limit = cur + max_tokens; @@ -710,9 +710,9 @@ /* Loads a simple field (i.e. non-table) into the current */ /* list of objects */ LOCAL_FUNC - FT_Error CID_Load_Field( CID_Parser* parser, + FT_Error CID_Load_Field( CID_Parser* parser, const CID_Field_Rec* field, - void* object ) + void* object ) { CID_Token_Rec token; FT_Byte* cur; @@ -803,16 +803,16 @@ LOCAL_FUNC - FT_Error CID_Load_Field_Table( CID_Parser* parser, + FT_Error CID_Load_Field_Table( CID_Parser* parser, const CID_Field_Rec* field, - void* object ) + void* object ) { CID_Token_Rec elements[T1_MAX_TABLE_ELEMENTS]; CID_Token_Rec* token; - FT_Int num_elements; - FT_Error error = 0; - FT_Byte* old_cursor; - FT_Byte* old_limit; + FT_Int num_elements; + FT_Error error = 0; + FT_Byte* old_cursor; + FT_Byte* old_limit; CID_Field_Rec fieldrec = *(CID_Field_Rec*)field; diff --git a/src/cid/cidparse.h b/src/cid/cidparse.h index dff348b1d..092f40e1c 100644 --- a/src/cid/cidparse.h +++ b/src/cid/cidparse.h @@ -32,10 +32,10 @@ /*************************************************************************/ /* */ /* */ - /* CID_Table */ + /* CID_Table */ /* */ /* */ - /* A CID_Table is a simple object used to store an array of objects */ + /* A CID_Table is a simple object used to store an array of objects */ /* in a single memory block. */ /* */ /* */ @@ -62,7 +62,7 @@ /* memory :: The memory object used for memory operations */ /* (allocation resp. reallocation). */ /* */ - typedef struct CID_Table_ + typedef struct CID_Table_ { FT_Byte* block; /* current memory block */ FT_Int cursor; /* current cursor in memory block */ @@ -81,14 +81,14 @@ LOCAL_DEF FT_Error CID_New_Table( CID_Table* table, - FT_Int count, - CID_Memory memory ); + FT_Int count, + CID_Memory memory ); LOCAL_DEF FT_Error CID_Add_Table( CID_Table* table, - FT_Int index, - void* object, - FT_Int length ); + FT_Int index, + void* object, + FT_Int length ); LOCAL_DEF void CID_Release_Table( CID_Table* table ); @@ -183,7 +183,7 @@ /* simple enumeration type used to identify token types */ - typedef enum CID_Token_Type_ + typedef enum CID_Token_Type_ { t1_token_none = 0, t1_token_any, @@ -199,9 +199,9 @@ /* a simple structure used to identify tokens */ typedef struct CID_Token_Rec_ { - FT_Byte* start; /* first character of token in input stream */ - FT_Byte* limit; /* first character after the token */ - CID_Token_Type type; /* type of token.. */ + FT_Byte* start; /* first character of token in input stream */ + FT_Byte* limit; /* first character after the token */ + CID_Token_Type type; /* type of token */ } CID_Token_Rec; @@ -212,7 +212,7 @@ /* enumeration type used to identify object fields */ - typedef enum CID_Field_Type_ + typedef enum CID_Field_Type_ { t1_field_none = 0, t1_field_bool, @@ -228,7 +228,7 @@ } CID_Field_Type; - typedef enum CID_Field_Location_ + typedef enum CID_Field_Location_ { t1_field_cid_info, t1_field_font_dict, @@ -245,17 +245,17 @@ CID_Parser* parser ); /* structure type used to model object fields */ - typedef struct CID_Field_Rec_ + typedef struct CID_Field_Rec_ { - const char* ident; /* field identifier */ + const char* ident; /* field identifier */ CID_Field_Location location; - CID_Field_Type type; /* type of field */ - CID_Field_Parser reader; - FT_UInt offset; /* offset of field in object */ - FT_UInt size; /* size of field in bytes */ - FT_UInt array_max; /* maximal number of elements for */ + CID_Field_Type type; /* type of field */ + CID_Field_Parser reader; + FT_UInt offset; /* offset of field in object */ + FT_UInt size; /* size of field in bytes */ + FT_UInt array_max; /* maximal number of elements for */ /* array */ - FT_UInt count_offset; /* offset of element count for */ + FT_UInt count_offset; /* offset of element count for */ /* arrays */ } CID_Field_Rec; @@ -263,83 +263,83 @@ #define CID_FIELD_REF( s, f ) ( ((s*)0)->f ) #define CID_NEW_SIMPLE_FIELD( _ident, _type, _fname ) \ - { \ - _ident, T1CODE, _type, \ - 0, \ + { \ + _ident, T1CODE, _type, \ + 0, \ (FT_UInt)(char*)&CID_FIELD_REF( T1TYPE, _fname ), \ sizeof ( CID_FIELD_REF( T1TYPE, _fname ) ), \ - 0, 0 \ + 0, 0 \ }, #define CID_NEW_CALLBACK_FIELD( _ident, _reader ) \ - { \ - _ident, T1CODE, t1_field_callback, \ - _reader, \ - 0, 0, \ - 0, 0 \ + { \ + _ident, T1CODE, t1_field_callback, \ + _reader, \ + 0, 0, \ + 0, 0 \ }, #define CID_NEW_TABLE_FIELD( _ident, _type, _fname, _max ) \ - { \ - _ident, T1CODE, _type, \ - 0, \ + { \ + _ident, T1CODE, _type, \ + 0, \ (FT_UInt)(char*)&CID_FIELD_REF( T1TYPE, _fname ), \ sizeof ( CID_FIELD_REF( T1TYPE, _fname )[0] ), \ - _max, \ + _max, \ (FT_UInt)(char*)&CID_FIELD_REF( T1TYPE, num_ ## _fname ) \ }, #define CID_NEW_TABLE_FIELD2( _ident, _type, _fname, _max ) \ - { \ - _ident, T1CODE, _type, \ - 0, \ + { \ + _ident, T1CODE, _type, \ + 0, \ (FT_UInt)(char*)&CID_FIELD_REF( T1TYPE, _fname ), \ sizeof ( CID_FIELD_REF( T1TYPE, _fname )[0] ), \ - _max, 0 \ + _max, 0 \ }, -#define CID_FIELD_BOOL( _ident, _fname ) \ +#define CID_FIELD_BOOL( _ident, _fname ) \ CID_NEW_SIMPLE_FIELD( _ident, t1_field_bool, _fname ) #define CID_FIELD_NUM( _ident, _fname ) \ CID_NEW_SIMPLE_FIELD( _ident, t1_field_integer, _fname ) -#define CID_FIELD_FIXED( _ident, _fname ) \ +#define CID_FIELD_FIXED( _ident, _fname ) \ CID_NEW_SIMPLE_FIELD( _ident, t1_field_fixed, _fname ) -#define CID_FIELD_STRING( _ident, _fname ) \ +#define CID_FIELD_STRING( _ident, _fname ) \ CID_NEW_SIMPLE_FIELD( _ident, t1_field_string, _fname ) -#define CID_FIELD_NUM_TABLE( _ident, _fname, _fmax ) \ - CID_NEW_TABLE_FIELD( _ident, t1_field_integer_array, \ +#define CID_FIELD_NUM_TABLE( _ident, _fname, _fmax ) \ + CID_NEW_TABLE_FIELD( _ident, t1_field_integer_array, \ _fname, _fmax ) -#define CID_FIELD_FIXED_TABLE( _ident, _fname, _fmax ) \ - CID_NEW_TABLE_FIELD( _ident, t1_field_fixed_array, \ +#define CID_FIELD_FIXED_TABLE( _ident, _fname, _fmax ) \ + CID_NEW_TABLE_FIELD( _ident, t1_field_fixed_array, \ _fname, _fmax ) -#define CID_FIELD_NUM_TABLE2( _ident, _fname, _fmax ) \ - CID_NEW_TABLE_FIELD2( _ident, t1_field_integer_array, \ +#define CID_FIELD_NUM_TABLE2( _ident, _fname, _fmax ) \ + CID_NEW_TABLE_FIELD2( _ident, t1_field_integer_array, \ _fname, _fmax ) -#define CID_FIELD_FIXED_TABLE2( _ident, _fname, _fmax ) \ - CID_NEW_TABLE_FIELD2( _ident, t1_field_fixed_array, \ +#define CID_FIELD_FIXED_TABLE2( _ident, _fname, _fmax ) \ + CID_NEW_TABLE_FIELD2( _ident, t1_field_fixed_array, \ _fname, _fmax ) -#define CID_FIELD_CALLBACK( _ident, _name ) \ +#define CID_FIELD_CALLBACK( _ident, _name ) \ CID_NEW_CALLBACK_FIELD( _ident, parse_ ## _name ) LOCAL_DEF - FT_Error CID_Load_Field( CID_Parser* parser, + FT_Error CID_Load_Field( CID_Parser* parser, const CID_Field_Rec* field, - void* object ); + void* object ); LOCAL_DEF - FT_Error CID_Load_Field_Table( CID_Parser* parser, + FT_Error CID_Load_Field_Table( CID_Parser* parser, const CID_Field_Rec* field, - void* object ); + void* object ); #ifdef __cplusplus diff --git a/src/cid/cidriver.c b/src/cid/cidriver.c index 11be5c761..7f07868ba 100644 --- a/src/cid/cidriver.c +++ b/src/cid/cidriver.c @@ -181,9 +181,9 @@ "t1cid", /* module name */ 0x10000L, /* version 1.0 of driver */ 0x20000L, /* requires FreeType 2.0 */ - + 0, - + (FT_Module_Constructor)CID_Init_Driver, (FT_Module_Destructor) CID_Done_Driver, (FT_Module_Requester) CID_Get_Interface diff --git a/src/macfond/fonddrvr.c b/src/macfond/fonddrvr.c index 8066d0d52..ce0a2a50d 100644 --- a/src/macfond/fonddrvr.c +++ b/src/macfond/fonddrvr.c @@ -427,7 +427,7 @@ error: return FT_Err_Out_Of_Memory; } - #if 0 +#if 0 { FILE* f; char * path; diff --git a/src/sfnt/sfobjs.c b/src/sfnt/sfobjs.c index acdbb759e..906d0e079 100644 --- a/src/sfnt/sfobjs.c +++ b/src/sfnt/sfobjs.c @@ -244,9 +244,10 @@ FT_Error error; SFNT_Interface* sfnt = (SFNT_Interface*)face->sfnt; - UNUSED(face_index); - UNUSED(num_params); - UNUSED(params); + UNUSED( face_index ); + UNUSED( num_params ); + UNUSED( params ); + /* Load tables */ if ( LOAD_( header ) || diff --git a/src/smooth/ftgrays.h b/src/smooth/ftgrays.h index feb74843b..51f44ce4e 100644 --- a/src/smooth/ftgrays.h +++ b/src/smooth/ftgrays.h @@ -42,8 +42,8 @@ FT_EXPORT_VAR(FT_Raster_Funcs) ft_grays_raster; - #ifdef __cplusplus +#ifdef __cplusplus } - #endif +#endif #endif diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c index e2cbbad86..7ca8077e8 100644 --- a/src/truetype/ttgload.c +++ b/src/truetype/ttgload.c @@ -920,6 +920,7 @@ FT_Vector* p1; FT_Vector* p2; + if ( start_point + k >= (FT_UInt)num_base_points || l >= (FT_UInt)num_new_points ) { @@ -1023,8 +1024,8 @@ pp1[0] = loader->pp1; pp1[1] = loader->pp2; + pts->tags[num_points ] = 0; pts->tags[num_points + 1] = 0; - pts->tags[num_points + 2] = 0; /* if hinting, round the phantom points */ if ( IS_HINTED( loader->load_flags ) ) diff --git a/src/type1z/z1parse.c b/src/type1z/z1parse.c index 992d39b2b..06e106959 100644 --- a/src/type1z/z1parse.c +++ b/src/type1z/z1parse.c @@ -244,10 +244,10 @@ /*************************************************************************/ /*************************************************************************/ - #define IS_Z1_WHITESPACE(c) ( (c) == ' ' || (c) == '\t' ) - #define IS_Z1_LINESPACE(c) ( (c) == '\r' || (c) == '\n' ) +#define IS_Z1_WHITESPACE(c) ( (c) == ' ' || (c) == '\t' ) +#define IS_Z1_LINESPACE(c) ( (c) == '\r' || (c) == '\n' ) - #define IS_Z1_SPACE(c) ( IS_Z1_WHITESPACE(c) || IS_Z1_LINESPACE(c) ) +#define IS_Z1_SPACE(c) ( IS_Z1_WHITESPACE(c) || IS_Z1_LINESPACE(c) ) LOCAL_FUNC void Z1_Skip_Spaces( Z1_Parser* parser )