summaryrefslogtreecommitdiffstats
path: root/src/base
diff options
context:
space:
mode:
authorVictoria Lease <violets@google.com>2013-12-12 09:12:18 -0800
committerVictoria Lease <violets@google.com>2013-12-12 09:23:45 -0800
commitec0bab5697bb31ba980810145f62e3799946ec60 (patch)
treebaa7eea792c50b86250831c67a9f2a6eb5be6a91 /src/base
parent899c67b6cfcd2010784fbf08c5415af16c526e0c (diff)
downloadandroid_external_freetype-ec0bab5697bb31ba980810145f62e3799946ec60.tar.gz
android_external_freetype-ec0bab5697bb31ba980810145f62e3799946ec60.tar.bz2
android_external_freetype-ec0bab5697bb31ba980810145f62e3799946ec60.zip
Update freetype to 8bb09b0fe4d9747bcf452a777cabed7d7ef435e2
Integrated patches from freetype2 git repository, up to hashval 8bb09b0fe4d9747bcf452a777cabed7d7ef435e2, which is post-2.5.2. Most recent commit message from freetype git: [truetype] Simplify logic of rendering modes. Noteworthy patches included: [sfnt] Fix handling of embedded bitmap strikes. [truetype] Improve handling of buggy embedded bitmap strikes. Add FT_FACE_FLAG_COLOR and FT_HAS_COLOR. Change-Id: I4a22d96c9443c7a587475ca0a9c684843e144b18
Diffstat (limited to 'src/base')
-rw-r--r--src/base/ftbbox.c334
-rw-r--r--src/base/ftbitmap.c4
-rw-r--r--src/base/ftcalc.c30
-rw-r--r--src/base/ftdebug.c2
-rw-r--r--src/base/ftgloadr.c3
-rw-r--r--src/base/ftglyph.c62
-rw-r--r--src/base/ftinit.c4
-rw-r--r--src/base/ftobjs.c62
-rw-r--r--src/base/ftoutln.c7
-rw-r--r--src/base/ftpic.c4
-rw-r--r--src/base/ftsynth.c11
-rw-r--r--src/base/md5.c51
-rw-r--r--src/base/md5.h2
13 files changed, 230 insertions, 346 deletions
diff --git a/src/base/ftbbox.c b/src/base/ftbbox.c
index 6d1c44c..8d3f383 100644
--- a/src/base/ftbbox.c
+++ b/src/base/ftbbox.c
@@ -85,7 +85,7 @@
/* BBox_Conic_Check */
/* */
/* <Description> */
- /* 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 */
/* */
/* <Description> */
- /* 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. */
/* */
/* <Input> */
/* 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/src/base/ftbitmap.c b/src/base/ftbitmap.c
index 975818e..182b1cc 100644
--- a/src/base/ftbitmap.c
+++ b/src/base/ftbitmap.c
@@ -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/src/base/ftcalc.c b/src/base/ftcalc.c
index 0ec0d78..b23b4d4 100644
--- a/src/base/ftcalc.c
+++ b/src/base/ftcalc.c
@@ -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/src/base/ftdebug.c b/src/base/ftdebug.c
index b9156d1..39ac6ad 100644
--- a/src/base/ftdebug.c
+++ b/src/base/ftdebug.c
@@ -152,7 +152,7 @@
/* the memory and stream components which are set to 7 and 5, */
/* respectively. */
/* */
- /* See the file <include/freetype/internal/fttrace.h> for details of the */
+ /* See the file <include/internal/fttrace.h> for details of the */
/* available toggle names. */
/* */
/* The level must be between 0 and 7; 0 means quiet (except for serious */
diff --git a/src/base/ftgloadr.c b/src/base/ftgloadr.c
index 663db26..3cc5c7a 100644
--- a/src/base/ftgloadr.c
+++ b/src/base/ftgloadr.c
@@ -265,6 +265,9 @@
FT_GlyphLoader_Adjust_Points( loader );
Exit:
+ if ( error )
+ FT_GlyphLoader_Reset( loader );
+
return error;
}
diff --git a/src/base/ftglyph.c b/src/base/ftglyph.c
index 5dd28a8..c62b3db 100644
--- a/src/base/ftglyph.c
+++ b/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/src/base/ftinit.c b/src/base/ftinit.c
index 85f321f..6176273 100644
--- a/src/base/ftinit.c
+++ b/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/src/base/ftobjs.c b/src/base/ftobjs.c
index ac2a39c..bd0c66e 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -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;
@@ -1153,15 +1160,19 @@
if ( FT_ALLOC( face, clazz->face_object_size ) )
goto Fail;
+ face->driver = driver;
+ face->memory = memory;
+ 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;
face->internal = internal;
- face->driver = driver;
- face->memory = memory;
- face->stream = stream;
-
#ifdef FT_CONFIG_OPTION_INCREMENTAL
{
int i;
@@ -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;
@@ -2024,8 +2036,8 @@
FT_Face *aface )
{
FT_Error error;
- FT_Driver driver;
- FT_Memory memory;
+ FT_Driver driver = NULL;
+ FT_Memory memory = NULL;
FT_Stream stream = NULL;
FT_Face face = NULL;
FT_ListNode node = NULL;
@@ -2069,7 +2081,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 +2117,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 +2186,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;
@@ -2265,7 +2273,10 @@
goto Exit;
Fail:
- FT_Done_Face( face );
+ if ( node )
+ FT_Done_Face( face ); /* face must be in the driver's list */
+ else if ( face )
+ destroy_face( memory, face, driver );
Exit:
FT_TRACE4(( "FT_Open_Face: Return %d\n", error ));
@@ -3377,8 +3388,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;
@@ -4308,7 +4321,8 @@
FT_Renderer renderer = FT_RENDERER( module );
- if ( renderer->clazz->glyph_format == FT_GLYPH_FORMAT_OUTLINE &&
+ if ( renderer->clazz &&
+ renderer->clazz->glyph_format == FT_GLYPH_FORMAT_OUTLINE &&
renderer->raster )
renderer->clazz->raster_class->raster_done( renderer->raster );
}
@@ -4513,9 +4527,9 @@
service = (FT_Service_Properties)interface;
if ( set )
- missing_func = !service->set_property;
+ missing_func = (FT_Bool)( !service->set_property );
else
- missing_func = !service->get_property;
+ missing_func = (FT_Bool)( !service->get_property );
if ( missing_func )
{
diff --git a/src/base/ftoutln.c b/src/base/ftoutln.c
index 54ca5cd..35df0cd 100644
--- a/src/base/ftoutln.c
+++ b/src/base/ftoutln.c
@@ -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/src/base/ftpic.c b/src/base/ftpic.c
index 1c87101..9bd92f7 100644
--- a/src/base/ftpic.c
+++ b/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,7 @@
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/src/base/ftsynth.c b/src/base/ftsynth.c
index 241d37f..3098a60 100644
--- a/src/base/ftsynth.c
+++ b/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/src/base/md5.c b/src/base/md5.c
index 2f01c93..52d96ac 100644
--- a/src/base/md5.c
+++ b/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/src/base/md5.h b/src/base/md5.h
index f1a6857..2da44bf 100644
--- a/src/base/md5.h
+++ b/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