aboutsummaryrefslogtreecommitdiff
path: root/freetype/src/base
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2013-06-21 10:45:51 +0200
committermarha <marha@users.sourceforge.net>2013-06-21 10:48:19 +0200
commitfa791414601df61d20d860299dba80fdb62565df (patch)
treeeecc4c74bb78dece330009c571ed57d7f1aaede2 /freetype/src/base
parent7f9fb534564d0eb8a62cf444e569a07166e5ee03 (diff)
downloadvcxsrv-fa791414601df61d20d860299dba80fdb62565df.tar.gz
vcxsrv-fa791414601df61d20d860299dba80fdb62565df.tar.bz2
vcxsrv-fa791414601df61d20d860299dba80fdb62565df.zip
Upgraded freetype to 2.5.0.1
Diffstat (limited to 'freetype/src/base')
-rw-r--r--freetype/src/base/basepic.h45
-rw-r--r--freetype/src/base/ftadvanc.c20
-rw-r--r--freetype/src/base/ftbbox.c251
-rw-r--r--freetype/src/base/ftbdf.c6
-rw-r--r--freetype/src/base/ftbitmap.c113
-rw-r--r--freetype/src/base/ftcalc.c110
-rw-r--r--freetype/src/base/ftcid.c8
-rw-r--r--freetype/src/base/ftdbgmem.c105
-rw-r--r--freetype/src/base/ftdebug.c28
-rw-r--r--freetype/src/base/ftgloadr.c10
-rw-r--r--freetype/src/base/ftglyph.c24
-rw-r--r--freetype/src/base/ftgxval.c16
-rw-r--r--freetype/src/base/ftinit.c6
-rw-r--r--freetype/src/base/ftlcdfil.c14
-rw-r--r--freetype/src/base/ftmac.c74
-rw-r--r--freetype/src/base/ftmm.c20
-rw-r--r--freetype/src/base/ftobjs.c374
-rw-r--r--freetype/src/base/ftotval.c10
-rw-r--r--freetype/src/base/ftoutln.c97
-rw-r--r--freetype/src/base/ftpfr.c12
-rw-r--r--freetype/src/base/ftrfork.c40
-rw-r--r--freetype/src/base/ftsnames.c2
-rw-r--r--freetype/src/base/ftstream.c55
-rw-r--r--freetype/src/base/ftstroke.c14
-rw-r--r--freetype/src/base/ftsystem.c8
-rw-r--r--freetype/src/base/fttrigon.c227
-rw-r--r--freetype/src/base/fttype1.c4
-rw-r--r--freetype/src/base/ftutil.c79
-rw-r--r--freetype/src/base/ftwinfnt.c2
-rw-r--r--freetype/src/base/md5.c295
-rw-r--r--freetype/src/base/md5.h45
-rw-r--r--freetype/src/base/rules.mk7
32 files changed, 1277 insertions, 844 deletions
diff --git a/freetype/src/base/basepic.h b/freetype/src/base/basepic.h
index bf90bef0b..329d7c8fd 100644
--- a/freetype/src/base/basepic.h
+++ b/freetype/src/base/basepic.h
@@ -25,11 +25,13 @@ FT_BEGIN_HEADER
#include FT_INTERNAL_PIC_H
#ifndef FT_CONFIG_OPTION_PIC
-#define FT_OUTLINE_GLYPH_CLASS_GET &ft_outline_glyph_class
-#define FT_BITMAP_GLYPH_CLASS_GET &ft_bitmap_glyph_class
-#define FT_DEFAULT_MODULES_GET ft_default_modules
+
+#define FT_OUTLINE_GLYPH_CLASS_GET &ft_outline_glyph_class
+#define FT_BITMAP_GLYPH_CLASS_GET &ft_bitmap_glyph_class
+#define FT_DEFAULT_MODULES_GET ft_default_modules
+
#ifdef FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK
-#define FT_RACCESS_GUESS_TABLE_GET ft_raccess_guess_table
+#define FT_RACCESS_GUESS_TABLE_GET ft_raccess_guess_table
#endif
#else /* FT_CONFIG_OPTION_PIC */
@@ -41,25 +43,35 @@ FT_BEGIN_HEADER
#endif
- typedef struct BasePIC_
+ typedef struct BasePIC_
{
- FT_Module_Class** default_module_classes;
- FT_Glyph_Class ft_outline_glyph_class;
- FT_Glyph_Class ft_bitmap_glyph_class;
+ FT_Module_Class** default_module_classes;
+ FT_Glyph_Class ft_outline_glyph_class;
+ FT_Glyph_Class ft_bitmap_glyph_class;
+
#ifdef FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK
- ft_raccess_guess_rec ft_raccess_guess_table[FT_RACCESS_N_RULES];
+ ft_raccess_guess_rec ft_raccess_guess_table[FT_RACCESS_N_RULES];
#endif
+
} BasePIC;
-#define GET_PIC(lib) ((BasePIC*)((lib)->pic_container.base))
-#define FT_OUTLINE_GLYPH_CLASS_GET (&GET_PIC(library)->ft_outline_glyph_class)
-#define FT_BITMAP_GLYPH_CLASS_GET (&GET_PIC(library)->ft_bitmap_glyph_class)
-#define FT_DEFAULT_MODULES_GET (GET_PIC(library)->default_module_classes)
+
+#define GET_PIC( lib ) ( (BasePIC*)( (lib)->pic_container.base ) )
+
+#define FT_OUTLINE_GLYPH_CLASS_GET \
+ ( &GET_PIC( library )->ft_outline_glyph_class )
+#define FT_BITMAP_GLYPH_CLASS_GET \
+ ( &GET_PIC( library )->ft_bitmap_glyph_class )
+#define FT_DEFAULT_MODULES_GET \
+ ( GET_PIC( library )->default_module_classes )
+
#ifdef FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK
-#define FT_RACCESS_GUESS_TABLE_GET (GET_PIC(library)->ft_raccess_guess_table)
+#define FT_RACCESS_GUESS_TABLE_GET \
+ ( GET_PIC( library )->ft_raccess_guess_table )
#endif
- /* see basepic.c for the implementation. */
+
+ /* see basepic.c for the implementation */
void
ft_base_pic_free( FT_Library library );
@@ -67,7 +79,8 @@ FT_BEGIN_HEADER
ft_base_pic_init( FT_Library library );
#endif /* FT_CONFIG_OPTION_PIC */
- /* */
+
+ /* */
FT_END_HEADER
diff --git a/freetype/src/base/ftadvanc.c b/freetype/src/base/ftadvanc.c
index a8bb43d3d..52078478d 100644
--- a/freetype/src/base/ftadvanc.c
+++ b/freetype/src/base/ftadvanc.c
@@ -4,7 +4,7 @@
/* */
/* Quick computation of advance widths (body). */
/* */
-/* Copyright 2008, 2009, 2011 by */
+/* Copyright 2008, 2009, 2011, 2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -17,6 +17,8 @@
#include <ft2build.h>
+#include FT_INTERNAL_DEBUG_H
+
#include FT_ADVANCES_H
#include FT_INTERNAL_OBJECTS_H
@@ -35,7 +37,7 @@
return FT_Err_Ok;
if ( face->size == NULL )
- return FT_Err_Invalid_Size_Handle;
+ return FT_THROW( Invalid_Size_Handle );
if ( flags & FT_LOAD_VERTICAL_LAYOUT )
scale = face->size->metrics.y_scale;
@@ -76,10 +78,10 @@
if ( !face )
- return FT_Err_Invalid_Face_Handle;
+ return FT_THROW( Invalid_Face_Handle );
if ( gindex >= (FT_UInt)face->num_glyphs )
- return FT_Err_Invalid_Glyph_Index;
+ return FT_THROW( Invalid_Glyph_Index );
func = face->driver->clazz->get_advances;
if ( func && LOAD_ADVANCE_FAST_CHECK( flags ) )
@@ -91,7 +93,7 @@
if ( !error )
return _ft_face_scale_advances( face, padvance, 1, flags );
- if ( error != FT_ERROR_BASE( FT_Err_Unimplemented_Feature ) )
+ if ( FT_ERR_NEQ( error, Unimplemented_Feature ) )
return error;
}
@@ -114,12 +116,12 @@
if ( !face )
- return FT_Err_Invalid_Face_Handle;
+ return FT_THROW( Invalid_Face_Handle );
num = (FT_UInt)face->num_glyphs;
end = start + count;
if ( start >= num || end < start || end > num )
- return FT_Err_Invalid_Glyph_Index;
+ return FT_THROW( Invalid_Glyph_Index );
if ( count == 0 )
return FT_Err_Ok;
@@ -131,14 +133,14 @@
if ( !error )
return _ft_face_scale_advances( face, padvances, count, flags );
- if ( error != FT_ERROR_BASE( FT_Err_Unimplemented_Feature ) )
+ if ( FT_ERR_NEQ( error, Unimplemented_Feature ) )
return error;
}
error = FT_Err_Ok;
if ( flags & FT_ADVANCE_FLAG_FAST_ONLY )
- return FT_Err_Unimplemented_Feature;
+ return FT_THROW( Unimplemented_Feature );
flags |= (FT_UInt32)FT_LOAD_ADVANCE_ONLY;
for ( nn = 0; nn < count; nn++ )
diff --git a/freetype/src/base/ftbbox.c b/freetype/src/base/ftbbox.c
index 4b8e9112f..6d1c44cb2 100644
--- a/freetype/src/base/ftbbox.c
+++ b/freetype/src/base/ftbbox.c
@@ -4,7 +4,7 @@
/* */
/* FreeType bbox computation (body). */
/* */
-/* Copyright 1996-2001, 2002, 2004, 2006, 2010 by */
+/* Copyright 1996-2002, 2004, 2006, 2010, 2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used */
@@ -25,6 +25,8 @@
#include <ft2build.h>
+#include FT_INTERNAL_DEBUG_H
+
#include FT_BBOX_H
#include FT_IMAGE_H
#include FT_OUTLINE_H
@@ -222,65 +224,100 @@
FT_Pos* min,
FT_Pos* max )
{
- FT_Pos stack[32*3 + 1], *arc;
-
+ FT_Pos q1, q2, q3, q4;
- arc = stack;
- arc[0] = p1;
- arc[1] = p2;
- arc[2] = p3;
- arc[3] = p4;
+ q1 = p1;
+ q2 = p2;
+ q3 = p3;
+ q4 = p4;
- do
+ /* 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 )
{
- FT_Pos y1 = arc[0];
- FT_Pos y2 = arc[1];
- FT_Pos y3 = arc[2];
- FT_Pos y4 = arc[3];
-
-
- if ( y1 == y4 )
+ /* determine which half contains the maximum and split */
+ if ( q1 + q2 > q3 + q4 ) /* first half */
{
- if ( y1 == y2 && y1 == y3 ) /* flat */
- goto Test;
+ 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 if ( y1 < y4 )
+ else /* second half */
{
- if ( y2 >= y1 && y2 <= y4 && y3 >= y1 && y3 <= y4 ) /* ascending */
- goto Test;
+ 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;
}
- else
+
+ /* check if either end reached the maximum */
+ if ( q1 == q2 && q1 >= q3 )
{
- if ( y2 >= y4 && y2 <= y1 && y3 >= y4 && y3 <= y1 ) /* descending */
- {
- y2 = y1;
- y1 = y4;
- y4 = y2;
- goto Test;
- }
+ *max = q1;
+ break;
}
+ if ( q3 == q4 && q2 <= q4 )
+ {
+ *max = q4;
+ break;
+ }
+ }
- /* unknown direction -- split the arc in two */
- arc[6] = y4;
- arc[1] = y1 = ( y1 + y2 ) / 2;
- arc[5] = y4 = ( y4 + y3 ) / 2;
- y2 = ( y2 + y3 ) / 2;
- arc[2] = y1 = ( y1 + y2 ) / 2;
- arc[4] = y4 = ( y4 + y2 ) / 2;
- arc[3] = ( y1 + y4 ) / 2;
-
- arc += 3;
- goto Suite;
+ q1 = p1;
+ q2 = p2;
+ q3 = p3;
+ q4 = p4;
- Test:
- if ( y1 < *min ) *min = y1;
- if ( y4 > *max ) *max = y4;
- arc -= 3;
+ /* 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;
+ }
- Suite:
- ;
- } while ( arc >= stack );
+ /* check if either end reached the minimum */
+ if ( q1 == q2 && q1 <= q3 )
+ {
+ *min = q1;
+ break;
+ }
+ if ( q3 == q4 && q2 >= q4 )
+ {
+ *min = q4;
+ break;
+ }
+ }
}
#else
@@ -358,107 +395,57 @@
return;
}
- /* There are some split points. Find them. */
+ /* 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. */
+ /* 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 float values to ensure */
- /* that its product is held in a `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). */
- {
- FT_ULong t1, t2;
- int shift = 0;
-
-
- /* The following computation is based on the fact that for */
- /* any value `y', if `n' is the position of the most */
- /* significant bit of `abs(y)' (starting from 0 for the */
- /* least significant bit), then `y' is in the range */
- /* */
- /* -2^n..2^n-1 */
- /* */
- /* We want to shift `a', `b', and `c' concurrently in order */
- /* to ensure that they all fit in 8.16 values, which maps */
- /* to the integer range `-2^23..2^23-1'. */
- /* */
- /* Necessarily, we need to shift `a', `b', and `c' so that */
- /* the most significant bit of its absolute values is at */
- /* _most_ at position 23. */
- /* */
- /* We begin by computing `t1' as the bitwise `OR' of the */
- /* absolute values of `a', `b', `c'. */
-
- t1 = (FT_ULong)( ( a >= 0 ) ? a : -a );
- t2 = (FT_ULong)( ( b >= 0 ) ? b : -b );
- t1 |= t2;
- t2 = (FT_ULong)( ( c >= 0 ) ? c : -c );
- t1 |= t2;
-
- /* Now we can be sure that the most significant bit of `t1' */
- /* is the most significant bit of either `a', `b', or `c', */
- /* depending on the greatest integer range of the particular */
- /* variable. */
- /* */
- /* Next, we compute the `shift', by shifting `t1' as many */
- /* times as necessary to move its MSB to position 23. This */
- /* corresponds to a value of `t1' that is in the range */
- /* 0x40_0000..0x7F_FFFF. */
- /* */
- /* Finally, we shift `a', `b', and `c' by the same amount. */
- /* This ensures that all values are now in the range */
- /* -2^23..2^23, i.e., they are now expressed as 8.16 */
- /* fixed-float numbers. This also means that we are using */
- /* 24 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). */
-
- if ( t1 == 0 ) /* all coefficients are 0! */
- return;
+ shift = FT_MSB( FT_ABS( a ) | FT_ABS( b ) | FT_ABS( c ) );
- if ( t1 > 0x7FFFFFUL )
- {
- do
- {
- shift++;
- t1 >>= 1;
-
- } while ( t1 > 0x7FFFFFUL );
-
- /* this loses some bits of precision, but we use 24 of them */
- /* for the computation anyway */
- a >>= shift;
- b >>= shift;
- c >>= shift;
- }
- else if ( t1 < 0x400000UL )
- {
- do
- {
- shift++;
- t1 <<= 1;
+ if ( shift > 22 )
+ {
+ shift -= 22;
- } while ( t1 < 0x400000UL );
+ /* 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;
- }
+ a <<= shift;
+ b <<= shift;
+ c <<= shift;
}
/* handle a == 0 */
@@ -581,10 +568,10 @@ FT_DEFINE_OUTLINE_FUNCS(bbox_interface,
if ( !abbox )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
if ( !outline )
- return FT_Err_Invalid_Outline;
+ return FT_THROW( Invalid_Outline );
/* if outline is empty, return (0,0,0,0) */
if ( outline->n_points == 0 || outline->n_contours <= 0 )
diff --git a/freetype/src/base/ftbdf.c b/freetype/src/base/ftbdf.c
index d29adf09d..5755f8558 100644
--- a/freetype/src/base/ftbdf.c
+++ b/freetype/src/base/ftbdf.c
@@ -4,7 +4,7 @@
/* */
/* FreeType API for accessing BDF-specific strings (body). */
/* */
-/* Copyright 2002, 2003, 2004 by */
+/* Copyright 2002-2004, 2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -33,7 +33,7 @@
const char* registry = NULL;
- error = FT_Err_Invalid_Argument;
+ error = FT_ERR( Invalid_Argument );
if ( face )
{
@@ -66,7 +66,7 @@
FT_Error error;
- error = FT_Err_Invalid_Argument;
+ error = FT_ERR( Invalid_Argument );
aproperty->type = BDF_PROPERTY_TYPE_NONE;
diff --git a/freetype/src/base/ftbitmap.c b/freetype/src/base/ftbitmap.c
index 84fa32275..975818e14 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 by */
+/* Copyright 2004-2009, 2011, 2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -17,6 +17,8 @@
#include <ft2build.h>
+#include FT_INTERNAL_DEBUG_H
+
#include FT_BITMAP_H
#include FT_IMAGE_H
#include FT_INTERNAL_OBJECTS_H
@@ -135,7 +137,7 @@
new_pitch = ( width + xpixels );
break;
default:
- return FT_Err_Invalid_Glyph_Format;
+ return FT_THROW( Invalid_Glyph_Format );
}
/* if no need to allocate memory */
@@ -223,14 +225,14 @@
if ( !library )
- return FT_Err_Invalid_Library_Handle;
+ return FT_THROW( Invalid_Library_Handle );
if ( !bitmap || !bitmap->buffer )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
if ( ( ( FT_PIX_ROUND( xStrength ) >> 6 ) > FT_INT_MAX ) ||
( ( FT_PIX_ROUND( yStrength ) >> 6 ) > FT_INT_MAX ) )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
xstr = (FT_Int)FT_PIX_ROUND( xStrength ) >> 6;
ystr = (FT_Int)FT_PIX_ROUND( yStrength ) >> 6;
@@ -238,7 +240,7 @@
if ( xstr == 0 && ystr == 0 )
return FT_Err_Ok;
else if ( xstr < 0 || ystr < 0 )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
switch ( bitmap->pixel_mode )
{
@@ -277,6 +279,10 @@
case FT_PIXEL_MODE_LCD_V:
ystr *= 3;
break;
+
+ case FT_PIXEL_MODE_BGRA:
+ /* We don't embolden color glyphs. */
+ return FT_Err_Ok;
}
error = ft_bitmap_assure_buffer( library->memory, bitmap, xstr, ystr );
@@ -369,6 +375,59 @@
}
+ FT_Byte
+ ft_gray_for_premultiplied_srgb_bgra( const FT_Byte* bgra )
+ {
+ FT_Long a = bgra[3];
+ FT_Long b = bgra[0];
+ FT_Long g = bgra[1];
+ FT_Long r = bgra[2];
+ FT_Long l;
+
+
+ /*
+ * Luminosity for sRGB is defined using ~0.2126,0.7152,0.0722
+ * coefficients for RGB channels *on the linear colors*.
+ * A gamma of 2.2 is fair to assume. And then, we need to
+ * undo the premultiplication too.
+ *
+ * http://accessibility.kde.org/hsl-adjusted.php
+ *
+ * We do the computation with integers only.
+ */
+
+ /* Undo premultification, get the number in a 16.16 form. */
+ b = FT_MulDiv( b, 65536, a );
+ g = FT_MulDiv( g, 65536, a );
+ r = FT_MulDiv( r, 65536, a );
+ a = a * 256;
+
+ /* Apply gamma of 2.0 instead of 2.2. */
+ b = FT_MulFix( b, b );
+ g = FT_MulFix( g, g );
+ r = FT_MulFix( r, r );
+
+ /* Apply coefficients. */
+ b = FT_MulFix( b, 4731 /* 0.0722 * 65536 */ );
+ g = FT_MulFix( g, 46871 /* 0.7152 * 65536 */ );
+ r = FT_MulFix( r, 13933 /* 0.2126 * 65536 */ );
+
+ l = r + g + b;
+
+ /*
+ * Final transparency can be determined this way:
+ *
+ * - If alpha is zero, we want 0.
+ * - If alpha is zero and luminosity is zero, we want 255.
+ * - If alpha is zero and luminosity is one, we want 0.
+ *
+ * So the formula is a * (1 - l).
+ */
+
+ return (FT_Byte)( FT_MulFix( 65535 - l, a ) >> 8 );
+ }
+
+
/* documentation is in ftbitmap.h */
FT_EXPORT_DEF( FT_Error )
@@ -382,7 +441,7 @@
if ( !library )
- return FT_Err_Invalid_Library_Handle;
+ return FT_THROW( Invalid_Library_Handle );
memory = library->memory;
@@ -394,6 +453,7 @@
case FT_PIXEL_MODE_GRAY4:
case FT_PIXEL_MODE_LCD:
case FT_PIXEL_MODE_LCD_V:
+ case FT_PIXEL_MODE_BGRA:
{
FT_Int pad;
FT_Long old_size;
@@ -419,7 +479,7 @@
if ( target->pitch > 0 &&
(FT_ULong)target->rows > FT_ULONG_MAX / target->pitch )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
if ( target->rows * target->pitch > old_size &&
FT_QREALLOC( target->buffer,
@@ -429,7 +489,7 @@
break;
default:
- error = FT_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
}
switch ( source->pixel_mode )
@@ -606,6 +666,37 @@
}
break;
+ case FT_PIXEL_MODE_BGRA:
+ {
+ FT_Byte* s = source->buffer;
+ FT_Byte* t = target->buffer;
+ FT_Int s_pitch = source->pitch;
+ FT_Int t_pitch = target->pitch;
+ FT_Int i;
+
+
+ target->num_grays = 256;
+
+ for ( i = source->rows; i > 0; i-- )
+ {
+ FT_Byte* ss = s;
+ FT_Byte* tt = t;
+ FT_Int j;
+
+
+ for ( j = source->width; j > 0; j-- )
+ {
+ tt[0] = ft_gray_for_premultiplied_srgb_bgra( ss );
+
+ ss += 4;
+ tt += 1;
+ }
+
+ s += s_pitch;
+ t += t_pitch;
+ }
+ }
+ break;
default:
;
@@ -650,10 +741,10 @@
if ( !library )
- return FT_Err_Invalid_Library_Handle;
+ return FT_THROW( Invalid_Library_Handle );
if ( !bitmap )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
memory = library->memory;
diff --git a/freetype/src/base/ftcalc.c b/freetype/src/base/ftcalc.c
index 2aeea0459..0ec0d7893 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 by */
+/* Copyright 1996-2006, 2008, 2012-2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -34,6 +34,7 @@
#include <ft2build.h>
#include FT_GLYPH_H
+#include FT_TRIGONOMETRY_H
#include FT_INTERNAL_CALC_H
#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_OBJECTS_H
@@ -42,13 +43,9 @@
#undef FT_MulFix
#endif
-/* we need to define a 64-bits data type here */
+/* we need to emulate a 64-bit data type if a real one isn't available */
-#ifdef FT_LONG64
-
- typedef FT_INT64 FT_Int64;
-
-#else
+#ifndef FT_LONG64
typedef struct FT_Int64_
{
@@ -57,7 +54,7 @@
} FT_Int64;
-#endif /* FT_LONG64 */
+#endif /* !FT_LONG64 */
/*************************************************************************/
@@ -103,39 +100,57 @@
}
-#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
+ FT_BASE_DEF ( FT_Int )
+ FT_MSB( FT_UInt32 z )
+ {
+ FT_Int shift = 0;
- /* documentation is in ftcalc.h */
+ /* determine msb bit index in `shift' */
+ if ( z >= ( 1L << 16 ) )
+ {
+ z >>= 16;
+ shift += 16;
+ }
+ if ( z >= ( 1L << 8 ) )
+ {
+ z >>= 8;
+ shift += 8;
+ }
+ if ( z >= ( 1L << 4 ) )
+ {
+ z >>= 4;
+ shift += 4;
+ }
+ if ( z >= ( 1L << 2 ) )
+ {
+ z >>= 2;
+ shift += 2;
+ }
+ if ( z >= ( 1L << 1 ) )
+ {
+ z >>= 1;
+ shift += 1;
+ }
- FT_EXPORT_DEF( FT_Int32 )
- FT_Sqrt32( FT_Int32 x )
- {
- FT_UInt32 val, root, newroot, mask;
+ return shift;
+ }
- root = 0;
- mask = (FT_UInt32)0x40000000UL;
- val = (FT_UInt32)x;
+ /* documentation is in ftcalc.h */
- do
- {
- newroot = root + mask;
- if ( newroot <= val )
- {
- val -= newroot;
- root = newroot + mask;
- }
+ FT_BASE_DEF( FT_Fixed )
+ FT_Hypot( FT_Fixed x,
+ FT_Fixed y )
+ {
+ FT_Vector v;
- root >>= 1;
- mask >>= 2;
- } while ( mask != 0 );
+ v.x = x;
+ v.y = y;
- return root;
+ return FT_Vector_Length( &v );
}
-#endif /* FT_CONFIG_OPTION_OLD_INTERNALS */
-
#ifdef FT_LONG64
@@ -163,8 +178,6 @@
}
-#ifdef TT_USE_BYTECODE_INTERPRETER
-
/* documentation is in ftcalc.h */
FT_BASE_DEF( FT_Long )
@@ -187,8 +200,6 @@
return ( s > 0 ) ? d : -d;
}
-#endif /* TT_USE_BYTECODE_INTERPRETER */
-
/* documentation is in freetype.h */
@@ -235,16 +246,25 @@
FT_Int32 s;
FT_UInt32 q;
+
s = 1;
- if ( a < 0 ) { a = -a; s = -1; }
- if ( b < 0 ) { b = -b; s = -s; }
+ if ( a < 0 )
+ {
+ a = -a;
+ s = -1;
+ }
+ if ( b < 0 )
+ {
+ b = -b;
+ s = -s;
+ }
if ( b == 0 )
/* check for division by 0 */
q = 0x7FFFFFFFL;
else
/* compute result directly */
- q = (FT_UInt32)( ( ( (FT_Int64)a << 16 ) + ( b >> 1 ) ) / b );
+ q = (FT_UInt32)( ( ( (FT_UInt64)a << 16 ) + ( b >> 1 ) ) / b );
return ( s < 0 ? -(FT_Long)q : (FT_Long)q );
}
@@ -392,8 +412,6 @@
}
-#ifdef TT_USE_BYTECODE_INTERPRETER
-
FT_BASE_DEF( FT_Long )
FT_MulDiv_No_Round( FT_Long a,
FT_Long b,
@@ -426,8 +444,6 @@
return ( s < 0 ? -a : a );
}
-#endif /* TT_USE_BYTECODE_INTERPRETER */
-
/* documentation is in freetype.h */
@@ -552,7 +568,7 @@
else if ( ( a >> 16 ) == 0 )
{
/* compute result directly */
- q = (FT_UInt32)( ( a << 16 ) + ( b >> 1 ) ) / (FT_UInt32)b;
+ q = (FT_UInt32)( ( (FT_ULong)a << 16 ) + ( b >> 1 ) ) / (FT_UInt32)b;
}
else
{
@@ -560,8 +576,8 @@
FT_Int64 temp, temp2;
- temp.hi = (FT_Int32) ( a >> 16 );
- temp.lo = (FT_UInt32)( a << 16 );
+ temp.hi = (FT_Int32)( a >> 16 );
+ temp.lo = (FT_UInt32)a << 16;
temp2.hi = 0;
temp2.lo = (FT_UInt32)( b >> 1 );
FT_Add64( &temp, &temp2, &temp );
@@ -727,14 +743,14 @@
if ( !matrix )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
/* compute discriminant */
delta = FT_MulFix( matrix->xx, matrix->yy ) -
FT_MulFix( matrix->xy, matrix->yx );
if ( !delta )
- return FT_Err_Invalid_Argument; /* matrix can't be inverted */
+ return FT_THROW( Invalid_Argument ); /* matrix can't be inverted */
matrix->xy = - FT_DivFix( matrix->xy, delta );
matrix->yx = - FT_DivFix( matrix->yx, delta );
diff --git a/freetype/src/base/ftcid.c b/freetype/src/base/ftcid.c
index 733aae147..741879d92 100644
--- a/freetype/src/base/ftcid.c
+++ b/freetype/src/base/ftcid.c
@@ -4,7 +4,7 @@
/* */
/* FreeType API for accessing CID font information. */
/* */
-/* Copyright 2007, 2009 by Derek Clegg, Michael Toftdal. */
+/* Copyright 2007, 2009, 2013 by Derek Clegg, Michael Toftdal. */
/* */
/* This file is part of the FreeType project, and may only be used, */
/* modified, and distributed under the terms of the FreeType project */
@@ -35,7 +35,7 @@
FT_Int s = 0;
- error = FT_Err_Invalid_Argument;
+ error = FT_ERR( Invalid_Argument );
if ( face )
{
@@ -65,7 +65,7 @@
FT_Get_CID_Is_Internally_CID_Keyed( FT_Face face,
FT_Bool *is_cid )
{
- FT_Error error = FT_Err_Invalid_Argument;
+ FT_Error error = FT_ERR( Invalid_Argument );
FT_Bool ic = 0;
@@ -92,7 +92,7 @@
FT_UInt glyph_index,
FT_UInt *cid )
{
- FT_Error error = FT_Err_Invalid_Argument;
+ FT_Error error = FT_ERR( Invalid_Argument );
FT_UInt c = 0;
diff --git a/freetype/src/base/ftdbgmem.c b/freetype/src/base/ftdbgmem.c
index 12fed04bb..6fb86fe77 100644
--- a/freetype/src/base/ftdbgmem.c
+++ b/freetype/src/base/ftdbgmem.c
@@ -4,7 +4,7 @@
/* */
/* Memory debugger (body). */
/* */
-/* Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2009 by */
+/* Copyright 2001-2006, 2009, 2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -344,85 +344,80 @@
ft_mem_table_destroy( FT_MemTable table )
{
FT_ULong i;
+ FT_Long leak_count = 0;
+ FT_ULong leaks = 0;
FT_DumpMemory( table->memory );
- if ( table )
+ /* remove all blocks from the table, revealing leaked ones */
+ for ( i = 0; i < table->size; i++ )
{
- FT_Long leak_count = 0;
- FT_ULong leaks = 0;
+ FT_MemNode *pnode = table->buckets + i, next, node = *pnode;
- /* remove all blocks from the table, revealing leaked ones */
- for ( i = 0; i < table->size; i++ )
+ while ( node )
{
- FT_MemNode *pnode = table->buckets + i, next, node = *pnode;
+ next = node->link;
+ node->link = 0;
-
- while ( node )
+ if ( node->size > 0 )
{
- next = node->link;
- node->link = 0;
-
- if ( node->size > 0 )
- {
- printf(
- "leaked memory block at address %p, size %8ld in (%s:%ld)\n",
- node->address, node->size,
- FT_FILENAME( node->source->file_name ),
- node->source->line_no );
+ printf(
+ "leaked memory block at address %p, size %8ld in (%s:%ld)\n",
+ node->address, node->size,
+ FT_FILENAME( node->source->file_name ),
+ node->source->line_no );
- leak_count++;
- leaks += node->size;
+ leak_count++;
+ leaks += node->size;
- ft_mem_table_free( table, node->address );
- }
+ ft_mem_table_free( table, node->address );
+ }
- node->address = NULL;
- node->size = 0;
+ node->address = NULL;
+ node->size = 0;
- ft_mem_table_free( table, node );
- node = next;
- }
- table->buckets[i] = 0;
+ ft_mem_table_free( table, node );
+ node = next;
}
+ table->buckets[i] = 0;
+ }
- ft_mem_table_free( table, table->buckets );
- table->buckets = NULL;
-
- table->size = 0;
- table->nodes = 0;
+ ft_mem_table_free( table, table->buckets );
+ table->buckets = NULL;
- /* remove all sources */
- for ( i = 0; i < FT_MEM_SOURCE_BUCKETS; i++ )
- {
- FT_MemSource source, next;
+ table->size = 0;
+ table->nodes = 0;
+ /* remove all sources */
+ for ( i = 0; i < FT_MEM_SOURCE_BUCKETS; i++ )
+ {
+ FT_MemSource source, next;
- for ( source = table->sources[i]; source != NULL; source = next )
- {
- next = source->link;
- ft_mem_table_free( table, source );
- }
- table->sources[i] = NULL;
+ for ( source = table->sources[i]; source != NULL; source = next )
+ {
+ next = source->link;
+ ft_mem_table_free( table, source );
}
- printf(
- "FreeType: total memory allocations = %ld\n", table->alloc_total );
- printf(
- "FreeType: maximum memory footprint = %ld\n", table->alloc_max );
+ table->sources[i] = NULL;
+ }
- ft_mem_table_free( table, table );
+ printf( "FreeType: total memory allocations = %ld\n",
+ table->alloc_total );
+ printf( "FreeType: maximum memory footprint = %ld\n",
+ table->alloc_max );
- if ( leak_count > 0 )
- ft_mem_debug_panic(
- "FreeType: %ld bytes of memory leaked in %ld blocks\n",
- leaks, leak_count );
+ ft_mem_table_free( table, table );
- printf( "FreeType: no memory leaks detected\n" );
- }
+ if ( leak_count > 0 )
+ ft_mem_debug_panic(
+ "FreeType: %ld bytes of memory leaked in %ld blocks\n",
+ leaks, leak_count );
+
+ printf( "FreeType: no memory leaks detected\n" );
}
diff --git a/freetype/src/base/ftdebug.c b/freetype/src/base/ftdebug.c
index 2adbeabeb..b9156d15e 100644
--- a/freetype/src/base/ftdebug.c
+++ b/freetype/src/base/ftdebug.c
@@ -4,7 +4,7 @@
/* */
/* Debugging and logging component (body). */
/* */
-/* Copyright 1996-2001, 2002, 2004, 2008 by */
+/* Copyright 1996-2001, 2002, 2004, 2008, 2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -51,7 +51,8 @@
/* documentation is in ftdebug.h */
FT_BASE_DEF( void )
- FT_Message( const char* fmt, ... )
+ FT_Message( const char* fmt,
+ ... )
{
va_list ap;
@@ -65,7 +66,8 @@
/* documentation is in ftdebug.h */
FT_BASE_DEF( void )
- FT_Panic( const char* fmt, ... )
+ FT_Panic( const char* fmt,
+ ... )
{
va_list ap;
@@ -77,6 +79,21 @@
exit( EXIT_FAILURE );
}
+
+ /* documentation is in ftdebug.h */
+
+ FT_BASE_DEF( int )
+ FT_Throw( FT_Error error,
+ int line,
+ const char* file )
+ {
+ FT_UNUSED( error );
+ FT_UNUSED( line );
+ FT_UNUSED( file );
+
+ return 0;
+ }
+
#endif /* FT_DEBUG_LEVEL_ERROR */
@@ -164,6 +181,9 @@
while ( *p && *p != ':' )
p++;
+ if ( !*p )
+ break;
+
if ( *p == ':' && p > q )
{
FT_Int n, i, len = (FT_Int)( p - q );
@@ -192,7 +212,7 @@
p++;
if ( *p )
{
- level = *p++ - '0';
+ level = *p - '0';
if ( level < 0 || level > 7 )
level = -1;
}
diff --git a/freetype/src/base/ftgloadr.c b/freetype/src/base/ftgloadr.c
index 3a5615e5e..3cc5c7a80 100644
--- a/freetype/src/base/ftgloadr.c
+++ b/freetype/src/base/ftgloadr.c
@@ -4,7 +4,7 @@
/* */
/* The FreeType glyph loader (body). */
/* */
-/* Copyright 2002, 2003, 2004, 2005, 2006, 2010 by */
+/* Copyright 2002-2006, 2010, 2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -17,6 +17,7 @@
#include <ft2build.h>
+#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_GLYPH_LOADER_H
#include FT_INTERNAL_MEMORY_H
#include FT_INTERNAL_OBJECTS_H
@@ -219,7 +220,7 @@
new_max = FT_PAD_CEIL( new_max, 8 );
if ( new_max > FT_OUTLINE_POINTS_MAX )
- return FT_Err_Array_Too_Large;
+ return FT_THROW( Array_Too_Large );
if ( FT_RENEW_ARRAY( base->points, old_max, new_max ) ||
FT_RENEW_ARRAY( base->tags, old_max, new_max ) )
@@ -251,7 +252,7 @@
new_max = FT_PAD_CEIL( new_max, 4 );
if ( new_max > FT_OUTLINE_CONTOURS_MAX )
- return FT_Err_Array_Too_Large;
+ return FT_THROW( Array_Too_Large );
if ( FT_RENEW_ARRAY( base->contours, old_max, new_max ) )
goto Exit;
@@ -264,6 +265,9 @@
FT_GlyphLoader_Adjust_Points( loader );
Exit:
+ if ( error )
+ FT_GlyphLoader_Reset( loader );
+
return error;
}
diff --git a/freetype/src/base/ftglyph.c b/freetype/src/base/ftglyph.c
index 7363c7dce..5dd28a8c5 100644
--- a/freetype/src/base/ftglyph.c
+++ b/freetype/src/base/ftglyph.c
@@ -4,7 +4,7 @@
/* */
/* FreeType convenience functions to handle glyphs (body). */
/* */
-/* Copyright 1996-2005, 2007, 2008, 2010, 2012 by */
+/* Copyright 1996-2005, 2007, 2008, 2010, 2012, 2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -29,6 +29,8 @@
#include <ft2build.h>
+#include FT_INTERNAL_DEBUG_H
+
#include FT_GLYPH_H
#include FT_OUTLINE_H
#include FT_BITMAP_H
@@ -65,7 +67,7 @@
if ( slot->format != FT_GLYPH_FORMAT_BITMAP )
{
- error = FT_Err_Invalid_Glyph_Format;
+ error = FT_THROW( Invalid_Glyph_Format );
goto Exit;
}
@@ -166,7 +168,7 @@
/* check format in glyph slot */
if ( slot->format != FT_GLYPH_FORMAT_OUTLINE )
{
- error = FT_Err_Invalid_Glyph_Format;
+ error = FT_THROW( Invalid_Glyph_Format );
goto Exit;
}
@@ -314,7 +316,7 @@
/* check arguments */
if ( !target )
{
- error = FT_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
goto Exit;
}
@@ -322,7 +324,7 @@
if ( !source || !source->clazz )
{
- error = FT_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
goto Exit;
}
@@ -361,12 +363,12 @@
if ( !slot )
- return FT_Err_Invalid_Slot_Handle;
+ return FT_THROW( Invalid_Slot_Handle );
library = slot->library;
if ( !aglyph )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
/* if it is a bitmap, that's easy :-) */
if ( slot->format == FT_GLYPH_FORMAT_BITMAP )
@@ -388,7 +390,7 @@
if ( !clazz )
{
- error = FT_Err_Invalid_Glyph_Format;
+ error = FT_THROW( Invalid_Glyph_Format );
goto Exit;
}
@@ -427,7 +429,7 @@
if ( !glyph || !glyph->clazz )
- error = FT_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
else
{
clazz = glyph->clazz;
@@ -441,7 +443,7 @@
FT_Vector_Transform( &glyph->advance, matrix );
}
else
- error = FT_Err_Invalid_Glyph_Format;
+ error = FT_THROW( Invalid_Glyph_Format );
}
return error;
}
@@ -600,7 +602,7 @@
return error;
Bad:
- error = FT_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
goto Exit;
}
diff --git a/freetype/src/base/ftgxval.c b/freetype/src/base/ftgxval.c
index aeeb8ce4f..a8ec44ac0 100644
--- a/freetype/src/base/ftgxval.c
+++ b/freetype/src/base/ftgxval.c
@@ -4,7 +4,7 @@
/* */
/* FreeType API for validating TrueTyepGX/AAT tables (body). */
/* */
-/* Copyright 2004, 2005, 2006, 2010 by */
+/* Copyright 2004-2006, 2010, 2013 by */
/* Masatake YAMATO, Redhat K.K, */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
@@ -26,6 +26,8 @@
#include <ft2build.h>
+#include FT_INTERNAL_DEBUG_H
+
#include FT_INTERNAL_OBJECTS_H
#include FT_SERVICE_GX_VALIDATE_H
@@ -44,13 +46,13 @@
if ( !face )
{
- error = FT_Err_Invalid_Face_Handle;
+ error = FT_THROW( Invalid_Face_Handle );
goto Exit;
}
if ( tables == NULL )
{
- error = FT_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
goto Exit;
}
@@ -62,7 +64,7 @@
tables,
table_length );
else
- error = FT_Err_Unimplemented_Feature;
+ error = FT_THROW( Unimplemented_Feature );
Exit:
return error;
@@ -96,13 +98,13 @@
if ( !face )
{
- error = FT_Err_Invalid_Face_Handle;
+ error = FT_THROW( Invalid_Face_Handle );
goto Exit;
}
if ( ckern_table == NULL )
{
- error = FT_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
goto Exit;
}
@@ -113,7 +115,7 @@
validation_flags,
ckern_table );
else
- error = FT_Err_Unimplemented_Feature;
+ error = FT_THROW( Unimplemented_Feature );
Exit:
return error;
diff --git a/freetype/src/base/ftinit.c b/freetype/src/base/ftinit.c
index 0d8b568be..85f321fd2 100644
--- a/freetype/src/base/ftinit.c
+++ b/freetype/src/base/ftinit.c
@@ -4,7 +4,7 @@
/* */
/* FreeType initialization layer (body). */
/* */
-/* Copyright 1996-2002, 2005, 2007, 2009, 2012 by */
+/* Copyright 1996-2002, 2005, 2007, 2009, 2012, 2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -166,7 +166,7 @@
pic_container->default_module_classes = 0;
- if ( FT_ALLOC( classes, sizeof ( FT_Module_Class* ) *
+ if ( FT_ALLOC( classes, sizeof ( FT_Module_Class* ) *
( FT_NUM_MODULE_CLASSES + 1 ) ) )
return error;
@@ -242,7 +242,7 @@
if ( !memory )
{
FT_ERROR(( "FT_Init_FreeType: cannot find memory manager\n" ));
- return FT_Err_Unimplemented_Feature;
+ return FT_THROW( Unimplemented_Feature );
}
/* build a library out of it, then fill it with the set of */
diff --git a/freetype/src/base/ftlcdfil.c b/freetype/src/base/ftlcdfil.c
index 0da4ba160..852fb3298 100644
--- a/freetype/src/base/ftlcdfil.c
+++ b/freetype/src/base/ftlcdfil.c
@@ -4,7 +4,7 @@
/* */
/* FreeType API for color filtering of subpixel bitmap glyphs (body). */
/* */
-/* Copyright 2006, 2008, 2009, 2010 by */
+/* Copyright 2006, 2008-2010, 2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -17,6 +17,8 @@
#include <ft2build.h>
+#include FT_INTERNAL_DEBUG_H
+
#include FT_LCD_FILTER_H
#include FT_IMAGE_H
#include FT_INTERNAL_OBJECTS_H
@@ -271,7 +273,7 @@
unsigned char *weights )
{
if ( !library || !weights )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
ft_memcpy( library->lcd_weights, weights, 5 );
@@ -292,7 +294,7 @@
if ( !library )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
switch ( filter )
{
@@ -339,7 +341,7 @@
#endif
default:
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
}
library->lcd_filter = filter;
@@ -356,7 +358,7 @@
FT_UNUSED( library );
FT_UNUSED( weights );
- return FT_Err_Unimplemented_Feature;
+ return FT_THROW( Unimplemented_Feature );
}
@@ -367,7 +369,7 @@
FT_UNUSED( library );
FT_UNUSED( filter );
- return FT_Err_Unimplemented_Feature;
+ return FT_THROW( Unimplemented_Feature );
}
#endif /* !FT_CONFIG_OPTION_SUBPIXEL_RENDERING */
diff --git a/freetype/src/base/ftmac.c b/freetype/src/base/ftmac.c
index f2007485d..5b5aae61c 100644
--- a/freetype/src/base/ftmac.c
+++ b/freetype/src/base/ftmac.c
@@ -8,8 +8,7 @@
/* This file is for Mac OS X only; see builds/mac/ftoldmac.c for */
/* classic platforms built by MPW. */
/* */
-/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, */
-/* 2009 by */
+/* Copyright 1996-2009, 2013 by */
/* Just van Rossum, David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -131,7 +130,7 @@
FT_UNUSED( pathSpec );
FT_UNUSED( face_index );
- return FT_Err_Unimplemented_Feature;
+ return FT_THROW( Unimplemented_Feature );
}
@@ -190,10 +189,10 @@
CFRelease( cf_fontName );
if ( ats_font_id == 0 || ats_font_id == 0xFFFFFFFFUL )
- return FT_Err_Unknown_File_Format;
+ return FT_THROW( Unknown_File_Format );
if ( noErr != FT_ATSFontGetFileReference( ats_font_id, ats_font_ref ) )
- return FT_Err_Unknown_File_Format;
+ return FT_THROW( Unknown_File_Format );
/* face_index calculation by searching preceding fontIDs */
/* with same FSRef */
@@ -229,11 +228,11 @@
err = FT_GetFileRef_From_Mac_ATS_Name( fontName, &ref, face_index );
- if ( FT_Err_Ok != err )
+ if ( err )
return err;
if ( noErr != FSRefMakePath( &ref, path, maxPathSize ) )
- return FT_Err_Unknown_File_Format;
+ return FT_THROW( Unknown_File_Format );
return FT_Err_Ok;
}
@@ -251,19 +250,19 @@
FT_UNUSED( pathSpec );
FT_UNUSED( face_index );
- return FT_Err_Unimplemented_Feature;
+ return FT_THROW( Unimplemented_Feature );
#else
FSRef ref;
FT_Error err;
err = FT_GetFileRef_From_Mac_ATS_Name( fontName, &ref, face_index );
- if ( FT_Err_Ok != err )
+ if ( err )
return err;
if ( noErr != FSGetCatalogInfo( &ref, kFSCatInfoNone, NULL, NULL,
pathSpec, NULL ) )
- return FT_Err_Unknown_File_Format;
+ return FT_THROW( Unknown_File_Format );
return FT_Err_Ok;
#endif
@@ -279,7 +278,7 @@
if ( noErr != FSPathMakeRef( pathname, &ref, FALSE ) )
- return FT_Err_Cannot_Open_Resource;
+ return FT_THROW( Cannot_Open_Resource );
/* at present, no support for dfont format */
err = FSOpenResourceFile( &ref, 0, NULL, fsRdPerm, res );
@@ -359,11 +358,9 @@
count_faces_scalable( char* fond_data )
{
AsscEntry* assoc;
- FamRec* fond;
short i, face, face_all;
- fond = (FamRec*)fond_data;
face_all = EndianS16_BtoN( *( (short *)( fond_data +
sizeof ( FamRec ) ) ) ) + 1;
assoc = (AsscEntry*)( fond_data + sizeof ( FamRec ) + 2 );
@@ -508,17 +505,17 @@
/* We should not extract parent directory by string manipulation. */
if ( noErr != FSPathMakeRef( path_fond, &ref, FALSE ) )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
if ( noErr != FSGetCatalogInfo( &ref, kFSCatInfoNone,
NULL, NULL, NULL, &par_ref ) )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
if ( noErr != FSRefMakePath( &par_ref, path_lwfn, path_size ) )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
if ( ft_strlen( (char *)path_lwfn ) + 1 + base_lwfn[0] > path_size )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
/* now we have absolute dirname in path_lwfn */
ft_strcat( (char *)path_lwfn, "/" );
@@ -527,11 +524,11 @@
path_lwfn[dirname_len + base_lwfn[0]] = '\0';
if ( noErr != FSPathMakeRef( path_lwfn, &ref, FALSE ) )
- return FT_Err_Cannot_Open_Resource;
+ return FT_THROW( Cannot_Open_Resource );
if ( noErr != FSGetCatalogInfo( &ref, kFSCatInfoNone,
NULL, NULL, NULL, NULL ) )
- return FT_Err_Cannot_Open_Resource;
+ return FT_THROW( Cannot_Open_Resource );
return FT_Err_Ok;
}
@@ -557,7 +554,7 @@
{
err = lookup_lwfn_by_fond( pathname, lwfn_file_name,
buff, sizeof ( buff ) );
- if ( FT_Err_Ok == err )
+ if ( !err )
have_lwfn = 1;
}
@@ -620,7 +617,7 @@
/* detect integer overflows */
if ( total_size < old_total_size )
{
- error = FT_Err_Array_Too_Large;
+ error = FT_THROW( Array_Too_Large );
goto Error;
}
@@ -705,7 +702,7 @@
if ( noErr != FT_FSPathMakeRes( pathname, &res ) )
- return FT_Err_Cannot_Open_Resource;
+ return FT_THROW( Cannot_Open_Resource );
pfb_data = NULL;
pfb_size = 0;
@@ -740,7 +737,7 @@
sfnt = GetResource( TTAG_sfnt, sfnt_id );
if ( sfnt == NULL )
- return FT_Err_Invalid_Handle;
+ return FT_THROW( Invalid_Handle );
sfnt_size = (FT_ULong)GetHandleSize( sfnt );
if ( FT_ALLOC( sfnt_data, (FT_Long)sfnt_size ) )
@@ -797,23 +794,26 @@
FT_Long face_index,
FT_Face* aface )
{
- FT_Error error = FT_Err_Cannot_Open_Resource;
+ FT_Error error = FT_ERR( Cannot_Open_Resource );
ResFileRefNum res_ref;
ResourceIndex res_index;
Handle fond;
- short num_faces_in_res, num_faces_in_fond;
+ short num_faces_in_res;
if ( noErr != FT_FSPathMakeRes( pathname, &res_ref ) )
- return FT_Err_Cannot_Open_Resource;
+ return FT_THROW( Cannot_Open_Resource );
UseResFile( res_ref );
if ( ResError() )
- return FT_Err_Cannot_Open_Resource;
+ return FT_THROW( Cannot_Open_Resource );
num_faces_in_res = 0;
for ( res_index = 1; ; ++res_index )
{
+ short num_faces_in_fond;
+
+
fond = Get1IndResource( TTAG_FOND, res_index );
if ( ResError() )
break;
@@ -828,7 +828,7 @@
}
CloseResFile( res_ref );
- if ( FT_Err_Ok == error && NULL != aface && NULL != *aface )
+ if ( !error && aface && *aface )
(*aface)->num_faces = num_faces_in_res;
return error;
}
@@ -854,7 +854,7 @@
GetResInfo( fond, &fond_id, &fond_type, fond_name );
if ( ResError() != noErr || fond_type != TTAG_FOND )
- return FT_Err_Invalid_File_Format;
+ return FT_THROW( Invalid_File_Format );
parse_fond( *fond, &have_sfnt, &sfnt_id, lwfn_file_name, face_index );
@@ -883,7 +883,7 @@
error = lookup_lwfn_by_fond( path_fond, lwfn_file_name,
path_lwfn, sizeof ( path_lwfn ) );
- if ( FT_Err_Ok == error )
+ if ( !error )
have_lwfn = 1;
}
}
@@ -894,10 +894,10 @@
face_index,
aface );
else
- error = FT_Err_Unknown_File_Format;
+ error = FT_THROW( Unknown_File_Format );
found_no_lwfn_file:
- if ( have_sfnt && FT_Err_Ok != error )
+ if ( have_sfnt && error )
error = FT_New_Face_From_SFNT( library,
sfnt_id,
face_index,
@@ -961,7 +961,7 @@
/* test for valid `library' and `aface' delayed to FT_Open_Face() */
if ( !pathname )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
error = FT_Err_Ok;
*aface = NULL;
@@ -1003,11 +1003,11 @@
if ( !ref )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
err = FSRefMakePath( ref, pathname, sizeof ( pathname ) );
if ( err )
- error = FT_Err_Cannot_Open_Resource;
+ error = FT_THROW( Cannot_Open_Resource );
error = FT_New_Face_From_Resource( library, pathname, face_index, aface );
if ( error != 0 || *aface != NULL )
@@ -1043,13 +1043,13 @@
FT_UNUSED( face_index );
FT_UNUSED( aface );
- return FT_Err_Unimplemented_Feature;
+ return FT_THROW( Unimplemented_Feature );
#else
FSRef ref;
if ( !spec || FSpMakeFSRef( spec, &ref ) != noErr )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
else
return FT_New_Face_From_FSRef( library, &ref, face_index, aface );
#endif
diff --git a/freetype/src/base/ftmm.c b/freetype/src/base/ftmm.c
index 030772981..18ff879bf 100644
--- a/freetype/src/base/ftmm.c
+++ b/freetype/src/base/ftmm.c
@@ -4,7 +4,7 @@
/* */
/* Multiple Master font support (body). */
/* */
-/* Copyright 1996-2001, 2003, 2004, 2009 by */
+/* Copyright 1996-2001, 2003, 2004, 2009, 2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -17,6 +17,8 @@
#include <ft2build.h>
+#include FT_INTERNAL_DEBUG_H
+
#include FT_MULTIPLE_MASTERS_H
#include FT_INTERNAL_OBJECTS_H
#include FT_SERVICE_MULTIPLE_MASTERS_H
@@ -42,9 +44,9 @@
*aservice = NULL;
if ( !face )
- return FT_Err_Invalid_Face_Handle;
+ return FT_THROW( Invalid_Face_Handle );
- error = FT_Err_Invalid_Argument;
+ error = FT_ERR( Invalid_Argument );
if ( FT_HAS_MULTIPLE_MASTERS( face ) )
{
@@ -73,7 +75,7 @@
error = ft_face_get_mm_service( face, &service );
if ( !error )
{
- error = FT_Err_Invalid_Argument;
+ error = FT_ERR( Invalid_Argument );
if ( service->get_mm )
error = service->get_mm( face, amaster );
}
@@ -95,7 +97,7 @@
error = ft_face_get_mm_service( face, &service );
if ( !error )
{
- error = FT_Err_Invalid_Argument;
+ error = FT_ERR( Invalid_Argument );
if ( service->get_mm_var )
error = service->get_mm_var( face, amaster );
}
@@ -118,7 +120,7 @@
error = ft_face_get_mm_service( face, &service );
if ( !error )
{
- error = FT_Err_Invalid_Argument;
+ error = FT_ERR( Invalid_Argument );
if ( service->set_mm_design )
error = service->set_mm_design( face, num_coords, coords );
}
@@ -141,7 +143,7 @@
error = ft_face_get_mm_service( face, &service );
if ( !error )
{
- error = FT_Err_Invalid_Argument;
+ error = FT_ERR( Invalid_Argument );
if ( service->set_var_design )
error = service->set_var_design( face, num_coords, coords );
}
@@ -164,7 +166,7 @@
error = ft_face_get_mm_service( face, &service );
if ( !error )
{
- error = FT_Err_Invalid_Argument;
+ error = FT_ERR( Invalid_Argument );
if ( service->set_mm_blend )
error = service->set_mm_blend( face, num_coords, coords );
}
@@ -190,7 +192,7 @@
error = ft_face_get_mm_service( face, &service );
if ( !error )
{
- error = FT_Err_Invalid_Argument;
+ error = FT_ERR( Invalid_Argument );
if ( service->set_mm_blend )
error = service->set_mm_blend( face, num_coords, coords );
}
diff --git a/freetype/src/base/ftobjs.c b/freetype/src/base/ftobjs.c
index 76ccf0a44..157bf4563 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-2012 by */
+/* Copyright 1996-2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -41,6 +41,32 @@
#include "ftbase.h"
#endif
+
+#ifdef FT_DEBUG_LEVEL_TRACE
+
+#include FT_BITMAP_H
+
+#if defined( _MSC_VER ) /* Visual C++ (and Intel C++) */
+ /* We disable the warning `conversion from XXX to YYY, */
+ /* possible loss of data' in order to compile cleanly with */
+ /* the maximum level of warnings: `md5.c' is non-FreeType */
+ /* code, and it gets used during development builds only. */
+#pragma warning( push )
+#pragma warning( disable : 4244 )
+#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 )
+#endif
+
+#endif /* FT_DEBUG_LEVEL_TRACE */
+
+
#define GRID_FIT_METRICS
@@ -137,10 +163,10 @@
*astream = 0;
if ( !library )
- return FT_Err_Invalid_Library_Handle;
+ return FT_THROW( Invalid_Library_Handle );
if ( !args )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
memory = library->memory;
@@ -178,7 +204,7 @@
#endif
else
- error = FT_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
if ( error )
FT_FREE( stream );
@@ -385,7 +411,7 @@
if ( !face || !face->driver )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
driver = face->driver;
clazz = driver->clazz;
@@ -575,7 +601,7 @@
if ( !face || !face->size || !face->glyph )
- return FT_Err_Invalid_Face_Handle;
+ return FT_THROW( Invalid_Face_Handle );
/* The validity test for `glyph_index' is performed by the */
/* font drivers. */
@@ -815,7 +841,7 @@
if ( !face )
- return FT_Err_Invalid_Face_Handle;
+ return FT_THROW( Invalid_Face_Handle );
glyph_index = (FT_UInt)char_code;
if ( face->charmap )
@@ -966,7 +992,7 @@
first = face->charmaps;
if ( !first )
- return FT_Err_Invalid_CharMap_Handle;
+ return FT_THROW( Invalid_CharMap_Handle );
/*
* The original TrueType specification(s) only specified charmap
@@ -1044,7 +1070,7 @@
}
}
- return FT_Err_Invalid_CharMap_Handle;
+ return FT_THROW( Invalid_CharMap_Handle );
}
@@ -1127,15 +1153,15 @@
if ( FT_ALLOC( face, clazz->face_object_size ) )
goto Fail;
+ face->driver = driver;
+ face->memory = memory;
+ face->stream = 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;
@@ -1166,7 +1192,7 @@
/* is returned. */
/* no error should happen, but we want to play safe */
- if ( error2 && error2 != FT_Err_Invalid_CharMap_Handle )
+ if ( error2 && FT_ERR_NEQ( error2, Invalid_CharMap_Handle ) )
{
error = error2;
goto Fail;
@@ -1207,7 +1233,7 @@
/* test for valid `library' and `aface' delayed to FT_Open_Face() */
if ( !pathname )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
args.flags = FT_OPEN_PATHNAME;
args.pathname = (char*)pathname;
@@ -1233,7 +1259,7 @@
/* test for valid `library' and `face' delayed to FT_Open_Face() */
if ( !file_base )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
args.flags = FT_OPEN_MEMORY;
args.memory_base = file_base;
@@ -1305,10 +1331,10 @@
if ( !library )
- return FT_Err_Invalid_Library_Handle;
+ return FT_THROW( Invalid_Library_Handle );
if ( !base )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
*astream = 0;
memory = library->memory;
@@ -1422,7 +1448,7 @@
if ( FT_READ_ULONG( tag ) )
return error;
if ( tag != TTAG_typ1 )
- return FT_Err_Unknown_File_Format;
+ return FT_THROW( Unknown_File_Format );
if ( FT_READ_USHORT( numTables ) )
return error;
@@ -1459,7 +1485,7 @@
if ( face_index >= 0 && pstable_index == face_index )
return FT_Err_Ok;
}
- return FT_Err_Table_Missing;
+ return FT_THROW( Table_Missing );
}
@@ -1505,7 +1531,7 @@
error = open_face_from_buffer( library,
sfnt_ps,
length,
- face_index < 0 ? face_index : 0,
+ FT_MIN( face_index, 0 ),
is_sfnt_cid ? "cid" : "type1",
aface );
Exit:
@@ -1513,7 +1539,7 @@
FT_Error error1;
- if ( error == FT_Err_Unknown_File_Format )
+ if ( FT_ERR_EQ( error, Unknown_File_Format ) )
{
error1 = FT_Stream_Seek( stream, pos );
if ( error1 )
@@ -1541,7 +1567,7 @@
FT_Long face_index,
FT_Face *aface )
{
- FT_Error error = FT_Err_Cannot_Open_Resource;
+ FT_Error error = FT_ERR( Cannot_Open_Resource );
FT_Memory memory = library->memory;
FT_Byte* pfb_data = NULL;
int i, type, flags;
@@ -1634,7 +1660,7 @@
pfb_data[pfb_pos++] = 0;
}
- error = FT_Err_Cannot_Open_Resource;
+ error = FT_ERR( Cannot_Open_Resource );
if ( pfb_pos > pfb_len || pfb_pos + rlen > pfb_len )
goto Exit2;
@@ -1696,7 +1722,7 @@
if ( face_index == -1 )
face_index = 0;
if ( face_index >= resource_cnt )
- return FT_Err_Cannot_Open_Resource;
+ return FT_THROW( Cannot_Open_Resource );
flag_offset = offsets[face_index];
error = FT_Stream_Seek( stream, flag_offset );
@@ -1706,7 +1732,7 @@
if ( FT_READ_LONG( rlen ) )
goto Exit;
if ( rlen == -1 )
- return FT_Err_Cannot_Open_Resource;
+ return FT_THROW( Cannot_Open_Resource );
error = open_face_PS_from_sfnt_stream( library,
stream,
@@ -1813,7 +1839,7 @@
if ( NULL == stream )
- return FT_Err_Invalid_Stream_Operation;
+ return FT_THROW( Invalid_Stream_Operation );
error = FT_Stream_Seek( stream, 0 );
if ( error )
@@ -1830,7 +1856,7 @@
header[ 1] > 33 ||
header[63] != 0 ||
header[2 + header[1]] != 0 )
- return FT_Err_Unknown_File_Format;
+ return FT_THROW( Unknown_File_Format );
dlen = ( header[0x53] << 24 ) |
( header[0x54] << 16 ) |
@@ -1863,7 +1889,7 @@
#define FT_COMPONENT trace_raccess
FT_Memory memory = library->memory;
- FT_Error error = FT_Err_Unknown_File_Format;
+ FT_Error error = FT_ERR( Unknown_File_Format );
int i;
char * file_names[FT_RACCESS_N_RULES];
@@ -1902,7 +1928,7 @@
i, args2.pathname, offsets[i] ));
error = FT_Stream_New( library, &args2, &stream2 );
- if ( is_darwin_vfs && error == FT_Err_Cannot_Open_Stream )
+ if ( is_darwin_vfs && FT_ERR_EQ( error, Cannot_Open_Stream ) )
vfs_rfork_has_no_font = TRUE;
if ( error )
@@ -1931,7 +1957,7 @@
/* Caller (load_mac_face) requires FT_Err_Unknown_File_Format. */
if ( error )
- error = FT_Err_Unknown_File_Format;
+ error = FT_ERR( Unknown_File_Format );
return error;
@@ -1960,7 +1986,7 @@
error = IsMacBinary( library, stream, face_index, aface );
- if ( FT_ERROR_BASE( error ) == FT_Err_Unknown_File_Format )
+ if ( FT_ERR_EQ( error, Unknown_File_Format ) )
{
#undef FT_COMPONENT
@@ -1977,9 +2003,9 @@
}
- if ( ( FT_ERROR_BASE( error ) == FT_Err_Unknown_File_Format ||
- FT_ERROR_BASE( error ) == FT_Err_Invalid_Stream_Operation ) &&
- ( args->flags & FT_OPEN_PATHNAME ) )
+ if ( ( FT_ERR_EQ( error, Unknown_File_Format ) ||
+ FT_ERR_EQ( error, Invalid_Stream_Operation ) ) &&
+ ( args->flags & FT_OPEN_PATHNAME ) )
error = load_face_in_embedded_rfork( library, stream,
face_index, aface, args );
return error;
@@ -1998,8 +2024,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;
@@ -2012,7 +2038,7 @@
/* FT_Stream_New() */
if ( ( !aface && face_index >= 0 ) || !args )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
external_stream = FT_BOOL( ( args->flags & FT_OPEN_STREAM ) &&
args->stream );
@@ -2049,14 +2075,14 @@
goto Success;
}
else
- error = FT_Err_Invalid_Handle;
+ error = FT_THROW( Invalid_Handle );
FT_Stream_Free( stream, external_stream );
goto Fail;
}
else
{
- error = FT_Err_Missing_Module;
+ error = FT_ERR( Missing_Module );
/* check each font driver for an appropriate format */
cur = library->modules;
@@ -2086,7 +2112,7 @@
#ifdef FT_CONFIG_OPTION_MAC_FONTS
if ( ft_strcmp( cur[0]->clazz->module_name, "truetype" ) == 0 &&
- FT_ERROR_BASE( error ) == FT_Err_Table_Missing )
+ FT_ERR_EQ( error, Table_Missing ) )
{
/* TrueType but essential tables are missing */
if ( FT_Stream_Seek( stream, 0 ) )
@@ -2106,7 +2132,7 @@
}
#endif
- if ( FT_ERROR_BASE( error ) != FT_Err_Unknown_File_Format )
+ if ( FT_ERR_NEQ( error, Unknown_File_Format ) )
goto Fail3;
}
}
@@ -2115,9 +2141,9 @@
/* If we are on the mac, and we get an */
/* FT_Err_Invalid_Stream_Operation it may be because we have an */
/* empty data fork, so we need to check the resource fork. */
- if ( FT_ERROR_BASE( error ) != FT_Err_Cannot_Open_Stream &&
- FT_ERROR_BASE( error ) != FT_Err_Unknown_File_Format &&
- FT_ERROR_BASE( error ) != FT_Err_Invalid_Stream_Operation )
+ if ( FT_ERR_NEQ( error, Cannot_Open_Stream ) &&
+ FT_ERR_NEQ( error, Unknown_File_Format ) &&
+ FT_ERR_NEQ( error, Invalid_Stream_Operation ) )
goto Fail2;
#if !defined( FT_MACINTOSH ) && defined( FT_CONFIG_OPTION_MAC_FONTS )
@@ -2133,12 +2159,12 @@
return error;
}
- if ( FT_ERROR_BASE( error ) != FT_Err_Unknown_File_Format )
+ if ( FT_ERR_NEQ( error, Unknown_File_Format ) )
goto Fail2;
#endif /* !FT_MACINTOSH && FT_CONFIG_OPTION_MAC_FONTS */
/* no driver is able to handle this format */
- error = FT_Err_Unknown_File_Format;
+ error = FT_THROW( Unknown_File_Format );
Fail2:
FT_Stream_Free( stream, external_stream );
@@ -2239,7 +2265,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 ));
@@ -2260,7 +2289,7 @@
/* test for valid `face' delayed to FT_Attach_Stream() */
if ( !filepathname )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
open.stream = NULL;
open.flags = FT_OPEN_PATHNAME;
@@ -2286,11 +2315,11 @@
/* test for valid `parameters' delayed to FT_Stream_New() */
if ( !face )
- return FT_Err_Invalid_Face_Handle;
+ return FT_THROW( Invalid_Face_Handle );
driver = face->driver;
if ( !driver )
- return FT_Err_Invalid_Driver_Handle;
+ return FT_THROW( Invalid_Driver_Handle );
error = FT_Stream_New( driver->root.library, parameters, &stream );
if ( error )
@@ -2299,7 +2328,7 @@
/* we implement FT_Attach_Stream in each driver through the */
/* `attach_file' interface */
- error = FT_Err_Unimplemented_Feature;
+ error = FT_ERR( Unimplemented_Feature );
clazz = driver->clazz;
if ( clazz->attach_file )
error = clazz->attach_file( face, stream );
@@ -2336,7 +2365,7 @@
FT_ListNode node;
- error = FT_Err_Invalid_Face_Handle;
+ error = FT_ERR( Invalid_Face_Handle );
if ( face && face->driver )
{
face->internal->refcount--;
@@ -2382,13 +2411,13 @@
if ( !face )
- return FT_Err_Invalid_Face_Handle;
+ return FT_THROW( Invalid_Face_Handle );
if ( !asize )
- return FT_Err_Invalid_Size_Handle;
+ return FT_THROW( Invalid_Size_Handle );
if ( !face->driver )
- return FT_Err_Invalid_Driver_Handle;
+ return FT_THROW( Invalid_Driver_Handle );
*asize = 0;
@@ -2440,15 +2469,15 @@
if ( !size )
- return FT_Err_Invalid_Size_Handle;
+ return FT_THROW( Invalid_Size_Handle );
face = size->face;
if ( !face )
- return FT_Err_Invalid_Face_Handle;
+ return FT_THROW( Invalid_Face_Handle );
driver = face->driver;
if ( !driver )
- return FT_Err_Invalid_Driver_Handle;
+ return FT_THROW( Invalid_Driver_Handle );
memory = driver->root.memory;
@@ -2469,7 +2498,7 @@
destroy_size( memory, size, driver );
}
else
- error = FT_Err_Invalid_Size_Handle;
+ error = FT_THROW( Invalid_Size_Handle );
return error;
}
@@ -2488,11 +2517,11 @@
if ( !FT_HAS_FIXED_SIZES( face ) )
- return FT_Err_Invalid_Face_Handle;
+ return FT_THROW( Invalid_Face_Handle );
/* FT_Bitmap_Size doesn't provide enough info... */
if ( req->type != FT_SIZE_REQUEST_TYPE_NOMINAL )
- return FT_Err_Unimplemented_Feature;
+ return FT_THROW( Unimplemented_Feature );
w = FT_REQUEST_WIDTH ( req );
h = FT_REQUEST_HEIGHT( req );
@@ -2515,6 +2544,8 @@
if ( w == FT_PIX_ROUND( bsize->x_ppem ) || ignore_width )
{
+ FT_TRACE3(( "FT_Match_Size: bitmap strike %d matches\n", i ));
+
if ( size_index )
*size_index = (FT_ULong)i;
@@ -2522,7 +2553,7 @@
}
}
- return FT_Err_Invalid_Pixel_Size;
+ return FT_THROW( Invalid_Pixel_Size );
}
@@ -2765,10 +2796,10 @@
if ( !face || !FT_HAS_FIXED_SIZES( face ) )
- return FT_Err_Invalid_Face_Handle;
+ return FT_THROW( Invalid_Face_Handle );
if ( strike_index < 0 || strike_index >= face->num_fixed_sizes )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
clazz = face->driver->clazz;
@@ -2818,11 +2849,11 @@
if ( !face )
- return FT_Err_Invalid_Face_Handle;
+ return FT_THROW( Invalid_Face_Handle );
if ( !req || req->width < 0 || req->height < 0 ||
req->type >= FT_SIZE_REQUEST_TYPE_MAX )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
clazz = face->driver->clazz;
@@ -2871,9 +2902,6 @@
if ( error )
return error;
- FT_TRACE3(( "FT_Request_Size: bitmap strike %lu matched\n",
- strike_index ));
-
return FT_Select_Size( face, (FT_Int)strike_index );
}
@@ -2973,10 +3001,10 @@
if ( !face )
- return FT_Err_Invalid_Face_Handle;
+ return FT_THROW( Invalid_Face_Handle );
if ( !akerning )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
driver = face->driver;
@@ -3032,14 +3060,14 @@
if ( !face )
- return FT_Err_Invalid_Face_Handle;
+ return FT_THROW( Invalid_Face_Handle );
if ( !akerning )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
FT_FACE_FIND_SERVICE( face, service, KERNING );
if ( !service )
- return FT_Err_Unimplemented_Feature;
+ return FT_THROW( Unimplemented_Feature );
error = service->get_track( face,
point_size,
@@ -3061,10 +3089,10 @@
if ( !face )
- return FT_Err_Invalid_Face_Handle;
+ return FT_THROW( Invalid_Face_Handle );
if ( encoding == FT_ENCODING_NONE )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
/* FT_ENCODING_UNICODE is special. We try to find the `best' Unicode */
/* charmap available, i.e., one with UCS-4 characters, if possible. */
@@ -3075,7 +3103,7 @@
cur = face->charmaps;
if ( !cur )
- return FT_Err_Invalid_CharMap_Handle;
+ return FT_THROW( Invalid_CharMap_Handle );
limit = cur + face->num_charmaps;
@@ -3097,7 +3125,7 @@
}
}
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
}
@@ -3112,13 +3140,13 @@
if ( !face )
- return FT_Err_Invalid_Face_Handle;
+ return FT_THROW( Invalid_Face_Handle );
cur = face->charmaps;
if ( !cur )
- return FT_Err_Invalid_CharMap_Handle;
+ return FT_THROW( Invalid_CharMap_Handle );
if ( FT_Get_CMap_Format( charmap ) == 14 )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
limit = cur + face->num_charmaps;
@@ -3139,7 +3167,7 @@
return 0;
}
}
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
}
@@ -3178,7 +3206,7 @@
{
FT_CMap_Class clazz = cmap->clazz;
FT_Face face = cmap->charmap.face;
- FT_Memory memory = FT_FACE_MEMORY(face);
+ FT_Memory memory = FT_FACE_MEMORY( face );
if ( clazz->done )
@@ -3247,7 +3275,7 @@
if ( clazz == NULL || charmap == NULL || charmap->face == NULL )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
face = charmap->face;
memory = FT_FACE_MEMORY( face );
@@ -3580,7 +3608,7 @@
FT_Pointer buffer,
FT_UInt buffer_max )
{
- FT_Error error = FT_Err_Invalid_Argument;
+ FT_Error error = FT_ERR( Invalid_Argument );
/* clean up buffer */
@@ -3669,11 +3697,11 @@
if ( !face || !FT_IS_SFNT( face ) )
- return FT_Err_Invalid_Face_Handle;
+ return FT_THROW( Invalid_Face_Handle );
FT_FACE_FIND_SERVICE( face, service, SFNT_TABLE );
if ( service == NULL )
- return FT_Err_Unimplemented_Feature;
+ return FT_THROW( Unimplemented_Feature );
return service->load_table( face, tag, offset, buffer, length );
}
@@ -3692,11 +3720,11 @@
if ( !face || !FT_IS_SFNT( face ) )
- return FT_Err_Invalid_Face_Handle;
+ return FT_THROW( Invalid_Face_Handle );
FT_FACE_FIND_SERVICE( face, service, SFNT_TABLE );
if ( service == NULL )
- return FT_Err_Unimplemented_Feature;
+ return FT_THROW( Unimplemented_Feature );
return service->table_info( face, table_index, tag, &offset, length );
}
@@ -3759,11 +3787,11 @@
if ( size == NULL )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
face = size->face;
if ( face == NULL || face->driver == NULL )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
/* we don't need anything more complex than that; all size objects */
/* are already listed by the face */
@@ -3955,15 +3983,15 @@
if ( !library )
- return FT_Err_Invalid_Library_Handle;
+ return FT_THROW( Invalid_Library_Handle );
if ( !renderer )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
node = FT_List_Find( &library->renderers, renderer );
if ( !node )
{
- error = FT_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
goto Exit;
}
@@ -4021,12 +4049,12 @@
else
renderer = FT_Lookup_Renderer( library, slot->format, &node );
- error = FT_Err_Unimplemented_Feature;
+ error = FT_ERR( Unimplemented_Feature );
while ( renderer )
{
error = renderer->render( renderer, slot, render_mode, NULL );
- if ( !error ||
- FT_ERROR_BASE( error ) != FT_Err_Cannot_Render_Glyph )
+ if ( !error ||
+ FT_ERR_NEQ( error, Cannot_Render_Glyph ) )
break;
/* FT_Err_Cannot_Render_Glyph is returned if the render mode */
@@ -4046,6 +4074,47 @@
}
}
+#ifdef FT_DEBUG_LEVEL_TRACE
+
+#undef FT_COMPONENT
+#define FT_COMPONENT trace_bitmap
+
+ /* we convert to a single bitmap format for computing the checksum */
+ {
+ FT_Bitmap bitmap;
+ FT_Error err;
+
+
+ FT_Bitmap_New( &bitmap );
+
+ err = FT_Bitmap_Convert( library, &slot->bitmap, &bitmap, 1 );
+ if ( !err )
+ {
+ MD5_CTX ctx;
+ unsigned char md5[16];
+ int i;
+
+
+ MD5_Init( &ctx);
+ MD5_Update( &ctx, bitmap.buffer, bitmap.rows * bitmap.pitch );
+ MD5_Final( md5, &ctx );
+
+ FT_TRACE3(( "MD5 checksum for %dx%d bitmap:\n"
+ " ",
+ bitmap.rows, bitmap.pitch ));
+ for ( i = 0; i < 16; i++ )
+ FT_TRACE3(( "%02X", md5[i] ));
+ FT_TRACE3(( "\n" ));
+ }
+
+ FT_Bitmap_Done( library, &bitmap );
+ }
+
+#undef FT_COMPONENT
+#define FT_COMPONENT trace_objs
+
+#endif /* FT_DEBUG_LEVEL_TRACE */
+
return error;
}
@@ -4060,7 +4129,7 @@
if ( !slot || !slot->face )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
library = FT_FACE_LIBRARY( slot->face );
@@ -4140,14 +4209,14 @@
FREETYPE_MINOR )
if ( !library )
- return FT_Err_Invalid_Library_Handle;
+ return FT_THROW( Invalid_Library_Handle );
if ( !clazz )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
/* check freetype version */
if ( clazz->module_requires > FREETYPE_VER_FIXED )
- return FT_Err_Invalid_Version;
+ return FT_THROW( Invalid_Version );
/* look for a module with the same name in the library's table */
for ( nn = 0; nn < library->num_modules; nn++ )
@@ -4157,7 +4226,7 @@
{
/* this installed module has the same name, compare their versions */
if ( clazz->module_version <= module->clazz->module_version )
- return FT_Err_Lower_Module_Version;
+ return FT_THROW( Lower_Module_Version );
/* remove the module from our list, then exit the loop to replace */
/* it by our new version.. */
@@ -4171,7 +4240,7 @@
if ( library->num_modules >= FT_MAX_MODULES )
{
- error = FT_Err_Too_Many_Drivers;
+ error = FT_THROW( Too_Many_Drivers );
goto Exit;
}
@@ -4242,7 +4311,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 );
}
@@ -4350,7 +4420,7 @@
/* try to find the module from the table, then remove it from there */
if ( !library )
- return FT_Err_Invalid_Library_Handle;
+ return FT_THROW( Invalid_Library_Handle );
if ( module )
{
@@ -4379,7 +4449,7 @@
}
}
}
- return FT_Err_Invalid_Driver_Handle;
+ return FT_THROW( Invalid_Driver_Handle );
}
@@ -4406,10 +4476,10 @@
if ( !library )
- return FT_Err_Invalid_Library_Handle;
+ return FT_THROW( Invalid_Library_Handle );
if ( !module_name || !property_name || !value )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
cur = library->modules;
limit = cur + library->num_modules;
@@ -4423,7 +4493,7 @@
{
FT_ERROR(( "%s: can't find module `%s'\n",
func_name, module_name ));
- return FT_Err_Missing_Module;
+ return FT_THROW( Missing_Module );
}
/* check whether we have a service interface */
@@ -4431,7 +4501,7 @@
{
FT_ERROR(( "%s: module `%s' doesn't support properties\n",
func_name, module_name ));
- return FT_Err_Unimplemented_Feature;
+ return FT_THROW( Unimplemented_Feature );
}
/* search property service */
@@ -4441,21 +4511,21 @@
{
FT_ERROR(( "%s: module `%s' doesn't support properties\n",
func_name, module_name ));
- return FT_Err_Unimplemented_Feature;
+ return FT_THROW( Unimplemented_Feature );
}
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 )
{
FT_ERROR(( "%s: property service of module `%s' is broken\n",
func_name, module_name ));
- return FT_Err_Unimplemented_Feature;
+ return FT_THROW( Unimplemented_Feature );
}
return set ? service->set_property( cur[0], property_name, value )
@@ -4465,7 +4535,7 @@
/* documentation is in ftmodapi.h */
- FT_Error
+ FT_EXPORT_DEF( FT_Error )
FT_Property_Set( FT_Library library,
const FT_String* module_name,
const FT_String* property_name,
@@ -4481,7 +4551,7 @@
/* documentation is in ftmodapi.h */
- FT_Error
+ FT_EXPORT_DEF( FT_Error )
FT_Property_Get( FT_Library library,
const FT_String* module_name,
const FT_String* property_name,
@@ -4530,7 +4600,7 @@
if ( !memory )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
#ifdef FT_DEBUG_LEVEL_ERROR
/* init debugging support */
@@ -4617,7 +4687,7 @@
if ( !library )
- return FT_Err_Invalid_Library_Handle;
+ return FT_THROW( Invalid_Library_Handle );
library->refcount--;
if ( library->refcount > 0 )
@@ -4764,70 +4834,6 @@
}
-#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
-
- FT_BASE_DEF( FT_Error )
- ft_stub_set_char_sizes( FT_Size size,
- FT_F26Dot6 width,
- FT_F26Dot6 height,
- FT_UInt horz_res,
- FT_UInt vert_res )
- {
- FT_Size_RequestRec req;
- FT_Driver driver = size->face->driver;
-
-
- if ( driver->clazz->request_size )
- {
- req.type = FT_SIZE_REQUEST_TYPE_NOMINAL;
- req.width = width;
- req.height = height;
-
- if ( horz_res == 0 )
- horz_res = vert_res;
-
- if ( vert_res == 0 )
- vert_res = horz_res;
-
- if ( horz_res == 0 )
- horz_res = vert_res = 72;
-
- req.horiResolution = horz_res;
- req.vertResolution = vert_res;
-
- return driver->clazz->request_size( size, &req );
- }
-
- return 0;
- }
-
-
- FT_BASE_DEF( FT_Error )
- ft_stub_set_pixel_sizes( FT_Size size,
- FT_UInt width,
- FT_UInt height )
- {
- FT_Size_RequestRec req;
- FT_Driver driver = size->face->driver;
-
-
- if ( driver->clazz->request_size )
- {
- req.type = FT_SIZE_REQUEST_TYPE_NOMINAL;
- req.width = width << 6;
- req.height = height << 6;
- req.horiResolution = 0;
- req.vertResolution = 0;
-
- return driver->clazz->request_size( size, &req );
- }
-
- return 0;
- }
-
-#endif /* FT_CONFIG_OPTION_OLD_INTERNALS */
-
-
/* documentation is in freetype.h */
FT_EXPORT_DEF( FT_Error )
@@ -4839,7 +4845,7 @@
FT_Int *p_arg2,
FT_Matrix *p_transform )
{
- FT_Error error = FT_Err_Invalid_Argument;
+ FT_Error error = FT_ERR( Invalid_Argument );
if ( glyph &&
diff --git a/freetype/src/base/ftotval.c b/freetype/src/base/ftotval.c
index 694fd2b87..5fc73d76a 100644
--- a/freetype/src/base/ftotval.c
+++ b/freetype/src/base/ftotval.c
@@ -4,7 +4,7 @@
/* */
/* FreeType API for validating OpenType tables (body). */
/* */
-/* Copyright 2004, 2006, 2008, 2010 by */
+/* Copyright 2004, 2006, 2008, 2010, 2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,6 +16,8 @@
/***************************************************************************/
#include <ft2build.h>
+#include FT_INTERNAL_DEBUG_H
+
#include FT_INTERNAL_OBJECTS_H
#include FT_SERVICE_OPENTYPE_VALIDATE_H
#include FT_OPENTYPE_VALIDATE_H
@@ -38,7 +40,7 @@
if ( !face )
{
- error = FT_Err_Invalid_Face_Handle;
+ error = FT_THROW( Invalid_Face_Handle );
goto Exit;
}
@@ -48,7 +50,7 @@
GSUB_table &&
JSTF_table ) )
{
- error = FT_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
goto Exit;
}
@@ -63,7 +65,7 @@
GSUB_table,
JSTF_table );
else
- error = FT_Err_Unimplemented_Feature;
+ error = FT_THROW( Unimplemented_Feature );
Exit:
return error;
diff --git a/freetype/src/base/ftoutln.c b/freetype/src/base/ftoutln.c
index c4fd2660a..54ca5cdcf 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 by */
+/* Copyright 1996-2008, 2010, 2012-2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -26,6 +26,7 @@
#include <ft2build.h>
#include FT_OUTLINE_H
#include FT_INTERNAL_OBJECTS_H
+#include FT_INTERNAL_CALC_H
#include FT_INTERNAL_DEBUG_H
#include FT_TRIGONOMETRY_H
@@ -73,7 +74,7 @@
if ( !outline || !func_interface )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
shift = func_interface->shift;
delta = func_interface->delta;
@@ -286,7 +287,7 @@
return error;
Invalid_Outline:
- return FT_Err_Invalid_Outline;
+ return FT_THROW( Invalid_Outline );
}
@@ -300,10 +301,17 @@
if ( !anoutline || !memory )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
*anoutline = null_outline;
+ if ( numContours < 0 ||
+ (FT_UInt)numContours > numPoints )
+ return FT_THROW( Invalid_Argument );
+
+ if ( numPoints > FT_OUTLINE_POINTS_MAX )
+ return FT_THROW( Array_Too_Large );
+
if ( FT_NEW_ARRAY( anoutline->points, numPoints ) ||
FT_NEW_ARRAY( anoutline->tags, numPoints ) ||
FT_NEW_ARRAY( anoutline->contours, numContours ) )
@@ -332,7 +340,7 @@
FT_Outline *anoutline )
{
if ( !library )
- return FT_Err_Invalid_Library_Handle;
+ return FT_THROW( Invalid_Library_Handle );
return FT_Outline_New_Internal( library->memory, numPoints,
numContours, anoutline );
@@ -380,7 +388,7 @@
}
Bad:
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
}
@@ -396,7 +404,7 @@
if ( !source || !target ||
source->n_points != target->n_points ||
source->n_contours != target->n_contours )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
if ( source == target )
return FT_Err_Ok;
@@ -435,7 +443,7 @@
return FT_Err_Ok;
}
else
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
}
@@ -448,7 +456,7 @@
/* check for valid `outline' in FT_Outline_Done_Internal() */
if ( !library )
- return FT_Err_Invalid_Library_Handle;
+ return FT_THROW( Invalid_Library_Handle );
return FT_Outline_Done_Internal( library->memory, outline );
}
@@ -602,21 +610,21 @@
if ( !library )
- return FT_Err_Invalid_Library_Handle;
+ return FT_THROW( Invalid_Library_Handle );
if ( !outline || !params )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
renderer = library->cur_renderer;
node = library->renderers.head;
params->source = (void*)outline;
- error = FT_Err_Cannot_Render_Glyph;
+ error = FT_ERR( Cannot_Render_Glyph );
while ( renderer )
{
error = renderer->raster_render( renderer->raster, params );
- if ( !error || FT_ERROR_BASE( error ) != FT_Err_Cannot_Render_Glyph )
+ if ( !error || FT_ERR_NEQ( error, Cannot_Render_Glyph ) )
break;
/* FT_Err_Cannot_Render_Glyph is returned if the render mode */
@@ -650,7 +658,7 @@
if ( !abitmap )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
/* other checks are delayed to FT_Outline_Render() */
@@ -900,7 +908,7 @@
if ( !outline )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
xstrength /= 2;
ystrength /= 2;
@@ -911,7 +919,7 @@
if ( orientation == FT_ORIENTATION_NONE )
{
if ( outline->n_contours )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
else
return FT_Err_Ok;
}
@@ -930,10 +938,15 @@
v_prev = points[last];
v_cur = v_first;
- /* compute the incoming vector and its length */
+ /* compute incoming normalized vector */
in.x = v_cur.x - v_prev.x;
in.y = v_cur.y - v_prev.y;
l_in = FT_Vector_Length( &in );
+ if ( l_in )
+ {
+ in.x = FT_DivFix( in.x, l_in );
+ in.y = FT_DivFix( in.y, l_in );
+ }
for ( n = first; n <= last; n++ )
{
@@ -942,39 +955,48 @@
else
v_next = v_first;
- /* compute the outgoing vector and its length */
+ /* compute outgoing normalized vector */
out.x = v_next.x - v_cur.x;
out.y = v_next.y - v_cur.y;
l_out = FT_Vector_Length( &out );
+ if ( l_out )
+ {
+ out.x = FT_DivFix( out.x, l_out );
+ out.y = FT_DivFix( out.y, l_out );
+ }
- d = l_in * l_out + in.x * out.x + in.y * out.y;
+ d = FT_MulFix( in.x, out.x ) + FT_MulFix( in.y, out.y );
- /* shift only if turn is less then ~160 degrees */
- if ( 16 * d > l_in * l_out )
+ /* shift only if turn is less than ~160 degrees */
+ if ( d > -0xF000L )
{
- /* shift components are aligned along bisector */
- /* and directed according to the outline orientation. */
- shift.x = l_out * in.y + l_in * out.y;
- shift.y = l_out * in.x + l_in * out.x;
+ d = d + 0x10000L;
+
+ /* shift components are aligned along lateral bisector */
+ /* and directed according to the outline orientation. */
+ shift.x = in.y + out.y;
+ shift.y = in.x + out.x;
if ( orientation == FT_ORIENTATION_TRUETYPE )
shift.x = -shift.x;
else
shift.y = -shift.y;
- /* threshold strength to better handle collapsing segments */
- l = FT_MIN( l_in, l_out );
- q = out.x * in.y - out.y * in.x;
+ /* restrict shift magnitude to better handle collapsing segments */
+ q = FT_MulFix( out.x, in.y ) - FT_MulFix( out.y, in.x );
if ( orientation == FT_ORIENTATION_TRUETYPE )
q = -q;
- if ( FT_MulDiv( xstrength, q, l ) < d )
+ l = FT_MIN( l_in, l_out );
+
+ /* non-strict inequalities avoid divide-by-zero when q == l == 0 */
+ if ( FT_MulFix( xstrength, q ) <= FT_MulFix( d, l ) )
shift.x = FT_MulDiv( shift.x, xstrength, d );
else
shift.x = FT_MulDiv( shift.x, l, q );
-
- if ( FT_MulDiv( ystrength, q, l ) < d )
+
+ if ( FT_MulFix( ystrength, q ) <= FT_MulFix( d, l ) )
shift.y = FT_MulDiv( shift.y, ystrength, d );
else
shift.y = FT_MulDiv( shift.y, l, q );
@@ -1002,6 +1024,8 @@
FT_EXPORT_DEF( FT_Orientation )
FT_Outline_Get_Orientation( FT_Outline* outline )
{
+ FT_BBox cbox;
+ FT_Int xshift, yshift;
FT_Vector* points;
FT_Vector v_prev, v_cur;
FT_Int c, n, first;
@@ -1016,6 +1040,14 @@
/* cubic or quadratic curves, this test deals with the polygon */
/* only which is spanned up by the control points. */
+ FT_Outline_Get_CBox( outline, &cbox );
+
+ xshift = FT_MSB( FT_ABS( cbox.xMax ) | FT_ABS( cbox.xMin ) ) - 14;
+ xshift = FT_MAX( xshift, 0 );
+
+ yshift = FT_MSB( cbox.yMax - cbox.yMin ) - 14;
+ yshift = FT_MAX( yshift, 0 );
+
points = outline->points;
first = 0;
@@ -1029,7 +1061,8 @@
for ( n = first; n <= last; n++ )
{
v_cur = points[n];
- area += ( v_cur.y - v_prev.y ) * ( v_cur.x + v_prev.x );
+ area += ( ( v_cur.y - v_prev.y ) >> yshift ) *
+ ( ( v_cur.x + v_prev.x ) >> xshift );
v_prev = v_cur;
}
diff --git a/freetype/src/base/ftpfr.c b/freetype/src/base/ftpfr.c
index 3a0f92d07..0ba955f01 100644
--- a/freetype/src/base/ftpfr.c
+++ b/freetype/src/base/ftpfr.c
@@ -4,7 +4,7 @@
/* */
/* FreeType API for accessing PFR-specific data (body). */
/* */
-/* Copyright 2002, 2003, 2004, 2008, 2010 by */
+/* Copyright 2002-2004, 2008, 2010, 2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,6 +16,8 @@
/***************************************************************************/
#include <ft2build.h>
+#include FT_INTERNAL_DEBUG_H
+
#include FT_INTERNAL_OBJECTS_H
#include FT_SERVICE_PFR_H
@@ -48,7 +50,7 @@
if ( !face )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
service = ft_pfr_check( face );
if ( service )
@@ -84,7 +86,7 @@
if ( ametrics_y_scale )
*ametrics_y_scale = y_scale;
- error = FT_Err_Unknown_File_Format;
+ error = FT_THROW( Unknown_File_Format );
}
return error;
@@ -104,7 +106,7 @@
if ( !face )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
service = ft_pfr_check( face );
if ( service )
@@ -135,7 +137,7 @@
}
else
/* XXX: TODO: PROVIDE ADVANCE-LOADING METHOD TO ALL FONT DRIVERS */
- error = FT_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
return error;
}
diff --git a/freetype/src/base/ftrfork.c b/freetype/src/base/ftrfork.c
index dcefdd28d..804911721 100644
--- a/freetype/src/base/ftrfork.c
+++ b/freetype/src/base/ftrfork.c
@@ -4,7 +4,7 @@
/* */
/* Embedded resource forks accessor (body). */
/* */
-/* Copyright 2004, 2005, 2006, 2007, 2008, 2009, 2010 by */
+/* Copyright 2004-2010, 2013 by */
/* Masatake YAMATO and Redhat K.K. */
/* */
/* FT_Raccess_Get_HeaderInfo() and raccess_guess_darwin_hfsplus() are */
@@ -86,7 +86,7 @@
/* map_len = head[12] .. head[15] */
if ( *rdata_pos + rdata_len != map_pos || map_pos == rfork_offset )
- return FT_Err_Unknown_File_Format;
+ return FT_THROW( Unknown_File_Format );
error = FT_Stream_Seek( stream, map_pos );
if ( error )
@@ -108,7 +108,7 @@
allmatch = 0;
}
if ( !allzeros && !allmatch )
- return FT_Err_Unknown_File_Format;
+ return FT_THROW( Unknown_File_Format );
/* If we have reached this point then it is probably a mac resource */
/* file. Now, does it contain any interesting resources? */
@@ -121,7 +121,7 @@
if ( FT_READ_USHORT( type_list ) )
return error;
if ( type_list == -1 )
- return FT_Err_Unknown_File_Format;
+ return FT_THROW( Unknown_File_Format );
error = FT_Stream_Seek( stream, map_pos + type_list );
if ( error )
@@ -233,7 +233,7 @@
}
}
- return FT_Err_Cannot_Open_Resource;
+ return FT_THROW( Cannot_Open_Resource );
}
@@ -435,7 +435,7 @@
*result_file_name = NULL;
if ( NULL == stream )
- return FT_Err_Cannot_Open_Stream;
+ return FT_THROW( Cannot_Open_Stream );
return raccess_guess_apple_generic( library, stream, base_file_name,
magic, result_offset );
@@ -457,7 +457,7 @@
*result_file_name = NULL;
if ( NULL == stream )
- return FT_Err_Cannot_Open_Stream;
+ return FT_THROW( Cannot_Open_Stream );
return raccess_guess_apple_generic( library, stream, base_file_name,
magic, result_offset );
@@ -481,7 +481,7 @@
memory = library->memory;
newpath = raccess_make_file_name( memory, base_file_name, "._" );
if ( !newpath )
- return FT_Err_Out_Of_Memory;
+ return FT_THROW( Out_Of_Memory );
error = raccess_guess_linux_double_from_file_name( library, newpath,
result_offset );
@@ -507,7 +507,7 @@
FT_Error error;
char* newpath = NULL;
FT_Memory memory;
- FT_Long base_file_len = ft_strlen( base_file_name );
+ FT_Long base_file_len = (FT_Long)ft_strlen( base_file_name );
FT_UNUSED( stream );
@@ -515,7 +515,7 @@
memory = library->memory;
if ( base_file_len + 6 > FT_INT_MAX )
- return FT_Err_Array_Too_Large;
+ return FT_THROW( Array_Too_Large );
if ( FT_ALLOC( newpath, base_file_len + 6 ) )
return error;
@@ -543,7 +543,7 @@
FT_Error error;
char* newpath = NULL;
FT_Memory memory;
- FT_Long base_file_len = ft_strlen( base_file_name );
+ FT_Long base_file_len = (FT_Long)ft_strlen( base_file_name );
FT_UNUSED( stream );
@@ -551,7 +551,7 @@
memory = library->memory;
if ( base_file_len + 18 > FT_INT_MAX )
- return FT_Err_Array_Too_Large;
+ return FT_THROW( Array_Too_Large );
if ( FT_ALLOC( newpath, base_file_len + 18 ) )
return error;
@@ -584,7 +584,7 @@
newpath = raccess_make_file_name( memory, base_file_name,
"resource.frk/" );
if ( !newpath )
- return FT_Err_Out_Of_Memory;
+ return FT_THROW( Out_Of_Memory );
*result_file_name = newpath;
*result_offset = 0;
@@ -610,7 +610,7 @@
newpath = raccess_make_file_name( memory, base_file_name, ".resource/" );
if ( !newpath )
- return FT_Err_Out_Of_Memory;
+ return FT_THROW( Out_Of_Memory );
*result_file_name = newpath;
*result_offset = 0;
@@ -637,7 +637,7 @@
newpath = raccess_make_file_name( memory, base_file_name, "%" );
if ( !newpath )
- return FT_Err_Out_Of_Memory;
+ return FT_THROW( Out_Of_Memory );
error = raccess_guess_linux_double_from_file_name( library, newpath,
result_offset );
@@ -669,7 +669,7 @@
newpath = raccess_make_file_name( memory, base_file_name,
".AppleDouble/" );
if ( !newpath )
- return FT_Err_Out_Of_Memory;
+ return FT_THROW( Out_Of_Memory );
error = raccess_guess_linux_double_from_file_name( library, newpath,
result_offset );
@@ -708,7 +708,7 @@
if ( FT_READ_LONG( magic_from_stream ) )
return error;
if ( magic_from_stream != magic )
- return FT_Err_Unknown_File_Format;
+ return FT_THROW( Unknown_File_Format );
if ( FT_READ_LONG( version_number ) )
return error;
@@ -721,7 +721,7 @@
if ( FT_READ_USHORT( n_of_entries ) )
return error;
if ( n_of_entries == 0 )
- return FT_Err_Unknown_File_Format;
+ return FT_THROW( Unknown_File_Format );
for ( i = 0; i < n_of_entries; i++ )
{
@@ -744,7 +744,7 @@
}
}
- return FT_Err_Unknown_File_Format;
+ return FT_THROW( Unknown_File_Format );
}
@@ -838,7 +838,7 @@
{
new_names[i] = NULL;
offsets[i] = 0;
- errors[i] = FT_Err_Unimplemented_Feature;
+ errors[i] = FT_ERR( Unimplemented_Feature );
}
}
diff --git a/freetype/src/base/ftsnames.c b/freetype/src/base/ftsnames.c
index 3447888ca..260e91c14 100644
--- a/freetype/src/base/ftsnames.c
+++ b/freetype/src/base/ftsnames.c
@@ -44,7 +44,7 @@
FT_UInt idx,
FT_SfntName *aname )
{
- FT_Error error = FT_Err_Invalid_Argument;
+ FT_Error error = FT_ERR( Invalid_Argument );
if ( aname && face && FT_IS_SFNT( face ) )
diff --git a/freetype/src/base/ftstream.c b/freetype/src/base/ftstream.c
index fc2868e8d..d965333da 100644
--- a/freetype/src/base/ftstream.c
+++ b/freetype/src/base/ftstream.c
@@ -4,7 +4,7 @@
/* */
/* I/O stream support (body). */
/* */
-/* Copyright 2000-2002, 2004-2006, 2008-2011 by */
+/* Copyright 2000-2002, 2004-2006, 2008-2011, 2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -68,7 +68,7 @@
" invalid i/o; pos = 0x%lx, size = 0x%lx\n",
pos, stream->size ));
- error = FT_Err_Invalid_Stream_Operation;
+ error = FT_THROW( Invalid_Stream_Operation );
}
}
/* note that seeking to the first position after the file is valid */
@@ -78,7 +78,7 @@
" invalid i/o; pos = 0x%lx, size = 0x%lx\n",
pos, stream->size ));
- error = FT_Err_Invalid_Stream_Operation;
+ error = FT_THROW( Invalid_Stream_Operation );
}
if ( !error )
@@ -93,7 +93,7 @@
FT_Long distance )
{
if ( distance < 0 )
- return FT_Err_Invalid_Stream_Operation;
+ return FT_THROW( Invalid_Stream_Operation );
return FT_Stream_Seek( stream, (FT_ULong)( stream->pos + distance ) );
}
@@ -131,7 +131,7 @@
" invalid i/o; pos = 0x%lx, size = 0x%lx\n",
pos, stream->size ));
- return FT_Err_Invalid_Stream_Operation;
+ return FT_THROW( Invalid_Stream_Operation );
}
if ( stream->read )
@@ -153,7 +153,7 @@
" invalid read; expected %lu bytes, got %lu\n",
count, read_bytes ));
- error = FT_Err_Invalid_Stream_Operation;
+ error = FT_THROW( Invalid_Stream_Operation );
}
return error;
@@ -254,7 +254,7 @@
" frame size (%lu) larger than stream size (%lu)\n",
count, stream->size ));
- error = FT_Err_Invalid_Stream_Operation;
+ error = FT_THROW( Invalid_Stream_Operation );
goto Exit;
}
@@ -277,7 +277,7 @@
count, read_bytes ));
FT_FREE( stream->base );
- error = FT_Err_Invalid_Stream_Operation;
+ error = FT_THROW( Invalid_Stream_Operation );
}
stream->cursor = stream->base;
stream->limit = stream->cursor + count;
@@ -293,7 +293,7 @@
" invalid i/o; pos = 0x%lx, count = %lu, size = 0x%lx\n",
stream->pos, count, stream->size ));
- error = FT_Err_Invalid_Stream_Operation;
+ error = FT_THROW( Invalid_Stream_Operation );
goto Exit;
}
@@ -474,7 +474,7 @@
return result;
Fail:
- *error = FT_Err_Invalid_Stream_Operation;
+ *error = FT_THROW( Invalid_Stream_Operation );
FT_ERROR(( "FT_Stream_ReadChar:"
" invalid i/o; pos = 0x%lx, size = 0x%lx\n",
stream->pos, stream->size ));
@@ -521,7 +521,7 @@
return result;
Fail:
- *error = FT_Err_Invalid_Stream_Operation;
+ *error = FT_THROW( Invalid_Stream_Operation );
FT_ERROR(( "FT_Stream_ReadUShort:"
" invalid i/o; pos = 0x%lx, size = 0x%lx\n",
stream->pos, stream->size ));
@@ -568,7 +568,7 @@
return result;
Fail:
- *error = FT_Err_Invalid_Stream_Operation;
+ *error = FT_THROW( Invalid_Stream_Operation );
FT_ERROR(( "FT_Stream_ReadUShortLE:"
" invalid i/o; pos = 0x%lx, size = 0x%lx\n",
stream->pos, stream->size ));
@@ -615,7 +615,7 @@
return result;
Fail:
- *error = FT_Err_Invalid_Stream_Operation;
+ *error = FT_THROW( Invalid_Stream_Operation );
FT_ERROR(( "FT_Stream_ReadUOffset:"
" invalid i/o; pos = 0x%lx, size = 0x%lx\n",
stream->pos, stream->size ));
@@ -662,7 +662,7 @@
return result;
Fail:
- *error = FT_Err_Invalid_Stream_Operation;
+ *error = FT_THROW( Invalid_Stream_Operation );
FT_ERROR(( "FT_Stream_ReadULong:"
" invalid i/o; pos = 0x%lx, size = 0x%lx\n",
stream->pos, stream->size ));
@@ -709,7 +709,7 @@
return result;
Fail:
- *error = FT_Err_Invalid_Stream_Operation;
+ *error = FT_THROW( Invalid_Stream_Operation );
FT_ERROR(( "FT_Stream_ReadULongLE:"
" invalid i/o; pos = 0x%lx, size = 0x%lx\n",
stream->pos, stream->size ));
@@ -727,8 +727,9 @@
FT_Bool frame_accessed = 0;
FT_Byte* cursor;
+
if ( !fields || !stream )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
cursor = stream->cursor;
@@ -760,7 +761,7 @@
if ( cursor + len > stream->limit )
{
- error = FT_Err_Invalid_Stream_Operation;
+ error = FT_THROW( Invalid_Stream_Operation );
goto Exit;
}
@@ -776,43 +777,43 @@
case ft_frame_byte:
case ft_frame_schar: /* read a single byte */
- value = FT_NEXT_BYTE(cursor);
+ value = FT_NEXT_BYTE( cursor );
sign_shift = 24;
break;
case ft_frame_short_be:
case ft_frame_ushort_be: /* read a 2-byte big-endian short */
- value = FT_NEXT_USHORT(cursor);
+ value = FT_NEXT_USHORT( cursor) ;
sign_shift = 16;
break;
case ft_frame_short_le:
case ft_frame_ushort_le: /* read a 2-byte little-endian short */
- value = FT_NEXT_USHORT_LE(cursor);
+ value = FT_NEXT_USHORT_LE( cursor );
sign_shift = 16;
break;
case ft_frame_long_be:
case ft_frame_ulong_be: /* read a 4-byte big-endian long */
- value = FT_NEXT_ULONG(cursor);
+ value = FT_NEXT_ULONG( cursor );
sign_shift = 0;
break;
case ft_frame_long_le:
case ft_frame_ulong_le: /* read a 4-byte little-endian long */
- value = FT_NEXT_ULONG_LE(cursor);
+ value = FT_NEXT_ULONG_LE( cursor );
sign_shift = 0;
break;
case ft_frame_off3_be:
case ft_frame_uoff3_be: /* read a 3-byte big-endian long */
- value = FT_NEXT_UOFF3(cursor);
+ value = FT_NEXT_UOFF3( cursor );
sign_shift = 8;
break;
case ft_frame_off3_le:
case ft_frame_uoff3_le: /* read a 3-byte little-endian long */
- value = FT_NEXT_UOFF3_LE(cursor);
+ value = FT_NEXT_UOFF3_LE( cursor );
sign_shift = 8;
break;
@@ -831,15 +832,15 @@
p = (FT_Byte*)structure + fields->offset;
switch ( fields->size )
{
- case (8 / FT_CHAR_BIT):
+ case ( 8 / FT_CHAR_BIT ):
*(FT_Byte*)p = (FT_Byte)value;
break;
- case (16 / FT_CHAR_BIT):
+ case ( 16 / FT_CHAR_BIT ):
*(FT_UShort*)p = (FT_UShort)value;
break;
- case (32 / FT_CHAR_BIT):
+ case ( 32 / FT_CHAR_BIT ):
*(FT_UInt32*)p = (FT_UInt32)value;
break;
diff --git a/freetype/src/base/ftstroke.c b/freetype/src/base/ftstroke.c
index fd6a0c10b..ee61ceca0 100644
--- a/freetype/src/base/ftstroke.c
+++ b/freetype/src/base/ftstroke.c
@@ -4,7 +4,7 @@
/* */
/* FreeType path stroker (body). */
/* */
-/* Copyright 2002-2006, 2008-2011 by */
+/* Copyright 2002-2006, 2008-2011, 2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -795,7 +795,7 @@
if ( !library )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
memory = library->memory;
@@ -1954,7 +1954,7 @@
if ( !stroker || border > 1 )
{
- error = FT_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
goto Exit;
}
@@ -2060,7 +2060,7 @@
if ( !outline || !stroker )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
FT_Stroker_Rewind( stroker );
@@ -2238,7 +2238,7 @@
return error;
Invalid_Outline:
- return FT_Err_Invalid_Outline;
+ return FT_THROW( Invalid_Outline );
}
@@ -2258,7 +2258,7 @@
FT_Stroker stroker,
FT_Bool destroy )
{
- FT_Error error = FT_Err_Invalid_Argument;
+ FT_Error error = FT_ERR( Invalid_Argument );
FT_Glyph glyph = NULL;
FT_Library library = stroker->library;
@@ -2334,7 +2334,7 @@
FT_Bool inside,
FT_Bool destroy )
{
- FT_Error error = FT_Err_Invalid_Argument;
+ FT_Error error = FT_ERR( Invalid_Argument );
FT_Glyph glyph = NULL;
FT_Library library = stroker->library;
diff --git a/freetype/src/base/ftsystem.c b/freetype/src/base/ftsystem.c
index 7e203bef8..2c6ddac10 100644
--- a/freetype/src/base/ftsystem.c
+++ b/freetype/src/base/ftsystem.c
@@ -4,7 +4,7 @@
/* */
/* ANSI-specific FreeType low-level system interface (body). */
/* */
-/* Copyright 1996-2002, 2006, 2008-2011 by */
+/* Copyright 1996-2002, 2006, 2008-2011, 2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -228,7 +228,7 @@
if ( !stream )
- return FT_Err_Invalid_Stream_Handle;
+ return FT_THROW( Invalid_Stream_Handle );
stream->descriptor.pointer = NULL;
stream->pathname.pointer = (char*)filepathname;
@@ -243,7 +243,7 @@
FT_ERROR(( "FT_Stream_Open:"
" could not open `%s'\n", filepathname ));
- return FT_Err_Cannot_Open_Resource;
+ return FT_THROW( Cannot_Open_Resource );
}
ft_fseek( file, 0, SEEK_END );
@@ -253,7 +253,7 @@
FT_ERROR(( "FT_Stream_Open:" ));
FT_ERROR(( " opened `%s' but zero-sized\n", filepathname ));
ft_fclose( file );
- return FT_Err_Cannot_Open_Stream;
+ return FT_THROW( Cannot_Open_Stream );
}
ft_fseek( file, 0, SEEK_SET );
diff --git a/freetype/src/base/fttrigon.c b/freetype/src/base/fttrigon.c
index 52395388b..4ffdcb77f 100644
--- a/freetype/src/base/fttrigon.c
+++ b/freetype/src/base/fttrigon.c
@@ -4,7 +4,7 @@
/* */
/* FreeType trigonometric functions (body). */
/* */
-/* Copyright 2001-2005, 2012 by */
+/* Copyright 2001-2005, 2012-2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -15,31 +15,41 @@
/* */
/***************************************************************************/
+ /*************************************************************************/
+ /* */
+ /* This is a fixed-point CORDIC implementation of trigonometric */
+ /* functions as well as transformations between Cartesian and polar */
+ /* coordinates. The angles are represented as 16.16 fixed-point values */
+ /* in degrees, i.e., the angular resolution is 2^-16 degrees. Note that */
+ /* only vectors longer than 2^16*180/pi (or at least 22 bits) on a */
+ /* discrete Cartesian grid can have the same or better angular */
+ /* resolution. Therefore, to maintain this precision, some functions */
+ /* require an interim upscaling of the vectors, whereas others operate */
+ /* with 24-bit long vectors directly. */
+ /* */
+ /*************************************************************************/
#include <ft2build.h>
#include FT_INTERNAL_OBJECTS_H
+#include FT_INTERNAL_CALC_H
#include FT_TRIGONOMETRY_H
-#ifdef FT_LONG64
- typedef FT_INT64 FT_Int64;
-#endif
-
-
- /* the Cordic shrink factor 0.607252935008887 * 2^32 */
-#define FT_TRIG_SCALE 0x9B74EDA8UL
+ /* the Cordic shrink factor 0.858785336480436 * 2^32 */
+#define FT_TRIG_SCALE 0xDBD95B16UL
- /* the following is 0.607252935008887 * 2^30 */
-#define FT_TRIG_COSCALE 0x26DD3B6AUL
+ /* the highest bit in overflow-safe vector components, */
+ /* MSB of 0.858785336480436 * sqrt(0.5) * 2^30 */
+#define FT_TRIG_SAFE_MSB 29
/* this table was generated for FT_PI = 180L << 16, i.e. degrees */
#define FT_TRIG_MAX_ITERS 23
static const FT_Fixed
- ft_trig_arctan_table[23] =
+ ft_trig_arctan_table[] =
{
- 2949120L, 1740967L, 919879L, 466945L, 234379L, 117304L, 58666L,
- 29335L, 14668L, 7334L, 3667L, 1833L, 917L, 458L, 229L, 115L,
+ 1740967L, 919879L, 466945L, 234379L, 117304L, 58666L, 29335L,
+ 14668L, 7334L, 3667L, 1833L, 917L, 458L, 229L, 115L,
57L, 29L, 14L, 7L, 4L, 2L, 1L
};
@@ -55,7 +65,7 @@
s = val;
- val = ( val >= 0 ) ? val : -val;
+ val = FT_ABS( val );
v = ( val * (FT_Int64)FT_TRIG_SCALE ) + 0x100000000UL;
val = (FT_Fixed)( v >> 32 );
@@ -74,7 +84,7 @@
s = val;
- val = ( val >= 0 ) ? val : -val;
+ val = FT_ABS( val );
v1 = (FT_UInt32)val >> 16;
v2 = (FT_UInt32)( val & 0xFFFFL );
@@ -86,7 +96,7 @@
lo1 = k1 * v2 + k2 * v1; /* can't overflow */
lo2 = ( k2 * v2 ) >> 16;
- lo3 = ( lo1 >= lo2 ) ? lo1 : lo2;
+ lo3 = FT_MAX( lo1, lo2 );
lo1 += lo2;
hi += lo1 >> 16;
@@ -104,85 +114,29 @@
static FT_Int
ft_trig_prenorm( FT_Vector* vec )
{
- FT_Fixed x, y, z;
- FT_Int shift;
+ FT_Pos x, y;
+ FT_Int shift;
x = vec->x;
y = vec->y;
- z = ( ( x >= 0 ) ? x : - x ) | ( (y >= 0) ? y : -y );
- shift = 0;
-
-#if 1
- /* determine msb bit index in `shift' */
- if ( z >= ( 1L << 16 ) )
- {
- z >>= 16;
- shift += 16;
- }
- if ( z >= ( 1L << 8 ) )
- {
- z >>= 8;
- shift += 8;
- }
- if ( z >= ( 1L << 4 ) )
- {
- z >>= 4;
- shift += 4;
- }
- if ( z >= ( 1L << 2 ) )
- {
- z >>= 2;
- shift += 2;
- }
- if ( z >= ( 1L << 1 ) )
- {
- z >>= 1;
- shift += 1;
- }
+ shift = FT_MSB( FT_ABS( x ) | FT_ABS( y ) );
- if ( shift <= 27 )
+ if ( shift <= FT_TRIG_SAFE_MSB )
{
- shift = 27 - shift;
- vec->x = x << shift;
- vec->y = y << shift;
+ shift = FT_TRIG_SAFE_MSB - shift;
+ vec->x = (FT_Pos)( (FT_ULong)x << shift );
+ vec->y = (FT_Pos)( (FT_ULong)y << shift );
}
else
{
- shift -= 27;
+ shift -= FT_TRIG_SAFE_MSB;
vec->x = x >> shift;
vec->y = y >> shift;
shift = -shift;
}
-#else /* 0 */
-
- if ( z < ( 1L << 27 ) )
- {
- do
- {
- shift++;
- z <<= 1;
- } while ( z < ( 1L << 27 ) );
- vec->x = x << shift;
- vec->y = y << shift;
- }
- else if ( z > ( 1L << 28 ) )
- {
- do
- {
- shift++;
- z >>= 1;
- } while ( z > ( 1L << 28 ) );
-
- vec->x = x >> shift;
- vec->y = y >> shift;
- shift = -shift;
- }
-
-#endif /* 0 */
-
return shift;
}
@@ -192,49 +146,50 @@
FT_Angle theta )
{
FT_Int i;
- FT_Fixed x, y, xtemp;
+ FT_Fixed x, y, xtemp, b;
const FT_Fixed *arctanptr;
x = vec->x;
y = vec->y;
- /* Get angle between -90 and 90 degrees */
- while ( theta <= -FT_ANGLE_PI2 )
+ /* Rotate inside [-PI/4,PI/4] sector */
+ while ( theta < -FT_ANGLE_PI4 )
{
- x = -x;
- y = -y;
- theta += FT_ANGLE_PI;
+ xtemp = y;
+ y = -x;
+ x = xtemp;
+ theta += FT_ANGLE_PI2;
}
- while ( theta > FT_ANGLE_PI2 )
+ while ( theta > FT_ANGLE_PI4 )
{
- x = -x;
- y = -y;
- theta -= FT_ANGLE_PI;
+ xtemp = -y;
+ y = x;
+ x = xtemp;
+ theta -= FT_ANGLE_PI2;
}
arctanptr = ft_trig_arctan_table;
/* Pseudorotations, with right shifts */
- i = 0;
- do
+ for ( i = 1, b = 1; i < FT_TRIG_MAX_ITERS; b <<= 1, i++ )
{
if ( theta < 0 )
{
- xtemp = x + ( y >> i );
- y = y - ( x >> i );
+ xtemp = x + ( ( y + b ) >> i );
+ y = y - ( ( x + b ) >> i );
x = xtemp;
theta += *arctanptr++;
}
else
{
- xtemp = x - ( y >> i );
- y = y + ( x >> i );
+ xtemp = x - ( ( y + b ) >> i );
+ y = y + ( ( x + b ) >> i );
x = xtemp;
theta -= *arctanptr++;
}
- } while ( ++i < FT_TRIG_MAX_ITERS );
+ }
vec->x = x;
vec->y = y;
@@ -246,46 +201,65 @@
{
FT_Angle theta;
FT_Int i;
- FT_Fixed x, y, xtemp;
+ FT_Fixed x, y, xtemp, b;
const FT_Fixed *arctanptr;
x = vec->x;
y = vec->y;
- /* Get the vector into the right half plane */
- theta = 0;
- if ( x < 0 )
+ /* Get the vector into [-PI/4,PI/4] sector */
+ if ( y > x )
{
- x = -x;
- y = -y;
- theta = 2 * FT_ANGLE_PI2;
+ if ( y > -x )
+ {
+ theta = FT_ANGLE_PI2;
+ xtemp = y;
+ y = -x;
+ x = xtemp;
+ }
+ else
+ {
+ theta = y > 0 ? FT_ANGLE_PI : -FT_ANGLE_PI;
+ x = -x;
+ y = -y;
+ }
+ }
+ else
+ {
+ if ( y < -x )
+ {
+ theta = -FT_ANGLE_PI2;
+ xtemp = -y;
+ y = x;
+ x = xtemp;
+ }
+ else
+ {
+ theta = 0;
+ }
}
-
- if ( y > 0 )
- theta = - theta;
arctanptr = ft_trig_arctan_table;
/* Pseudorotations, with right shifts */
- i = 0;
- do
+ for ( i = 1, b = 1; i < FT_TRIG_MAX_ITERS; b <<= 1, i++ )
{
if ( y > 0 )
{
- xtemp = x + ( y >> i );
- y = y - ( x >> i );
+ xtemp = x + ( ( y + b ) >> i );
+ y = y - ( ( x + b ) >> i );
x = xtemp;
theta += *arctanptr++;
}
else
{
- xtemp = x - ( y >> i );
- y = y + ( x >> i );
+ xtemp = x - ( ( y + b ) >> i );
+ y = y + ( ( x + b ) >> i );
x = xtemp;
theta -= *arctanptr++;
}
- } while ( ++i < FT_TRIG_MAX_ITERS );
+ }
/* round theta */
if ( theta >= 0 )
@@ -306,11 +280,11 @@
FT_Vector v;
- v.x = FT_TRIG_COSCALE >> 2;
+ v.x = FT_TRIG_SCALE >> 8;
v.y = 0;
ft_trig_pseudo_rotate( &v, angle );
- return v.x / ( 1 << 12 );
+ return ( v.x + 0x80L ) >> 8;
}
@@ -331,7 +305,7 @@
FT_Vector v;
- v.x = FT_TRIG_COSCALE >> 2;
+ v.x = FT_TRIG_SCALE >> 8;
v.y = 0;
ft_trig_pseudo_rotate( &v, angle );
@@ -366,11 +340,11 @@
FT_Vector_Unit( FT_Vector* vec,
FT_Angle angle )
{
- vec->x = FT_TRIG_COSCALE >> 2;
+ vec->x = FT_TRIG_SCALE >> 8;
vec->y = 0;
ft_trig_pseudo_rotate( vec, angle );
- vec->x >>= 12;
- vec->y >>= 12;
+ vec->x = ( vec->x + 0x80L ) >> 8;
+ vec->y = ( vec->y + 0x80L ) >> 8;
}
@@ -413,8 +387,8 @@
else
{
shift = -shift;
- vec->x = v.x << shift;
- vec->y = v.y << shift;
+ vec->x = (FT_Pos)( (FT_ULong)v.x << shift );
+ vec->y = (FT_Pos)( (FT_ULong)v.y << shift );
}
}
}
@@ -434,11 +408,11 @@
/* handle trivial cases */
if ( v.x == 0 )
{
- return ( v.y >= 0 ) ? v.y : -v.y;
+ return FT_ABS( v.y );
}
else if ( v.y == 0 )
{
- return ( v.x >= 0 ) ? v.x : -v.x;
+ return FT_ABS( v.x );
}
/* general case */
@@ -450,7 +424,7 @@
if ( shift > 0 )
return ( v.x + ( 1 << ( shift - 1 ) ) ) >> shift;
- return v.x << -shift;
+ return (FT_Fixed)( (FT_UInt32)v.x << -shift );
}
@@ -475,7 +449,8 @@
v.x = ft_trig_downscale( v.x );
- *length = ( shift >= 0 ) ? ( v.x >> shift ) : ( v.x << -shift );
+ *length = ( shift >= 0 ) ? ( v.x >> shift )
+ : (FT_Fixed)( (FT_UInt32)v.x << -shift );
*angle = v.y;
}
diff --git a/freetype/src/base/fttype1.c b/freetype/src/base/fttype1.c
index 885dba598..c1f9931db 100644
--- a/freetype/src/base/fttype1.c
+++ b/freetype/src/base/fttype1.c
@@ -28,7 +28,7 @@
FT_Get_PS_Font_Info( FT_Face face,
PS_FontInfoRec* afont_info )
{
- FT_Error error = FT_Err_Invalid_Argument;
+ FT_Error error = FT_ERR( Invalid_Argument );
if ( face )
@@ -73,7 +73,7 @@
FT_Get_PS_Font_Private( FT_Face face,
PS_PrivateRec* afont_private )
{
- FT_Error error = FT_Err_Invalid_Argument;
+ FT_Error error = FT_ERR( Invalid_Argument );
if ( face )
diff --git a/freetype/src/base/ftutil.c b/freetype/src/base/ftutil.c
index 5f77be557..879d02752 100644
--- a/freetype/src/base/ftutil.c
+++ b/freetype/src/base/ftutil.c
@@ -4,7 +4,7 @@
/* */
/* FreeType utility file for memory and list management (body). */
/* */
-/* Copyright 2002, 2004, 2005, 2006, 2007 by */
+/* Copyright 2002, 2004-2007, 2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -75,12 +75,12 @@
{
block = memory->alloc( memory, size );
if ( block == NULL )
- error = FT_Err_Out_Of_Memory;
+ error = FT_THROW( Out_Of_Memory );
}
else if ( size < 0 )
{
/* may help catch/prevent security issues */
- error = FT_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
}
*p_error = error;
@@ -98,6 +98,7 @@
{
FT_Error error = FT_Err_Ok;
+
block = ft_mem_qrealloc( memory, item_size,
cur_count, new_count, block, &error );
if ( !error && new_count > cur_count )
@@ -127,7 +128,7 @@
if ( cur_count < 0 || new_count < 0 || item_size < 0 )
{
/* may help catch/prevent nasty security issues */
- error = FT_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
}
else if ( new_count == 0 || item_size == 0 )
{
@@ -136,7 +137,7 @@
}
else if ( new_count > FT_INT_MAX/item_size )
{
- error = FT_Err_Array_Too_Large;
+ error = FT_THROW( Array_Too_Large );
}
else if ( cur_count == 0 )
{
@@ -153,7 +154,7 @@
block2 = memory->realloc( memory, cur_size, new_size, block );
if ( block2 == NULL )
- error = FT_Err_Out_Of_Memory;
+ error = FT_THROW( Out_Of_Memory );
else
block = block2;
}
@@ -432,70 +433,4 @@
}
-#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
-
- FT_BASE_DEF( FT_Error )
- FT_Alloc( FT_Memory memory,
- FT_Long size,
- void* *P )
- {
- FT_Error error;
-
-
- (void)FT_ALLOC( *P, size );
- return error;
- }
-
-
- FT_BASE_DEF( FT_Error )
- FT_QAlloc( FT_Memory memory,
- FT_Long size,
- void* *p )
- {
- FT_Error error;
-
-
- (void)FT_QALLOC( *p, size );
- return error;
- }
-
-
- FT_BASE_DEF( FT_Error )
- FT_Realloc( FT_Memory memory,
- FT_Long current,
- FT_Long size,
- void* *P )
- {
- FT_Error error;
-
-
- (void)FT_REALLOC( *P, current, size );
- return error;
- }
-
-
- FT_BASE_DEF( FT_Error )
- FT_QRealloc( FT_Memory memory,
- FT_Long current,
- FT_Long size,
- void* *p )
- {
- FT_Error error;
-
-
- (void)FT_QREALLOC( *p, current, size );
- return error;
- }
-
-
- FT_BASE_DEF( void )
- FT_Free( FT_Memory memory,
- void* *P )
- {
- if ( *P )
- FT_MEM_FREE( *P );
- }
-
-#endif /* FT_CONFIG_OPTION_OLD_INTERNALS */
-
/* END */
diff --git a/freetype/src/base/ftwinfnt.c b/freetype/src/base/ftwinfnt.c
index bc2e90e1f..463ae761d 100644
--- a/freetype/src/base/ftwinfnt.c
+++ b/freetype/src/base/ftwinfnt.c
@@ -32,7 +32,7 @@
FT_Error error;
- error = FT_Err_Invalid_Argument;
+ error = FT_ERR( Invalid_Argument );
if ( face != NULL )
{
diff --git a/freetype/src/base/md5.c b/freetype/src/base/md5.c
new file mode 100644
index 000000000..2f01c9302
--- /dev/null
+++ b/freetype/src/base/md5.c
@@ -0,0 +1,295 @@
+/*
+ * This is an OpenSSL-compatible implementation of the RSA Data Security, Inc.
+ * MD5 Message-Digest Algorithm (RFC 1321).
+ *
+ * Homepage:
+ * http://openwall.info/wiki/people/solar/software/public-domain-source-code/md5
+ *
+ * Author:
+ * Alexander Peslyak, better known as Solar Designer <solar at openwall.com>
+ *
+ * This software was written by Alexander Peslyak in 2001. No copyright is
+ * claimed, and the software is hereby placed in the public domain.
+ * In case this attempt to disclaim copyright and place the software in the
+ * public domain is deemed null and void, then the software is
+ * Copyright (c) 2001 Alexander Peslyak and it is hereby released to the
+ * general public under the following terms:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted.
+ *
+ * There's ABSOLUTELY NO WARRANTY, express or implied.
+ *
+ * (This is a heavily cut-down "BSD license".)
+ *
+ * This differs from Colin Plumb's older public domain implementation in that
+ * no exactly 32-bit integer data type is required (any 32-bit or wider
+ * unsigned integer data type will do), there's no compile-time endianness
+ * configuration, and the function prototypes match OpenSSL's. No code from
+ * Colin Plumb's implementation has been reused; this comment merely compares
+ * the properties of the two independent implementations.
+ *
+ * The primary goals of this implementation are portability and ease of use.
+ * It is meant to be fast, but not as fast as possible. Some known
+ * optimizations are not included to reduce source code size and avoid
+ * compile-time configuration.
+ */
+
+#ifndef HAVE_OPENSSL
+
+#include <string.h>
+
+#include "md5.h"
+
+/*
+ * The basic MD5 functions.
+ *
+ * F and G are optimized compared to their RFC 1321 definitions for
+ * architectures that lack an AND-NOT instruction, just like in Colin Plumb's
+ * implementation.
+ */
+#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 I(x, y, z) ((y) ^ ((x) | ~(z)))
+
+/*
+ * The MD5 transformation for all four rounds.
+ */
+#define STEP(f, a, b, c, d, x, t, s) \
+ (a) += f((b), (c), (d)) + (x) + (t); \
+ (a) = (((a) << (s)) | (((a) & 0xffffffff) >> (32 - (s)))); \
+ (a) += (b);
+
+/*
+ * SET reads 4 input bytes in little-endian byte order and stores them
+ * in a properly aligned word in host byte order.
+ *
+ * The check for little-endian architectures that tolerate unaligned
+ * memory accesses is just an optimization. Nothing will break if it
+ * doesn't work.
+ */
+#if defined(__i386__) || defined(__x86_64__) || defined(__vax__)
+#define SET(n) \
+ (*(MD5_u32plus *)&ptr[(n) * 4])
+#define GET(n) \
+ SET(n)
+#else
+#define SET(n) \
+ (ctx->block[(n)] = \
+ (MD5_u32plus)ptr[(n) * 4] | \
+ ((MD5_u32plus)ptr[(n) * 4 + 1] << 8) | \
+ ((MD5_u32plus)ptr[(n) * 4 + 2] << 16) | \
+ ((MD5_u32plus)ptr[(n) * 4 + 3] << 24))
+#define GET(n) \
+ (ctx->block[(n)])
+#endif
+
+/*
+ * 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)
+{
+ unsigned char *ptr;
+ MD5_u32plus a, b, c, d;
+ MD5_u32plus saved_a, saved_b, saved_c, saved_d;
+
+ ptr = (unsigned char *)data;
+
+ a = ctx->a;
+ b = ctx->b;
+ c = ctx->c;
+ d = ctx->d;
+
+ do {
+ saved_a = a;
+ saved_b = b;
+ saved_c = c;
+ saved_d = d;
+
+/* Round 1 */
+ STEP(F, a, b, c, d, SET(0), 0xd76aa478, 7)
+ STEP(F, d, a, b, c, SET(1), 0xe8c7b756, 12)
+ STEP(F, c, d, a, b, SET(2), 0x242070db, 17)
+ STEP(F, b, c, d, a, SET(3), 0xc1bdceee, 22)
+ STEP(F, a, b, c, d, SET(4), 0xf57c0faf, 7)
+ STEP(F, d, a, b, c, SET(5), 0x4787c62a, 12)
+ STEP(F, c, d, a, b, SET(6), 0xa8304613, 17)
+ STEP(F, b, c, d, a, SET(7), 0xfd469501, 22)
+ STEP(F, a, b, c, d, SET(8), 0x698098d8, 7)
+ STEP(F, d, a, b, c, SET(9), 0x8b44f7af, 12)
+ STEP(F, c, d, a, b, SET(10), 0xffff5bb1, 17)
+ STEP(F, b, c, d, a, SET(11), 0x895cd7be, 22)
+ STEP(F, a, b, c, d, SET(12), 0x6b901122, 7)
+ STEP(F, d, a, b, c, SET(13), 0xfd987193, 12)
+ STEP(F, c, d, a, b, SET(14), 0xa679438e, 17)
+ STEP(F, b, c, d, a, SET(15), 0x49b40821, 22)
+
+/* Round 2 */
+ STEP(G, a, b, c, d, GET(1), 0xf61e2562, 5)
+ STEP(G, d, a, b, c, GET(6), 0xc040b340, 9)
+ STEP(G, c, d, a, b, GET(11), 0x265e5a51, 14)
+ STEP(G, b, c, d, a, GET(0), 0xe9b6c7aa, 20)
+ STEP(G, a, b, c, d, GET(5), 0xd62f105d, 5)
+ STEP(G, d, a, b, c, GET(10), 0x02441453, 9)
+ STEP(G, c, d, a, b, GET(15), 0xd8a1e681, 14)
+ STEP(G, b, c, d, a, GET(4), 0xe7d3fbc8, 20)
+ STEP(G, a, b, c, d, GET(9), 0x21e1cde6, 5)
+ STEP(G, d, a, b, c, GET(14), 0xc33707d6, 9)
+ STEP(G, c, d, a, b, GET(3), 0xf4d50d87, 14)
+ STEP(G, b, c, d, a, GET(8), 0x455a14ed, 20)
+ STEP(G, a, b, c, d, GET(13), 0xa9e3e905, 5)
+ STEP(G, d, a, b, c, GET(2), 0xfcefa3f8, 9)
+ STEP(G, c, d, a, b, GET(7), 0x676f02d9, 14)
+ STEP(G, b, c, d, a, GET(12), 0x8d2a4c8a, 20)
+
+/* Round 3 */
+ STEP(H, a, b, c, d, GET(5), 0xfffa3942, 4)
+ STEP(H, 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(H, a, b, c, d, GET(1), 0xa4beea44, 4)
+ STEP(H, 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(H, a, b, c, d, GET(13), 0x289b7ec6, 4)
+ STEP(H, 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(H, a, b, c, d, GET(9), 0xd9d4d039, 4)
+ STEP(H, 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)
+
+/* Round 4 */
+ STEP(I, a, b, c, d, GET(0), 0xf4292244, 6)
+ STEP(I, d, a, b, c, GET(7), 0x432aff97, 10)
+ STEP(I, c, d, a, b, GET(14), 0xab9423a7, 15)
+ STEP(I, b, c, d, a, GET(5), 0xfc93a039, 21)
+ STEP(I, a, b, c, d, GET(12), 0x655b59c3, 6)
+ STEP(I, d, a, b, c, GET(3), 0x8f0ccc92, 10)
+ STEP(I, c, d, a, b, GET(10), 0xffeff47d, 15)
+ STEP(I, b, c, d, a, GET(1), 0x85845dd1, 21)
+ STEP(I, a, b, c, d, GET(8), 0x6fa87e4f, 6)
+ STEP(I, d, a, b, c, GET(15), 0xfe2ce6e0, 10)
+ STEP(I, c, d, a, b, GET(6), 0xa3014314, 15)
+ STEP(I, b, c, d, a, GET(13), 0x4e0811a1, 21)
+ STEP(I, a, b, c, d, GET(4), 0xf7537e82, 6)
+ STEP(I, d, a, b, c, GET(11), 0xbd3af235, 10)
+ STEP(I, c, d, a, b, GET(2), 0x2ad7d2bb, 15)
+ STEP(I, b, c, d, a, GET(9), 0xeb86d391, 21)
+
+ a += saved_a;
+ b += saved_b;
+ c += saved_c;
+ d += saved_d;
+
+ ptr += 64;
+ } while (size -= 64);
+
+ ctx->a = a;
+ ctx->b = b;
+ ctx->c = c;
+ ctx->d = d;
+
+ return ptr;
+}
+
+void MD5_Init(MD5_CTX *ctx)
+{
+ ctx->a = 0x67452301;
+ ctx->b = 0xefcdab89;
+ ctx->c = 0x98badcfe;
+ ctx->d = 0x10325476;
+
+ ctx->lo = 0;
+ ctx->hi = 0;
+}
+
+void MD5_Update(MD5_CTX *ctx, void *data, unsigned long size)
+{
+ MD5_u32plus saved_lo;
+ unsigned long used, free;
+
+ saved_lo = ctx->lo;
+ if ((ctx->lo = (saved_lo + size) & 0x1fffffff) < saved_lo)
+ ctx->hi++;
+ ctx->hi += size >> 29;
+
+ used = saved_lo & 0x3f;
+
+ if (used) {
+ free = 64 - used;
+
+ if (size < free) {
+ memcpy(&ctx->buffer[used], data, size);
+ return;
+ }
+
+ memcpy(&ctx->buffer[used], data, free);
+ data = (unsigned char *)data + free;
+ size -= free;
+ body(ctx, ctx->buffer, 64);
+ }
+
+ if (size >= 64) {
+ data = body(ctx, data, size & ~(unsigned long)0x3f);
+ size &= 0x3f;
+ }
+
+ memcpy(ctx->buffer, data, size);
+}
+
+void MD5_Final(unsigned char *result, MD5_CTX *ctx)
+{
+ unsigned long used, free;
+
+ used = ctx->lo & 0x3f;
+
+ ctx->buffer[used++] = 0x80;
+
+ free = 64 - used;
+
+ if (free < 8) {
+ memset(&ctx->buffer[used], 0, free);
+ body(ctx, ctx->buffer, 64);
+ used = 0;
+ free = 64;
+ }
+
+ memset(&ctx->buffer[used], 0, free - 8);
+
+ ctx->lo <<= 3;
+ ctx->buffer[56] = ctx->lo;
+ ctx->buffer[57] = ctx->lo >> 8;
+ ctx->buffer[58] = ctx->lo >> 16;
+ ctx->buffer[59] = ctx->lo >> 24;
+ ctx->buffer[60] = ctx->hi;
+ ctx->buffer[61] = ctx->hi >> 8;
+ ctx->buffer[62] = ctx->hi >> 16;
+ ctx->buffer[63] = ctx->hi >> 24;
+
+ body(ctx, ctx->buffer, 64);
+
+ result[0] = ctx->a;
+ result[1] = ctx->a >> 8;
+ result[2] = ctx->a >> 16;
+ result[3] = ctx->a >> 24;
+ result[4] = ctx->b;
+ result[5] = ctx->b >> 8;
+ result[6] = ctx->b >> 16;
+ result[7] = ctx->b >> 24;
+ result[8] = ctx->c;
+ result[9] = ctx->c >> 8;
+ result[10] = ctx->c >> 16;
+ result[11] = ctx->c >> 24;
+ result[12] = ctx->d;
+ result[13] = ctx->d >> 8;
+ result[14] = ctx->d >> 16;
+ result[15] = ctx->d >> 24;
+
+ memset(ctx, 0, sizeof(*ctx));
+}
+
+#endif
diff --git a/freetype/src/base/md5.h b/freetype/src/base/md5.h
new file mode 100644
index 000000000..f1a685764
--- /dev/null
+++ b/freetype/src/base/md5.h
@@ -0,0 +1,45 @@
+/*
+ * This is an OpenSSL-compatible implementation of the RSA Data Security, Inc.
+ * MD5 Message-Digest Algorithm (RFC 1321).
+ *
+ * Homepage:
+ * http://openwall.info/wiki/people/solar/software/public-domain-source-code/md5
+ *
+ * Author:
+ * Alexander Peslyak, better known as Solar Designer <solar at openwall.com>
+ *
+ * This software was written by Alexander Peslyak in 2001. No copyright is
+ * claimed, and the software is hereby placed in the public domain.
+ * In case this attempt to disclaim copyright and place the software in the
+ * public domain is deemed null and void, then the software is
+ * Copyright (c) 2001 Alexander Peslyak and it is hereby released to the
+ * general public under the following terms:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted.
+ *
+ * There's ABSOLUTELY NO WARRANTY, express or implied.
+ *
+ * See md5.c for more information.
+ */
+
+#ifdef HAVE_OPENSSL
+#include <openssl/md5.h>
+#elif !defined(_MD5_H)
+#define _MD5_H
+
+/* Any 32-bit or wider unsigned integer data type will do */
+typedef unsigned int MD5_u32plus;
+
+typedef struct {
+ MD5_u32plus lo, hi;
+ MD5_u32plus a, b, c, d;
+ unsigned char buffer[64];
+ MD5_u32plus block[16];
+} MD5_CTX;
+
+extern void MD5_Init(MD5_CTX *ctx);
+extern void MD5_Update(MD5_CTX *ctx, 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 10f578abc..e93219115 100644
--- a/freetype/src/base/rules.mk
+++ b/freetype/src/base/rules.mk
@@ -3,7 +3,7 @@
#
-# Copyright 1996-2000, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by
+# Copyright 1996-2000, 2002-2009, 2013 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
@@ -50,7 +50,10 @@ ifneq ($(ftmac_c),)
BASE_SRC += $(BASE_DIR)/$(ftmac_c)
endif
-BASE_H := $(BASE_DIR)/ftbase.h
+# for simplicity, we also handle `md5.c' (which gets included by `ftobjs.h')
+BASE_H := $(BASE_DIR)/ftbase.h \
+ $(BASE_DIR)/md5.c \
+ $(BASE_DIR)/md5.h
# Base layer `extensions' sources
#