From fba3b6d1979c1d1ad0d56d46fc2d787f111c07fb Mon Sep 17 00:00:00 2001 From: marha Date: Thu, 26 Jun 2014 09:46:14 +0200 Subject: Updated to freetype 2.5.3 --- freetype/src/base/basepic.c | 13 +- freetype/src/base/ftbbox.c | 334 +++++++++++-------------------------------- freetype/src/base/ftbitmap.c | 8 +- freetype/src/base/ftcalc.c | 34 ++++- freetype/src/base/ftdebug.c | 2 +- freetype/src/base/ftglyph.c | 62 ++++---- freetype/src/base/ftinit.c | 4 +- freetype/src/base/ftmac.c | 1 - freetype/src/base/ftobjs.c | 62 +++++--- freetype/src/base/ftoutln.c | 11 +- freetype/src/base/ftpic.c | 5 +- freetype/src/base/ftrfork.c | 26 +++- freetype/src/base/ftsynth.c | 11 +- freetype/src/base/md5.c | 51 +++---- freetype/src/base/md5.h | 2 +- freetype/src/base/rules.mk | 13 +- 16 files changed, 273 insertions(+), 366 deletions(-) (limited to 'freetype/src/base') diff --git a/freetype/src/base/basepic.c b/freetype/src/base/basepic.c index 5268e7c67..aeb6fd577 100644 --- a/freetype/src/base/basepic.c +++ b/freetype/src/base/basepic.c @@ -4,7 +4,7 @@ /* */ /* The FreeType position independent code services for base. */ /* */ -/* Copyright 2009, 2012 by */ +/* Copyright 2009, 2012, 2013 by */ /* Oran Agra and Mickey Gabel. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -35,7 +35,7 @@ /* forward declaration of PIC init function from ftrfork.c */ /* (not modularized) */ void - FT_Init_Table_raccess_guess_table( ft_raccess_guess_rec* record ); + FT_Init_Table_ft_raccess_guess_table( ft_raccess_guess_rec* record ); #endif /* forward declaration of PIC init functions from ftinit.c */ @@ -75,7 +75,7 @@ /* 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 ) ); pic_container->base = container; @@ -92,17 +92,16 @@ FT_Init_Class_ft_bitmap_glyph_class( &container->ft_bitmap_glyph_class ); #ifdef FT_CONFIG_OPTION_MAC_FONTS - FT_Init_Table_raccess_guess_table( + FT_Init_Table_ft_raccess_guess_table( (ft_raccess_guess_rec*)&container->ft_raccess_guess_table ); #endif -Exit: - if( error ) + Exit: + if ( error ) ft_base_pic_free( library ); return error; } - #endif /* FT_CONFIG_OPTION_PIC */ diff --git a/freetype/src/base/ftbbox.c b/freetype/src/base/ftbbox.c index 6d1c44cb2..8d3f383b4 100644 --- a/freetype/src/base/ftbbox.c +++ b/freetype/src/base/ftbbox.c @@ -85,7 +85,7 @@ /* BBox_Conic_Check */ /* */ /* */ - /* Finds the extrema of a 1-dimensional conic Bezier curve and update */ + /* Find the extrema of a 1-dimensional conic Bezier curve and update */ /* a bounding range. This version uses direct computation, as it */ /* doesn't need square roots. */ /* */ @@ -108,30 +108,19 @@ FT_Pos* min, FT_Pos* max ) { - if ( y1 <= y3 && y2 == y1 ) /* flat arc */ - goto Suite; - - if ( y1 < y3 ) - { - if ( y2 >= y1 && y2 <= y3 ) /* ascending arc */ - goto Suite; - } - else - { - if ( y2 >= y3 && y2 <= y1 ) /* descending arc */ - { - y2 = y1; - y1 = y3; - y3 = y2; - goto Suite; - } - } - - y1 = y3 = y1 - FT_MulDiv( y2 - y1, y2 - y1, y1 - 2*y2 + y3 ); - - Suite: - if ( y1 < *min ) *min = y1; - if ( y3 > *max ) *max = y3; + /* This function is only called when a control off-point is outside */ + /* the bbox that contains all on-points. It finds a local extremum */ + /* within the segment, equal to (y1*y3 - y2*y2)/(y1 - 2*y2 + y3). */ + /* Or, offsetting from y2, we get */ + + y1 -= y2; + y3 -= y2; + y2 += FT_MulDiv( y1, y3, y1 + y3 ); + + if ( y2 < *min ) + *min = y2; + if ( y2 > *max ) + *max = y2; } @@ -195,9 +184,9 @@ /* BBox_Cubic_Check */ /* */ /* */ - /* Finds the extrema of a 1-dimensional cubic Bezier curve and */ - /* updates a bounding range. This version uses splitting because we */ - /* don't want to use square roots and extra accuracy. */ + /* Find the extrema of a 1-dimensional cubic Bezier curve and */ + /* update a bounding range. This version uses iterative splitting */ + /* because it is faster than the exact solution with square roots. */ /* */ /* */ /* p1 :: The start coordinate. */ @@ -213,28 +202,16 @@ /* */ /* max :: The address of the current maximum. */ /* */ - -#if 0 - - static void - BBox_Cubic_Check( FT_Pos p1, - FT_Pos p2, - FT_Pos p3, - FT_Pos p4, - FT_Pos* min, - FT_Pos* max ) + static FT_Pos + update_cubic_max( FT_Pos q1, + FT_Pos q2, + FT_Pos q3, + FT_Pos q4, + FT_Pos max ) { - FT_Pos q1, q2, q3, q4; - - - q1 = p1; - q2 = p2; - q3 = p3; - q4 = p4; - - /* for a conic segment to possibly reach new maximum */ - /* one of its off-points must be above the current value */ - while ( q2 > *max || q3 > *max ) + /* for a cubic segment to possibly reach new maximum, at least */ + /* one of its off-points must stay above the current value */ + while ( q2 > max || q3 > max ) { /* determine which half contains the maximum and split */ if ( q1 + q2 > q3 + q4 ) /* first half */ @@ -260,231 +237,91 @@ q3 = q3 / 2; } - /* check if either end reached the maximum */ + /* check whether either end reached the maximum */ if ( q1 == q2 && q1 >= q3 ) { - *max = q1; + max = q1; break; } if ( q3 == q4 && q2 <= q4 ) { - *max = q4; + max = q4; break; } } - q1 = p1; - q2 = p2; - q3 = p3; - q4 = p4; - - /* for a conic segment to possibly reach new minimum */ - /* one of its off-points must be below the current value */ - while ( q2 < *min || q3 < *min ) - { - /* determine which half contains the minimum and split */ - if ( q1 + q2 < q3 + q4 ) /* first half */ - { - q4 = q4 + q3; - q3 = q3 + q2; - q2 = q2 + q1; - q4 = q4 + q3; - q3 = q3 + q2; - q4 = ( q4 + q3 ) / 8; - q3 = q3 / 4; - q2 = q2 / 2; - } - else /* second half */ - { - q1 = q1 + q2; - q2 = q2 + q3; - q3 = q3 + q4; - q1 = q1 + q2; - q2 = q2 + q3; - q1 = ( q1 + q2 ) / 8; - q2 = q2 / 4; - q3 = q3 / 2; - } - - /* check if either end reached the minimum */ - if ( q1 == q2 && q1 <= q3 ) - { - *min = q1; - break; - } - if ( q3 == q4 && q2 >= q4 ) - { - *min = q4; - break; - } - } - } - -#else - - static void - test_cubic_extrema( FT_Pos y1, - FT_Pos y2, - FT_Pos y3, - FT_Pos y4, - FT_Fixed u, - FT_Pos* min, - FT_Pos* max ) - { - /* FT_Pos a = y4 - 3*y3 + 3*y2 - y1; */ - FT_Pos b = y3 - 2*y2 + y1; - FT_Pos c = y2 - y1; - FT_Pos d = y1; - FT_Pos y; - FT_Fixed uu; - - FT_UNUSED ( y4 ); - - - /* The polynomial is */ - /* */ - /* P(x) = a*x^3 + 3b*x^2 + 3c*x + d , */ - /* */ - /* dP/dx = 3a*x^2 + 6b*x + 3c . */ - /* */ - /* However, we also have */ - /* */ - /* dP/dx(u) = 0 , */ - /* */ - /* which implies by subtraction that */ - /* */ - /* P(u) = b*u^2 + 2c*u + d . */ - - if ( u > 0 && u < 0x10000L ) - { - uu = FT_MulFix( u, u ); - y = d + FT_MulFix( c, 2*u ) + FT_MulFix( b, uu ); - - if ( y < *min ) *min = y; - if ( y > *max ) *max = y; - } + return max; } static void - BBox_Cubic_Check( FT_Pos y1, - FT_Pos y2, - FT_Pos y3, - FT_Pos y4, + BBox_Cubic_Check( FT_Pos p1, + FT_Pos p2, + FT_Pos p3, + FT_Pos p4, FT_Pos* min, FT_Pos* max ) { - /* always compare first and last points */ - if ( y1 < *min ) *min = y1; - else if ( y1 > *max ) *max = y1; + FT_Pos nmin, nmax; + FT_Int shift; - if ( y4 < *min ) *min = y4; - else if ( y4 > *max ) *max = y4; - /* now, try to see if there are split points here */ - if ( y1 <= y4 ) + /* This function is only called when a control off-point is outside */ + /* the bbox that contains all on-points. It finds a local extremum */ + /* within the segment using iterative bisection of the segment. */ + /* The fixed-point arithmetic of bisection is inherently stable */ + /* but may loose accuracy in the two lowest bits. To compensate, */ + /* we upscale the segment if there is room. Large values may need */ + /* to be downscaled to avoid overflows during bisection. */ + /* The control off-point outside the bbox is likely to have the top */ + /* absolute value among arguments. */ + + shift = 27 - FT_MSB( FT_ABS( p2 ) | FT_ABS( p3 ) ); + + if ( shift > 0 ) { - /* flat or ascending arc test */ - if ( y1 <= y2 && y2 <= y4 && y1 <= y3 && y3 <= y4 ) - return; + /* upscaling too much just wastes time */ + if ( shift > 2 ) + shift = 2; + + p1 <<= shift; + p2 <<= shift; + p3 <<= shift; + p4 <<= shift; + nmin = *min << shift; + nmax = *max << shift; } - else /* y1 > y4 */ + else { - /* descending arc test */ - if ( y1 >= y2 && y2 >= y4 && y1 >= y3 && y3 >= y4 ) - return; + p1 >>= -shift; + p2 >>= -shift; + p3 >>= -shift; + p4 >>= -shift; + nmin = *min >> -shift; + nmax = *max >> -shift; } - /* There are some split points. Find them. */ - /* We already made sure that a, b, and c below cannot be all zero. */ - { - FT_Pos a = y4 - 3*y3 + 3*y2 - y1; - FT_Pos b = y3 - 2*y2 + y1; - FT_Pos c = y2 - y1; - FT_Pos d; - FT_Fixed t; - FT_Int shift; - - - /* We need to solve `ax^2+2bx+c' here, without floating points! */ - /* The trick is to normalize to a different representation in order */ - /* to use our 16.16 fixed-point routines. */ - /* */ - /* We compute FT_MulFix(b,b) and FT_MulFix(a,c) after normalization. */ - /* These values must fit into a single 16.16 value. */ - /* */ - /* We normalize a, b, and c to `8.16' fixed-point values to ensure */ - /* that their product is held in a `16.16' value including the sign. */ - /* Necessarily, we need to shift `a', `b', and `c' so that the most */ - /* significant bit of their absolute values is at position 22. */ - /* */ - /* This also means that we are using 23 bits of precision to compute */ - /* the zeros, independently of the range of the original polynomial */ - /* coefficients. */ - /* */ - /* This algorithm should ensure reasonably accurate values for the */ - /* zeros. Note that they are only expressed with 16 bits when */ - /* computing the extrema (the zeros need to be in 0..1 exclusive */ - /* to be considered part of the arc). */ - - shift = FT_MSB( FT_ABS( a ) | FT_ABS( b ) | FT_ABS( c ) ); - - if ( shift > 22 ) - { - shift -= 22; + nmax = update_cubic_max( p1, p2, p3, p4, nmax ); - /* this loses some bits of precision, but we use 23 of them */ - /* for the computation anyway */ - a >>= shift; - b >>= shift; - c >>= shift; - } - else - { - shift = 22 - shift; - - a <<= shift; - b <<= shift; - c <<= shift; - } + /* now flip the signs to update the minimum */ + nmin = -update_cubic_max( -p1, -p2, -p3, -p4, -nmin ); - /* handle a == 0 */ - if ( a == 0 ) - { - if ( b != 0 ) - { - t = - FT_DivFix( c, b ) / 2; - test_cubic_extrema( y1, y2, y3, y4, t, min, max ); - } - } - else - { - /* solve the equation now */ - d = FT_MulFix( b, b ) - FT_MulFix( a, c ); - if ( d < 0 ) - return; - - if ( d == 0 ) - { - /* there is a single split point at -b/a */ - t = - FT_DivFix( b, a ); - test_cubic_extrema( y1, y2, y3, y4, t, min, max ); - } - else - { - /* there are two solutions; we need to filter them */ - d = FT_SqrtFixed( (FT_Int32)d ); - t = - FT_DivFix( b - d, a ); - test_cubic_extrema( y1, y2, y3, y4, t, min, max ); - - t = - FT_DivFix( b + d, a ); - test_cubic_extrema( y1, y2, y3, y4, t, min, max ); - } - } + if ( shift > 0 ) + { + nmin >>= shift; + nmax >>= shift; + } + else + { + nmin <<= -shift; + nmax <<= -shift; } - } -#endif + if ( nmin < *min ) + *min = nmin; + if ( nmax > *max ) + *max = nmax; + } /*************************************************************************/ @@ -521,8 +358,9 @@ FT_Vector* to, TBBox_Rec* user ) { - /* we don't need to check `to' since it is always an `on' point, thus */ - /* within the bbox */ + /* We don't need to check `to' since it is always an on-point, */ + /* thus within the bbox. Only segments with an off-point outside */ + /* the bbox can possibly reach new extreme values. */ if ( CHECK_X( control1, user->bbox ) || CHECK_X( control2, user->bbox ) ) diff --git a/freetype/src/base/ftbitmap.c b/freetype/src/base/ftbitmap.c index 975818e14..5606745be 100644 --- a/freetype/src/base/ftbitmap.c +++ b/freetype/src/base/ftbitmap.c @@ -4,7 +4,7 @@ /* */ /* FreeType utility functions for bitmaps (body). */ /* */ -/* Copyright 2004-2009, 2011, 2013 by */ +/* Copyright 2004-2009, 2011, 2013, 2014 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -375,7 +375,7 @@ } - FT_Byte + static FT_Byte ft_gray_for_premultiplied_srgb_bgra( const FT_Byte* bgra ) { FT_Long a = bgra[3]; @@ -385,6 +385,10 @@ FT_Long l; + /* Short-circuit transparent color to avoid div-by-zero. */ + if ( !a ) + return 0; + /* * Luminosity for sRGB is defined using ~0.2126,0.7152,0.0722 * coefficients for RGB channels *on the linear colors*. diff --git a/freetype/src/base/ftcalc.c b/freetype/src/base/ftcalc.c index 0ec0d7893..6e655832f 100644 --- a/freetype/src/base/ftcalc.c +++ b/freetype/src/base/ftcalc.c @@ -4,7 +4,7 @@ /* */ /* Arithmetic computations (body). */ /* */ -/* Copyright 1996-2006, 2008, 2012-2013 by */ +/* Copyright 1996-2006, 2008, 2012-2014 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -128,7 +128,7 @@ } if ( z >= ( 1L << 1 ) ) { - z >>= 1; + /* z >>= 1; */ shift += 1; } @@ -816,6 +816,8 @@ } +#if 0 + /* documentation is in ftcalc.h */ FT_BASE_DEF( FT_Int32 ) @@ -850,6 +852,8 @@ return (FT_Int32)root; } +#endif /* 0 */ + /* documentation is in ftcalc.h */ @@ -945,11 +949,27 @@ FT_Pos d_in, d_out, d_corner; + /* We approximate the Euclidean metric (sqrt(x^2 + y^2)) with */ + /* the Taxicab metric (|x| + |y|), which can be computed much */ + /* faster. If one of the two vectors is much longer than the */ + /* other one, the direction of the shorter vector doesn't */ + /* influence the result any more. */ + /* */ + /* corner */ + /* x---------------------------x */ + /* \ / */ + /* \ / */ + /* in \ / out */ + /* \ / */ + /* o */ + /* Point */ + /* */ + if ( ax < 0 ) ax = -ax; if ( ay < 0 ) ay = -ay; - d_in = ax + ay; + d_in = ax + ay; /* d_in = || in || */ ax = out_x; if ( ax < 0 ) @@ -957,7 +977,7 @@ ay = out_y; if ( ay < 0 ) ay = -ay; - d_out = ax + ay; + d_out = ax + ay; /* d_out = || out || */ ax = out_x + in_x; if ( ax < 0 ) @@ -965,7 +985,11 @@ ay = out_y + in_y; if ( ay < 0 ) ay = -ay; - d_corner = ax + ay; + d_corner = ax + ay; /* d_corner = || in + out || */ + + /* now do a simple length comparison: */ + /* */ + /* d_in + d_out < 17/16 d_corner */ return ( d_in + d_out - d_corner ) < ( d_corner >> 4 ); } diff --git a/freetype/src/base/ftdebug.c b/freetype/src/base/ftdebug.c index b9156d15e..39ac6add0 100644 --- a/freetype/src/base/ftdebug.c +++ b/freetype/src/base/ftdebug.c @@ -152,7 +152,7 @@ /* the memory and stream components which are set to 7 and 5, */ /* respectively. */ /* */ - /* See the file for details of the */ + /* See the file for details of the */ /* available toggle names. */ /* */ /* The level must be between 0 and 7; 0 means quiet (except for serious */ diff --git a/freetype/src/base/ftglyph.c b/freetype/src/base/ftglyph.c index 5dd28a8c5..c62b3db0c 100644 --- a/freetype/src/base/ftglyph.c +++ b/freetype/src/base/ftglyph.c @@ -424,15 +424,16 @@ FT_Matrix* matrix, FT_Vector* delta ) { - const FT_Glyph_Class* clazz; - FT_Error error = FT_Err_Ok; + FT_Error error = FT_Err_Ok; if ( !glyph || !glyph->clazz ) error = FT_THROW( Invalid_Argument ); else { - clazz = glyph->clazz; + const FT_Glyph_Class* clazz = glyph->clazz; + + if ( clazz->glyph_transform ) { /* transform glyph image */ @@ -466,38 +467,33 @@ if ( !glyph || !glyph->clazz ) return; - else + + clazz = glyph->clazz; + if ( !clazz->glyph_bbox ) + return; + + /* retrieve bbox in 26.6 coordinates */ + clazz->glyph_bbox( glyph, acbox ); + + /* perform grid fitting if needed */ + if ( bbox_mode == FT_GLYPH_BBOX_GRIDFIT || + bbox_mode == FT_GLYPH_BBOX_PIXELS ) { - clazz = glyph->clazz; - if ( !clazz->glyph_bbox ) - return; - else - { - /* retrieve bbox in 26.6 coordinates */ - clazz->glyph_bbox( glyph, acbox ); - - /* perform grid fitting if needed */ - if ( bbox_mode == FT_GLYPH_BBOX_GRIDFIT || - bbox_mode == FT_GLYPH_BBOX_PIXELS ) - { - acbox->xMin = FT_PIX_FLOOR( acbox->xMin ); - acbox->yMin = FT_PIX_FLOOR( acbox->yMin ); - acbox->xMax = FT_PIX_CEIL( acbox->xMax ); - acbox->yMax = FT_PIX_CEIL( acbox->yMax ); - } - - /* convert to integer pixels if needed */ - if ( bbox_mode == FT_GLYPH_BBOX_TRUNCATE || - bbox_mode == FT_GLYPH_BBOX_PIXELS ) - { - acbox->xMin >>= 6; - acbox->yMin >>= 6; - acbox->xMax >>= 6; - acbox->yMax >>= 6; - } - } + acbox->xMin = FT_PIX_FLOOR( acbox->xMin ); + acbox->yMin = FT_PIX_FLOOR( acbox->yMin ); + acbox->xMax = FT_PIX_CEIL( acbox->xMax ); + acbox->yMax = FT_PIX_CEIL( acbox->yMax ); + } + + /* convert to integer pixels if needed */ + if ( bbox_mode == FT_GLYPH_BBOX_TRUNCATE || + bbox_mode == FT_GLYPH_BBOX_PIXELS ) + { + acbox->xMin >>= 6; + acbox->yMin >>= 6; + acbox->xMax >>= 6; + acbox->yMax >>= 6; } - return; } diff --git a/freetype/src/base/ftinit.c b/freetype/src/base/ftinit.c index 85f321fd2..6176273f0 100644 --- a/freetype/src/base/ftinit.c +++ b/freetype/src/base/ftinit.c @@ -23,8 +23,8 @@ /* FT_Add_Default_Modules(): */ /* This function is used to add the set of default modules to a */ /* fresh new library object. The set is taken from the header file */ - /* `freetype/config/ftmodule.h'. See the document `FreeType 2.0 */ - /* Build System' for more information. */ + /* `config/ftmodule.h'. See the document `FreeType 2.0 Build */ + /* System' for more information. */ /* */ /* FT_Init_FreeType(): */ /* This function creates a system object for the current platform, */ diff --git a/freetype/src/base/ftmac.c b/freetype/src/base/ftmac.c index 5b5aae61c..9b49da814 100644 --- a/freetype/src/base/ftmac.c +++ b/freetype/src/base/ftmac.c @@ -963,7 +963,6 @@ if ( !pathname ) return FT_THROW( Invalid_Argument ); - error = FT_Err_Ok; *aface = NULL; /* try resourcefork based font: LWFN, FFIL */ diff --git a/freetype/src/base/ftobjs.c b/freetype/src/base/ftobjs.c index 157bf4563..6f323362a 100644 --- a/freetype/src/base/ftobjs.c +++ b/freetype/src/base/ftobjs.c @@ -4,7 +4,7 @@ /* */ /* The FreeType private base classes (body). */ /* */ -/* Copyright 1996-2013 by */ +/* Copyright 1996-2014 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -56,9 +56,7 @@ #endif /* _MSC_VER */ /* it's easiest to include `md5.c' directly */ -#define free md5_free /* suppress a shadow warning */ #include "md5.c" -#undef free #if defined( _MSC_VER ) #pragma warning( pop ) @@ -667,11 +665,18 @@ /* the check for `num_locations' assures that we actually */ /* test for instructions in a TTF and not in a CFF-based OTF */ + /* */ + /* since `maxSizeOfInstructions' might be unreliable, we */ + /* check the size of the `fpgm' and `prep' tables, too -- */ + /* the assumption is that there don't exist real TTFs where */ + /* both `fpgm' and `prep' tables are missing */ if ( mode == FT_RENDER_MODE_LIGHT || face->internal->ignore_unpatented_hinter || ( FT_IS_SFNT( face ) && ttface->num_locations && - ttface->max_profile.maxSizeOfInstructions == 0 ) ) + ttface->max_profile.maxSizeOfInstructions == 0 && + ttface->font_program_size == 0 && + ttface->cvt_program_size == 0 ) ) autohint = TRUE; } } @@ -1133,7 +1138,8 @@ /* */ static FT_Error open_face( FT_Driver driver, - FT_Stream stream, + FT_Stream *astream, + FT_Bool external_stream, FT_Long face_index, FT_Int num_params, FT_Parameter* params, @@ -1141,10 +1147,11 @@ { FT_Memory memory; FT_Driver_Class clazz; - FT_Face face = 0; - FT_Error error, error2; + FT_Face face = NULL; FT_Face_Internal internal = NULL; + FT_Error error, error2; + clazz = driver->clazz; memory = driver->root.memory; @@ -1155,7 +1162,11 @@ face->driver = driver; face->memory = memory; - face->stream = stream; + face->stream = *astream; + + /* set the FT_FACE_FLAG_EXTERNAL_STREAM bit for FT_Done_Face */ + if ( external_stream ) + face->face_flags |= FT_FACE_FLAG_EXTERNAL_STREAM; if ( FT_NEW( internal ) ) goto Fail; @@ -1177,11 +1188,12 @@ #endif if ( clazz->init_face ) - error = clazz->init_face( stream, + error = clazz->init_face( *astream, face, (FT_Int)face_index, num_params, params ); + *astream = face->stream; /* Stream may have been changed. */ if ( error ) goto Fail; @@ -1789,9 +1801,10 @@ if ( error ) return error; + /* POST resources must be sorted to concatenate properly */ error = FT_Raccess_Get_DataOffsets( library, stream, map_offset, rdara_pos, - TTAG_POST, + TTAG_POST, TRUE, &data_offsets, &count ); if ( !error ) { @@ -1804,9 +1817,11 @@ return error; } + /* sfnt resources should not be sorted to preserve the face order by + QuickDraw API */ error = FT_Raccess_Get_DataOffsets( library, stream, map_offset, rdara_pos, - TTAG_sfnt, + TTAG_sfnt, FALSE, &data_offsets, &count ); if ( !error ) { @@ -2069,7 +2084,7 @@ params = args->params; } - error = open_face( driver, stream, face_index, + error = open_face( driver, &stream, external_stream, face_index, num_params, params, &face ); if ( !error ) goto Success; @@ -2105,7 +2120,7 @@ params = args->params; } - error = open_face( driver, stream, face_index, + error = open_face( driver, &stream, external_stream, face_index, num_params, params, &face ); if ( !error ) goto Success; @@ -2174,10 +2189,6 @@ Success: FT_TRACE4(( "FT_Open_Face: New face object, adding to list\n" )); - /* set the FT_FACE_FLAG_EXTERNAL_STREAM bit for FT_Done_Face */ - if ( external_stream ) - face->face_flags |= FT_FACE_FLAG_EXTERNAL_STREAM; - /* add the face object to its driver's list */ if ( FT_NEW( node ) ) goto Fail; @@ -3349,6 +3360,7 @@ FT_UInt gindex = 0; + /* only do something if we have a charmap, and we have glyphs at all */ if ( face && face->charmap && face->num_glyphs ) { gindex = FT_Get_Char_Index( face, 0 ); @@ -3380,8 +3392,10 @@ FT_CMap cmap = FT_CMAP( face->charmap ); - do { + do + { gindex = cmap->clazz->char_next( cmap, &code ); + } while ( gindex >= (FT_UInt)face->num_glyphs ); result = ( gindex == 0 ) ? 0 : code; @@ -3933,11 +3947,17 @@ static void ft_remove_renderer( FT_Module module ) { - FT_Library library = module->library; - FT_Memory memory = library->memory; + FT_Library library; + FT_Memory memory; FT_ListNode node; + library = module->library; + if ( !library ) + return; + + memory = library->memory; + node = FT_List_Find( &library->renderers, module ); if ( node ) { @@ -4453,7 +4473,7 @@ } - FT_Error + static FT_Error ft_property_do( FT_Library library, const FT_String* module_name, const FT_String* property_name, diff --git a/freetype/src/base/ftoutln.c b/freetype/src/base/ftoutln.c index 54ca5cdcf..4a39dcd7c 100644 --- a/freetype/src/base/ftoutln.c +++ b/freetype/src/base/ftoutln.c @@ -4,7 +4,7 @@ /* */ /* FreeType outline management (body). */ /* */ -/* Copyright 1996-2008, 2010, 2012-2013 by */ +/* Copyright 1996-2008, 2010, 2012-2014 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -128,7 +128,7 @@ v_start.x = ( v_start.x + v_last.x ) / 2; v_start.y = ( v_start.y + v_last.y ) / 2; - v_last = v_start; + /* v_last = v_start; */ } point--; tags--; @@ -576,11 +576,13 @@ { char* p = outline->tags + first; char* q = outline->tags + last; - char swap; while ( p < q ) { + char swap; + + swap = *p; *p = *q; *q = swap; @@ -721,7 +723,8 @@ #if 0 #define FT_OUTLINE_GET_CONTOUR( outline, c, first, last ) \ - do { \ + do \ + { \ (first) = ( c > 0 ) ? (outline)->points + \ (outline)->contours[c - 1] + 1 \ : (outline)->points; \ diff --git a/freetype/src/base/ftpic.c b/freetype/src/base/ftpic.c index b74e90dad..9bd92f785 100644 --- a/freetype/src/base/ftpic.c +++ b/freetype/src/base/ftpic.c @@ -4,7 +4,7 @@ /* */ /* The FreeType position independent code services (body). */ /* */ -/* Copyright 2009 by */ +/* Copyright 2009, 2013 by */ /* Oran Agra and Mickey Gabel. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -29,7 +29,8 @@ ft_pic_container_init( FT_Library library ) { FT_PIC_Container* pic_container = &library->pic_container; - FT_Error error = FT_Err_Ok; + FT_Error error; + FT_MEM_SET( pic_container, 0, sizeof ( *pic_container ) ); diff --git a/freetype/src/base/ftrfork.c b/freetype/src/base/ftrfork.c index 804911721..535297038 100644 --- a/freetype/src/base/ftrfork.c +++ b/freetype/src/base/ftrfork.c @@ -4,7 +4,7 @@ /* */ /* Embedded resource forks accessor (body). */ /* */ -/* Copyright 2004-2010, 2013 by */ +/* Copyright 2004-2010, 2013, 2014 by */ /* Masatake YAMATO and Redhat K.K. */ /* */ /* FT_Raccess_Get_HeaderInfo() and raccess_guess_darwin_hfsplus() are */ @@ -29,6 +29,7 @@ #include FT_INTERNAL_STREAM_H #include FT_INTERNAL_RFORK_H #include "basepic.h" +#include "ftbase.h" #undef FT_COMPONENT #define FT_COMPONENT trace_raccess @@ -151,6 +152,7 @@ FT_Long map_offset, FT_Long rdata_pos, FT_Long tag, + FT_Bool sort_by_res_id, FT_Long **offsets, FT_Long *count ) { @@ -163,6 +165,7 @@ FT_RFork_Ref *ref = NULL; + FT_TRACE3(( "\n" )); error = FT_Stream_Seek( stream, map_offset ); if ( error ) return error; @@ -183,6 +186,8 @@ (char)( 0xff & ( tag_internal >> 16 ) ), (char)( 0xff & ( tag_internal >> 8 ) ), (char)( 0xff & ( tag_internal >> 0 ) ) )); + FT_TRACE3(( " : subcount=%d, suboffset=0x%04x\n", + subcnt, rpos )); if ( tag_internal == tag ) { @@ -208,11 +213,24 @@ goto Exit; ref[j].offset = temp & 0xFFFFFFL; + FT_TRACE3(( " [%d]:" + " resource_id=0x%04x, offset=0x%08x\n", + j, ref[j].res_id, ref[j].offset )); } - ft_qsort( ref, *count, sizeof ( FT_RFork_Ref ), - ( int(*)(const void*, const void*) ) - ft_raccess_sort_ref_by_id ); + if (sort_by_res_id) + { + ft_qsort( ref, *count, sizeof ( FT_RFork_Ref ), + ( int(*)(const void*, const void*) ) + ft_raccess_sort_ref_by_id ); + + FT_TRACE3(( " -- sort resources by their ids --\n" )); + for ( j = 0; j < *count; ++ j ) { + FT_TRACE3(( " [%d]:" + " resource_id=0x%04x, offset=0x%08x\n", + j, ref[j].res_id, ref[j].offset )); + } + } if ( FT_NEW_ARRAY( offsets_internal, *count ) ) goto Exit; diff --git a/freetype/src/base/ftsynth.c b/freetype/src/base/ftsynth.c index 241d37f42..3098a60fa 100644 --- a/freetype/src/base/ftsynth.c +++ b/freetype/src/base/ftsynth.c @@ -4,7 +4,7 @@ /* */ /* FreeType synthesizing code for emboldening and slanting (body). */ /* */ -/* Copyright 2000-2006, 2010, 2012 by */ +/* Copyright 2000-2006, 2010, 2012, 2013 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -139,10 +139,11 @@ if ( slot->advance.y ) slot->advance.y += ystr; - slot->metrics.width += xstr; - slot->metrics.height += ystr; - slot->metrics.horiAdvance += xstr; - slot->metrics.vertAdvance += ystr; + slot->metrics.width += xstr; + slot->metrics.height += ystr; + slot->metrics.horiAdvance += xstr; + slot->metrics.vertAdvance += ystr; + slot->metrics.horiBearingY += ystr; /* XXX: 16-bit overflow case must be excluded before here */ if ( slot->format == FT_GLYPH_FORMAT_BITMAP ) diff --git a/freetype/src/base/md5.c b/freetype/src/base/md5.c index 2f01c9302..52d96accd 100644 --- a/freetype/src/base/md5.c +++ b/freetype/src/base/md5.c @@ -50,7 +50,8 @@ */ #define F(x, y, z) ((z) ^ ((x) & ((y) ^ (z)))) #define G(x, y, z) ((y) ^ ((z) & ((x) ^ (y)))) -#define H(x, y, z) ((x) ^ (y) ^ (z)) +#define H(x, y, z) (((x) ^ (y)) ^ (z)) +#define H2(x, y, z) ((x) ^ ((y) ^ (z))) #define I(x, y, z) ((y) ^ ((x) | ~(z))) /* @@ -89,13 +90,13 @@ * This processes one or more 64-byte data blocks, but does NOT update * the bit counters. There are no alignment requirements. */ -static void *body(MD5_CTX *ctx, void *data, unsigned long size) +static const void *body(MD5_CTX *ctx, const void *data, unsigned long size) { - unsigned char *ptr; + const unsigned char *ptr; MD5_u32plus a, b, c, d; MD5_u32plus saved_a, saved_b, saved_c, saved_d; - ptr = (unsigned char *)data; + ptr = (const unsigned char *)data; a = ctx->a; b = ctx->b; @@ -146,21 +147,21 @@ static void *body(MD5_CTX *ctx, void *data, unsigned long size) /* Round 3 */ STEP(H, a, b, c, d, GET(5), 0xfffa3942, 4) - STEP(H, d, a, b, c, GET(8), 0x8771f681, 11) + STEP(H2, d, a, b, c, GET(8), 0x8771f681, 11) STEP(H, c, d, a, b, GET(11), 0x6d9d6122, 16) - STEP(H, b, c, d, a, GET(14), 0xfde5380c, 23) + STEP(H2, b, c, d, a, GET(14), 0xfde5380c, 23) STEP(H, a, b, c, d, GET(1), 0xa4beea44, 4) - STEP(H, d, a, b, c, GET(4), 0x4bdecfa9, 11) + STEP(H2, d, a, b, c, GET(4), 0x4bdecfa9, 11) STEP(H, c, d, a, b, GET(7), 0xf6bb4b60, 16) - STEP(H, b, c, d, a, GET(10), 0xbebfbc70, 23) + STEP(H2, b, c, d, a, GET(10), 0xbebfbc70, 23) STEP(H, a, b, c, d, GET(13), 0x289b7ec6, 4) - STEP(H, d, a, b, c, GET(0), 0xeaa127fa, 11) + STEP(H2, d, a, b, c, GET(0), 0xeaa127fa, 11) STEP(H, c, d, a, b, GET(3), 0xd4ef3085, 16) - STEP(H, b, c, d, a, GET(6), 0x04881d05, 23) + STEP(H2, b, c, d, a, GET(6), 0x04881d05, 23) STEP(H, a, b, c, d, GET(9), 0xd9d4d039, 4) - STEP(H, d, a, b, c, GET(12), 0xe6db99e5, 11) + STEP(H2, d, a, b, c, GET(12), 0xe6db99e5, 11) STEP(H, c, d, a, b, GET(15), 0x1fa27cf8, 16) - STEP(H, b, c, d, a, GET(2), 0xc4ac5665, 23) + STEP(H2, b, c, d, a, GET(2), 0xc4ac5665, 23) /* Round 4 */ STEP(I, a, b, c, d, GET(0), 0xf4292244, 6) @@ -207,10 +208,10 @@ void MD5_Init(MD5_CTX *ctx) ctx->hi = 0; } -void MD5_Update(MD5_CTX *ctx, void *data, unsigned long size) +void MD5_Update(MD5_CTX *ctx, const void *data, unsigned long size) { MD5_u32plus saved_lo; - unsigned long used, free; + unsigned long used, available; saved_lo = ctx->lo; if ((ctx->lo = (saved_lo + size) & 0x1fffffff) < saved_lo) @@ -220,16 +221,16 @@ void MD5_Update(MD5_CTX *ctx, void *data, unsigned long size) used = saved_lo & 0x3f; if (used) { - free = 64 - used; + available = 64 - used; - if (size < free) { + if (size < available) { memcpy(&ctx->buffer[used], data, size); return; } - memcpy(&ctx->buffer[used], data, free); - data = (unsigned char *)data + free; - size -= free; + memcpy(&ctx->buffer[used], data, available); + data = (const unsigned char *)data + available; + size -= available; body(ctx, ctx->buffer, 64); } @@ -243,22 +244,22 @@ void MD5_Update(MD5_CTX *ctx, void *data, unsigned long size) void MD5_Final(unsigned char *result, MD5_CTX *ctx) { - unsigned long used, free; + unsigned long used, available; used = ctx->lo & 0x3f; ctx->buffer[used++] = 0x80; - free = 64 - used; + available = 64 - used; - if (free < 8) { - memset(&ctx->buffer[used], 0, free); + if (available < 8) { + memset(&ctx->buffer[used], 0, available); body(ctx, ctx->buffer, 64); used = 0; - free = 64; + available = 64; } - memset(&ctx->buffer[used], 0, free - 8); + memset(&ctx->buffer[used], 0, available - 8); ctx->lo <<= 3; ctx->buffer[56] = ctx->lo; diff --git a/freetype/src/base/md5.h b/freetype/src/base/md5.h index f1a685764..2da44bf35 100644 --- a/freetype/src/base/md5.h +++ b/freetype/src/base/md5.h @@ -39,7 +39,7 @@ typedef struct { } MD5_CTX; extern void MD5_Init(MD5_CTX *ctx); -extern void MD5_Update(MD5_CTX *ctx, void *data, unsigned long size); +extern void MD5_Update(MD5_CTX *ctx, const void *data, unsigned long size); extern void MD5_Final(unsigned char *result, MD5_CTX *ctx); #endif diff --git a/freetype/src/base/rules.mk b/freetype/src/base/rules.mk index e93219115..cbd810732 100644 --- a/freetype/src/base/rules.mk +++ b/freetype/src/base/rules.mk @@ -19,8 +19,8 @@ # BASE_OBJ_S: The single-object base layer. # BASE_OBJ_M: A list of all objects for a multiple-objects build. # BASE_EXT_OBJ: A list of base layer extensions, i.e., components found -# in `freetype/src/base' which are not compiled within the -# base layer proper. +# in `src/base' which are not compiled within the base +# layer proper. BASE_COMPILE := $(FT_COMPILE) $I$(subst /,$(COMPILER_SEP),$(SRC_DIR)/base) @@ -33,12 +33,14 @@ BASE_COMPILE := $(FT_COMPILE) $I$(subst /,$(COMPILER_SEP),$(SRC_DIR)/base) # All files listed here should be included in `ftbase.c' (for a `single' # build). # -BASE_SRC := $(BASE_DIR)/ftadvanc.c \ +BASE_SRC := $(BASE_DIR)/basepic.c \ + $(BASE_DIR)/ftadvanc.c \ $(BASE_DIR)/ftcalc.c \ $(BASE_DIR)/ftdbgmem.c \ $(BASE_DIR)/ftgloadr.c \ $(BASE_DIR)/ftobjs.c \ $(BASE_DIR)/ftoutln.c \ + $(BASE_DIR)/ftpic.c \ $(BASE_DIR)/ftrfork.c \ $(BASE_DIR)/ftsnames.c \ $(BASE_DIR)/ftstream.c \ @@ -51,8 +53,9 @@ ifneq ($(ftmac_c),) endif # for simplicity, we also handle `md5.c' (which gets included by `ftobjs.h') -BASE_H := $(BASE_DIR)/ftbase.h \ - $(BASE_DIR)/md5.c \ +BASE_H := $(BASE_DIR)/basepic.h \ + $(BASE_DIR)/ftbase.h \ + $(BASE_DIR)/md5.c \ $(BASE_DIR)/md5.h # Base layer `extensions' sources -- cgit v1.2.3