summaryrefslogtreecommitdiffstats
path: root/src/base
diff options
context:
space:
mode:
authorDavid 'Digit' Turner <digit@google.com>2010-03-03 14:24:57 -0800
committerDavid 'Digit' Turner <digit@google.com>2010-03-03 15:33:53 -0800
commit295ffce55e0198e7a9f7d46b33f5c2b4147bf821 (patch)
treebda1a337e630483e46b2e4d4db803814437b765d /src/base
parent6fb02c1f75ab969890012dd1f01939d3444ddbc1 (diff)
downloadandroid_external_freetype-295ffce55e0198e7a9f7d46b33f5c2b4147bf821.tar.gz
android_external_freetype-295ffce55e0198e7a9f7d46b33f5c2b4147bf821.tar.bz2
android_external_freetype-295ffce55e0198e7a9f7d46b33f5c2b4147bf821.zip
Update to FreeType 2.3.12
Diffstat (limited to 'src/base')
-rw-r--r--src/base/basepic.c83
-rw-r--r--src/base/basepic.h62
-rw-r--r--src/base/ftadvanc.c2
-rw-r--r--src/base/ftbase.c6
-rw-r--r--src/base/ftbase.h6
-rw-r--r--src/base/ftbbox.c27
-rw-r--r--src/base/ftbitmap.c8
-rw-r--r--src/base/ftcalc.c34
-rw-r--r--src/base/ftdbgmem.c4
-rw-r--r--src/base/ftgloadr.c7
-rw-r--r--src/base/ftglyph.c27
-rw-r--r--src/base/ftinit.c111
-rw-r--r--src/base/ftobjs.c148
-rw-r--r--src/base/ftoutln.c4
-rw-r--r--src/base/ftpatent.c17
-rw-r--r--src/base/ftpic.c54
-rw-r--r--src/base/ftrfork.c4
-rw-r--r--src/base/ftsnames.c (renamed from src/base/ftnames.c)10
-rw-r--r--src/base/ftstream.c56
-rw-r--r--src/base/ftstroke.c64
-rw-r--r--src/base/ftsynth.c29
-rw-r--r--src/base/ftsystem.c9
-rw-r--r--src/base/fttrigon.c10
23 files changed, 629 insertions, 153 deletions
diff --git a/src/base/basepic.c b/src/base/basepic.c
new file mode 100644
index 0000000..c0bccb6
--- /dev/null
+++ b/src/base/basepic.c
@@ -0,0 +1,83 @@
+/***************************************************************************/
+/* */
+/* basepic.c */
+/* */
+/* The FreeType position independent code services for base. */
+/* */
+/* Copyright 2009 by */
+/* Oran Agra and Mickey Gabel. */
+/* */
+/* This file is part of the FreeType project, and may only be used, */
+/* modified, and distributed under the terms of the FreeType project */
+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
+/* this file you indicate that you have read the license and */
+/* understand and accept it fully. */
+/* */
+/***************************************************************************/
+
+
+#include <ft2build.h>
+#include FT_FREETYPE_H
+#include FT_INTERNAL_OBJECTS_H
+#include "basepic.h"
+
+#ifdef FT_CONFIG_OPTION_PIC
+
+ /* forward declaration of PIC init functions from ftglyph.c */
+ void FT_Init_Class_ft_outline_glyph_class(FT_Glyph_Class*);
+ void FT_Init_Class_ft_bitmap_glyph_class(FT_Glyph_Class*);
+
+ /* forward declaration of PIC init functions from ftinit.c */
+ FT_Error ft_create_default_module_classes(FT_Library);
+ void ft_destroy_default_module_classes(FT_Library);
+
+ void
+ ft_base_pic_free( FT_Library library )
+ {
+ FT_PIC_Container* pic_container = &library->pic_container;
+ FT_Memory memory = library->memory;
+ if ( pic_container->base )
+ {
+ /* Destroy default module classes (in case FT_Add_Default_Modules was used) */
+ ft_destroy_default_module_classes( library );
+
+ FT_FREE( pic_container->base );
+ pic_container->base = NULL;
+ }
+ }
+
+
+ FT_Error
+ ft_base_pic_init( FT_Library library )
+ {
+ FT_PIC_Container* pic_container = &library->pic_container;
+ FT_Error error = FT_Err_Ok;
+ BasePIC* container;
+ FT_Memory memory = library->memory;
+
+ /* allocate pointer, clear and set global container pointer */
+ if ( FT_ALLOC ( container, sizeof ( *container ) ) )
+ return error;
+ FT_MEM_SET( container, 0, sizeof(*container) );
+ pic_container->base = container;
+
+ /* initialize default modules list and pointers */
+ error = ft_create_default_module_classes( library );
+ if ( error )
+ goto Exit;
+
+ /* initialize pointer table - this is how the module usually expects this data */
+ FT_Init_Class_ft_outline_glyph_class(&container->ft_outline_glyph_class);
+ FT_Init_Class_ft_bitmap_glyph_class(&container->ft_bitmap_glyph_class);
+
+Exit:
+ if(error)
+ ft_base_pic_free(library);
+ return error;
+ }
+
+
+#endif /* FT_CONFIG_OPTION_PIC */
+
+
+/* END */
diff --git a/src/base/basepic.h b/src/base/basepic.h
new file mode 100644
index 0000000..bb17745
--- /dev/null
+++ b/src/base/basepic.h
@@ -0,0 +1,62 @@
+/***************************************************************************/
+/* */
+/* basepic.h */
+/* */
+/* The FreeType position independent code services for base. */
+/* */
+/* Copyright 2009 by */
+/* Oran Agra and Mickey Gabel. */
+/* */
+/* This file is part of the FreeType project, and may only be used, */
+/* modified, and distributed under the terms of the FreeType project */
+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
+/* this file you indicate that you have read the license and */
+/* understand and accept it fully. */
+/* */
+/***************************************************************************/
+
+
+#ifndef __BASEPIC_H__
+#define __BASEPIC_H__
+
+
+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
+
+#else /* FT_CONFIG_OPTION_PIC */
+
+#include FT_GLYPH_H
+
+ typedef struct BasePIC_
+ {
+ FT_Module_Class** default_module_classes;
+ FT_Glyph_Class ft_outline_glyph_class;
+ FT_Glyph_Class ft_bitmap_glyph_class;
+ } 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)
+
+ void
+ ft_base_pic_free( FT_Library library );
+
+ FT_Error
+ ft_base_pic_init( FT_Library library );
+
+#endif /* FT_CONFIG_OPTION_PIC */
+ /* */
+
+FT_END_HEADER
+
+#endif /* __BASEPIC_H__ */
+
+
+/* END */
diff --git a/src/base/ftadvanc.c b/src/base/ftadvanc.c
index 504f9d2..8ab7fcb 100644
--- a/src/base/ftadvanc.c
+++ b/src/base/ftadvanc.c
@@ -140,7 +140,7 @@
if ( flags & FT_ADVANCE_FLAG_FAST_ONLY )
return FT_Err_Unimplemented_Feature;
- flags |= FT_LOAD_ADVANCE_ONLY;
+ flags |= (FT_UInt32)FT_LOAD_ADVANCE_ONLY;
for ( nn = 0; nn < count; nn++ )
{
error = FT_Load_Glyph( face, start + nn, flags );
diff --git a/src/base/ftbase.c b/src/base/ftbase.c
index d1fe6e6..6a27ea9 100644
--- a/src/base/ftbase.c
+++ b/src/base/ftbase.c
@@ -4,7 +4,7 @@
/* */
/* Single object library component (body only). */
/* */
-/* Copyright 1996-2001, 2002, 2003, 2004, 2006, 2007, 2008 by */
+/* Copyright 1996-2001, 2002, 2003, 2004, 2006, 2007, 2008, 2009 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -20,14 +20,16 @@
#define FT_MAKE_OPTION_SINGLE_OBJECT
+#include "ftpic.c"
+#include "basepic.c"
#include "ftadvanc.c"
#include "ftcalc.c"
#include "ftdbgmem.c"
#include "ftgloadr.c"
-#include "ftnames.c"
#include "ftobjs.c"
#include "ftoutln.c"
#include "ftrfork.c"
+#include "ftsnames.c"
#include "ftstream.c"
#include "fttrigon.c"
#include "ftutil.c"
diff --git a/src/base/ftbase.h b/src/base/ftbase.h
index 9cae85d..1dc49f3 100644
--- a/src/base/ftbase.h
+++ b/src/base/ftbase.h
@@ -4,7 +4,7 @@
/* */
/* The FreeType private functions used in base module (specification). */
/* */
-/* Copyright 2008 by */
+/* Copyright 2008, 2010 by */
/* David Turner, Robert Wilhelm, Werner Lemberg, and suzuki toshiya. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -29,7 +29,7 @@ FT_BEGIN_HEADER
/* Assume the stream is sfnt-wrapped PS Type1 or sfnt-wrapped CID-keyed */
/* font, and try to load a face specified by the face_index. */
- FT_LOCAL_DEF( FT_Error )
+ FT_LOCAL( FT_Error )
open_face_PS_from_sfnt_stream( FT_Library library,
FT_Stream stream,
FT_Long face_index,
@@ -40,7 +40,7 @@ FT_BEGIN_HEADER
/* Create a new FT_Face given a buffer and a driver name. */
/* From ftmac.c. */
- FT_LOCAL_DEF( FT_Error )
+ FT_LOCAL( FT_Error )
open_face_from_buffer( FT_Library library,
FT_Byte* base,
FT_ULong size,
diff --git a/src/base/ftbbox.c b/src/base/ftbbox.c
index 532ab13..2de592d 100644
--- a/src/base/ftbbox.c
+++ b/src/base/ftbbox.c
@@ -4,7 +4,7 @@
/* */
/* FreeType bbox computation (body). */
/* */
-/* Copyright 1996-2001, 2002, 2004, 2006 by */
+/* Copyright 1996-2001, 2002, 2004, 2006, 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used */
@@ -29,6 +29,7 @@
#include FT_IMAGE_H
#include FT_OUTLINE_H
#include FT_INTERNAL_CALC_H
+#include FT_INTERNAL_OBJECTS_H
typedef struct TBBox_Rec_
@@ -139,7 +140,7 @@
/* */
/* <Description> */
/* This function is used as a `conic_to' emitter during */
- /* FT_Raster_Decompose(). It checks a conic Bezier curve with the */
+ /* FT_Outline_Decompose(). It checks a conic Bezier curve with the */
/* current bounding box, and computes its extrema if necessary to */
/* update it. */
/* */
@@ -506,7 +507,7 @@
/* */
/* <Description> */
/* This function is used as a `cubic_to' emitter during */
- /* FT_Raster_Decompose(). It checks a cubic Bezier curve with the */
+ /* FT_Outline_Decompose(). It checks a cubic Bezier curve with the */
/* current bounding box, and computes its extrema if necessary to */
/* update it. */
/* */
@@ -559,6 +560,13 @@
return 0;
}
+FT_DEFINE_OUTLINE_FUNCS(bbox_interface,
+ (FT_Outline_MoveTo_Func) BBox_Move_To,
+ (FT_Outline_LineTo_Func) BBox_Move_To,
+ (FT_Outline_ConicTo_Func)BBox_Conic_To,
+ (FT_Outline_CubicTo_Func)BBox_Cubic_To,
+ 0, 0
+ )
/* documentation is in ftbbox.h */
@@ -628,18 +636,13 @@
/* the two boxes are different, now walk over the outline to */
/* get the Bezier arc extrema. */
- static const FT_Outline_Funcs bbox_interface =
- {
- (FT_Outline_MoveTo_Func) BBox_Move_To,
- (FT_Outline_LineTo_Func) BBox_Move_To,
- (FT_Outline_ConicTo_Func)BBox_Conic_To,
- (FT_Outline_CubicTo_Func)BBox_Cubic_To,
- 0, 0
- };
-
FT_Error error;
TBBox_Rec user;
+#ifdef FT_CONFIG_OPTION_PIC
+ FT_Outline_Funcs bbox_interface;
+ Init_Class_bbox_interface(&bbox_interface);
+#endif
user.bbox = bbox;
diff --git a/src/base/ftbitmap.c b/src/base/ftbitmap.c
index 8810cfa..46fcce6 100644
--- a/src/base/ftbitmap.c
+++ b/src/base/ftbitmap.c
@@ -228,8 +228,12 @@
if ( !bitmap || !bitmap->buffer )
return FT_Err_Invalid_Argument;
- xstr = FT_PIX_ROUND( xStrength ) >> 6;
- ystr = FT_PIX_ROUND( yStrength ) >> 6;
+ if ( ( ( FT_PIX_ROUND( xStrength ) >> 6 ) > FT_INT_MAX ) ||
+ ( ( FT_PIX_ROUND( yStrength ) >> 6 ) > FT_INT_MAX ) )
+ return FT_Err_Invalid_Argument;
+
+ xstr = (FT_Int)FT_PIX_ROUND( xStrength ) >> 6;
+ ystr = (FT_Int)FT_PIX_ROUND( yStrength ) >> 6;
if ( xstr == 0 && ystr == 0 )
return FT_Err_Ok;
diff --git a/src/base/ftcalc.c b/src/base/ftcalc.c
index 04295a6..3892fab 100644
--- a/src/base/ftcalc.c
+++ b/src/base/ftcalc.c
@@ -110,12 +110,12 @@
FT_EXPORT_DEF( FT_Int32 )
FT_Sqrt32( FT_Int32 x )
{
- FT_ULong val, root, newroot, mask;
+ FT_UInt32 val, root, newroot, mask;
root = 0;
- mask = 0x40000000L;
- val = (FT_ULong)x;
+ mask = (FT_UInt32)0x40000000UL;
+ val = (FT_UInt32)x;
do
{
@@ -362,6 +362,7 @@
long s;
+ /* XXX: this function does not allow 64-bit arguments */
if ( a == 0 || b == c )
return a;
@@ -377,12 +378,12 @@
FT_Int64 temp, temp2;
- ft_multo64( a, b, &temp );
+ ft_multo64( (FT_Int32)a, (FT_Int32)b, &temp );
temp2.hi = 0;
temp2.lo = (FT_UInt32)(c >> 1);
FT_Add64( &temp, &temp2, &temp );
- a = ft_div64by32( temp.hi, temp.lo, c );
+ a = ft_div64by32( temp.hi, temp.lo, (FT_Int32)c );
}
else
a = 0x7FFFFFFFL;
@@ -416,8 +417,8 @@
FT_Int64 temp;
- ft_multo64( a, b, &temp );
- a = ft_div64by32( temp.hi, temp.lo, c );
+ ft_multo64( (FT_Int32)a, (FT_Int32)b, &temp );
+ a = ft_div64by32( temp.hi, temp.lo, (FT_Int32)c );
}
else
a = 0x7FFFFFFFL;
@@ -539,13 +540,14 @@
FT_UInt32 q;
- s = a; a = FT_ABS( a );
- s ^= b; b = FT_ABS( b );
+ /* XXX: this function does not allow 64-bit arguments */
+ s = (FT_Int32)a; a = FT_ABS( a );
+ s ^= (FT_Int32)b; b = FT_ABS( b );
if ( b == 0 )
{
/* check for division by 0 */
- q = 0x7FFFFFFFL;
+ q = (FT_UInt32)0x7FFFFFFFL;
}
else if ( ( a >> 16 ) == 0 )
{
@@ -562,7 +564,7 @@
temp2.hi = 0;
temp2.lo = (FT_UInt32)( b >> 1 );
FT_Add64( &temp, &temp2, &temp );
- q = ft_div64by32( temp.hi, temp.lo, b );
+ q = ft_div64by32( temp.hi, temp.lo, (FT_Int32)b );
}
return ( s < 0 ? -(FT_Int32)q : (FT_Int32)q );
@@ -840,7 +842,7 @@
FT_Pos out_x,
FT_Pos out_y )
{
- FT_Int result;
+ FT_Long result; /* avoid overflow on 16-bit system */
/* deal with the trivial cases quickly */
@@ -889,8 +891,9 @@
FT_Int64 z1, z2;
- ft_multo64( in_x, out_y, &z1 );
- ft_multo64( in_y, out_x, &z2 );
+ /* XXX: this function does not allow 64-bit arguments */
+ ft_multo64( (FT_Int32)in_x, (FT_Int32)out_y, &z1 );
+ ft_multo64( (FT_Int32)in_y, (FT_Int32)out_x, &z2 );
if ( z1.hi > z2.hi )
result = +1;
@@ -906,7 +909,8 @@
#endif
}
- return result;
+ /* XXX: only the sign of return value, +1/0/-1 must be used */
+ return (FT_Int)result;
}
diff --git a/src/base/ftdbgmem.c b/src/base/ftdbgmem.c
index 8b2a330..160269d 100644
--- a/src/base/ftdbgmem.c
+++ b/src/base/ftdbgmem.c
@@ -421,7 +421,7 @@
"FreeType: %ld bytes of memory leaked in %ld blocks\n",
leaks, leak_count );
- printf( "FreeType: No memory leaks detected!\n" );
+ printf( "FreeType: no memory leaks detected\n" );
}
}
@@ -989,7 +989,7 @@
#else /* !FT_DEBUG_MEMORY */
/* ANSI C doesn't like empty source files */
- static const FT_Byte _debug_mem_dummy = 0;
+ typedef int _debug_mem_dummy;
#endif /* !FT_DEBUG_MEMORY */
diff --git a/src/base/ftgloadr.c b/src/base/ftgloadr.c
index ab52621..ac0010d 100644
--- a/src/base/ftgloadr.c
+++ b/src/base/ftgloadr.c
@@ -218,6 +218,9 @@
{
new_max = FT_PAD_CEIL( new_max, 8 );
+ if ( new_max > FT_OUTLINE_POINTS_MAX )
+ return FT_Err_Array_Too_Large;
+
if ( FT_RENEW_ARRAY( base->points, old_max, new_max ) ||
FT_RENEW_ARRAY( base->tags, old_max, new_max ) )
goto Exit;
@@ -246,6 +249,10 @@
if ( new_max > old_max )
{
new_max = FT_PAD_CEIL( new_max, 4 );
+
+ if ( new_max > FT_OUTLINE_CONTOURS_MAX )
+ return FT_Err_Array_Too_Large;
+
if ( FT_RENEW_ARRAY( base->contours, old_max, new_max ) )
goto Exit;
diff --git a/src/base/ftglyph.c b/src/base/ftglyph.c
index 4130cb1..3505d6d 100644
--- a/src/base/ftglyph.c
+++ b/src/base/ftglyph.c
@@ -34,6 +34,7 @@
#include FT_BITMAP_H
#include FT_INTERNAL_OBJECTS_H
+#include "basepic.h"
/*************************************************************************/
/* */
@@ -129,9 +130,7 @@
}
- FT_CALLBACK_TABLE_DEF
- const FT_Glyph_Class ft_bitmap_glyph_class =
- {
+ FT_DEFINE_GLYPH(ft_bitmap_glyph_class,
sizeof ( FT_BitmapGlyphRec ),
FT_GLYPH_FORMAT_BITMAP,
@@ -141,7 +140,7 @@
0, /* FT_Glyph_TransformFunc */
ft_bitmap_glyph_bbox,
0 /* FT_Glyph_PrepareFunc */
- };
+ )
/*************************************************************************/
@@ -255,9 +254,7 @@
}
- FT_CALLBACK_TABLE_DEF
- const FT_Glyph_Class ft_outline_glyph_class =
- {
+ FT_DEFINE_GLYPH( ft_outline_glyph_class,
sizeof ( FT_OutlineGlyphRec ),
FT_GLYPH_FORMAT_OUTLINE,
@@ -267,7 +264,7 @@
ft_outline_glyph_transform,
ft_outline_glyph_bbox,
ft_outline_glyph_prepare
- };
+ )
/*************************************************************************/
@@ -373,11 +370,11 @@
/* if it is a bitmap, that's easy :-) */
if ( slot->format == FT_GLYPH_FORMAT_BITMAP )
- clazz = &ft_bitmap_glyph_class;
+ clazz = FT_BITMAP_GLYPH_CLASS_GET;
- /* it it is an outline too */
+ /* if it is an outline */
else if ( slot->format == FT_GLYPH_FORMAT_OUTLINE )
- clazz = &ft_outline_glyph_class;
+ clazz = FT_OUTLINE_GLYPH_CLASS_GET;
else
{
@@ -518,6 +515,10 @@
const FT_Glyph_Class* clazz;
+#ifdef FT_CONFIG_OPTION_PIC
+ FT_Library library = FT_GLYPH( glyph )->library;
+#endif
+
/* check argument */
if ( !the_glyph )
@@ -533,7 +534,7 @@
clazz = glyph->clazz;
/* when called with a bitmap glyph, do nothing and return successfully */
- if ( clazz == &ft_bitmap_glyph_class )
+ if ( clazz == FT_BITMAP_GLYPH_CLASS_GET )
goto Exit;
if ( !clazz || !clazz->glyph_prepare )
@@ -546,7 +547,7 @@
dummy.format = clazz->glyph_format;
/* create result bitmap glyph */
- error = ft_new_glyph( glyph->library, &ft_bitmap_glyph_class,
+ error = ft_new_glyph( glyph->library, FT_BITMAP_GLYPH_CLASS_GET,
(FT_Glyph*)(void*)&bitmap );
if ( error )
goto Exit;
diff --git a/src/base/ftinit.c b/src/base/ftinit.c
index dac30b0..1914228 100644
--- a/src/base/ftinit.c
+++ b/src/base/ftinit.c
@@ -4,7 +4,7 @@
/* */
/* FreeType initialization layer (body). */
/* */
-/* Copyright 1996-2001, 2002, 2005, 2007 by */
+/* Copyright 1996-2001, 2002, 2005, 2007, 2009 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -42,6 +42,7 @@
#include FT_INTERNAL_OBJECTS_H
#include FT_INTERNAL_DEBUG_H
#include FT_MODULE_H
+#include "basepic.h"
/*************************************************************************/
@@ -53,6 +54,8 @@
#undef FT_COMPONENT
#define FT_COMPONENT trace_init
+#ifndef FT_CONFIG_OPTION_PIC
+
#undef FT_USE_MODULE
#ifdef __cplusplus
#define FT_USE_MODULE( type, x ) extern "C" const type x;
@@ -74,6 +77,99 @@
0
};
+#else /* FT_CONFIG_OPTION_PIC */
+
+#ifdef __cplusplus
+#define FT_EXTERNC extern "C"
+#else
+#define FT_EXTERNC extern
+#endif
+
+ /* declare the module's class creation/destruction functions */
+#undef FT_USE_MODULE
+#define FT_USE_MODULE( type, x ) \
+ FT_EXTERNC FT_Error FT_Create_Class_##x( FT_Library library, FT_Module_Class** output_class ); \
+ FT_EXTERNC void FT_Destroy_Class_##x( FT_Library library, FT_Module_Class* clazz );
+
+#include FT_CONFIG_MODULES_H
+
+
+ /* count all module classes */
+#undef FT_USE_MODULE
+#define FT_USE_MODULE( type, x ) MODULE_CLASS_##x,
+
+ enum {
+#include FT_CONFIG_MODULES_H
+ FT_NUM_MODULE_CLASSES
+ };
+
+ /* destroy all module classes */
+#undef FT_USE_MODULE
+#define FT_USE_MODULE( type, x ) \
+ if ( classes[i] ) { FT_Destroy_Class_##x(library, classes[i]); } \
+ i++; \
+
+ FT_BASE_DEF( void )
+ ft_destroy_default_module_classes( FT_Library library )
+ {
+ FT_Module_Class** classes;
+ FT_Memory memory;
+ FT_UInt i;
+ BasePIC* pic_container = (BasePIC*)library->pic_container.base;
+
+ if ( !pic_container->default_module_classes )
+ return;
+
+ memory = library->memory;
+ classes = pic_container->default_module_classes;
+ i = 0;
+
+#include FT_CONFIG_MODULES_H
+
+ FT_FREE( classes );
+ pic_container->default_module_classes = 0;
+ }
+
+ /* initialize all module classes and the pointer table */
+#undef FT_USE_MODULE
+#define FT_USE_MODULE( type, x ) \
+ error = FT_Create_Class_##x(library, &clazz); \
+ if (error) goto Exit; \
+ classes[i++] = clazz;
+
+ FT_BASE_DEF( FT_Error )
+ ft_create_default_module_classes( FT_Library library )
+ {
+ FT_Error error;
+ FT_Memory memory;
+ FT_Module_Class** classes;
+ FT_Module_Class* clazz;
+ FT_UInt i;
+ BasePIC* pic_container = (BasePIC*)library->pic_container.base;
+
+ memory = library->memory;
+ pic_container->default_module_classes = 0;
+
+ if ( FT_ALLOC(classes, sizeof(FT_Module_Class*) * (FT_NUM_MODULE_CLASSES + 1) ) )
+ return error;
+ /* initialize all pointers to 0, especially the last one */
+ for (i = 0; i < FT_NUM_MODULE_CLASSES; i++)
+ classes[i] = 0;
+ classes[FT_NUM_MODULE_CLASSES] = 0;
+
+ i = 0;
+
+#include FT_CONFIG_MODULES_H
+
+Exit:
+ if (error) ft_destroy_default_module_classes( library );
+ else pic_container->default_module_classes = classes;
+
+ return error;
+ }
+
+
+#endif /* FT_CONFIG_OPTION_PIC */
/* documentation is in ftmodapi.h */
@@ -86,16 +182,15 @@
/* test for valid `library' delayed to FT_Add_Module() */
- cur = ft_default_modules;
+ cur = FT_DEFAULT_MODULES_GET;
while ( *cur )
{
error = FT_Add_Module( library, *cur );
/* notify errors, but don't stop */
if ( error )
- {
- FT_ERROR(( "FT_Add_Default_Module: Cannot install `%s', error = 0x%x\n",
+ FT_TRACE0(( "FT_Add_Default_Module:"
+ " Cannot install `%s', error = 0x%x\n",
(*cur)->module_name, error ));
- }
cur++;
}
}
@@ -127,13 +222,7 @@
if ( error )
FT_Done_Memory( memory );
else
- {
- (*alibrary)->version_major = FREETYPE_MAJOR;
- (*alibrary)->version_minor = FREETYPE_MINOR;
- (*alibrary)->version_patch = FREETYPE_PATCH;
-
FT_Add_Default_Modules( *alibrary );
- }
return error;
}
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index 72dea33..a32b2cd 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -4,7 +4,8 @@
/* */
/* The FreeType private base classes (body). */
/* */
-/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
+/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, */
+/* 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -37,7 +38,9 @@
#include FT_SERVICE_KERNING_H
#include FT_SERVICE_TRUETYPE_ENGINE_H
+#ifdef FT_CONFIG_OPTION_MAC_FONTS
#include "ftbase.h"
+#endif
#define GRID_FIT_METRICS
@@ -348,6 +351,9 @@
/* free bitmap buffer if needed */
ft_glyphslot_free_bitmap( slot );
+ /* slot->internal might be NULL in out-of-memory situations */
+ if ( slot->internal )
+ {
/* free glyph loader */
if ( FT_DRIVER_USES_OUTLINES( driver ) )
{
@@ -356,6 +362,7 @@
}
FT_FREE( slot->internal );
+ }
}
@@ -588,17 +595,17 @@
* Determine whether we need to auto-hint or not.
* The general rules are:
*
- * - Do only auto-hinting if we have a hinter module,
- * a scalable font format dealing with outlines,
- * and no transforms except simple slants.
+ * - Do only auto-hinting if we have a hinter module, a scalable font
+ * format dealing with outlines, and no transforms except simple
+ * slants and/or rotations by integer multiples of 90 degrees.
*
- * - Then, autohint if FT_LOAD_FORCE_AUTOHINT is set
- * or if we don't have a native font hinter.
+ * - Then, auto-hint if FT_LOAD_FORCE_AUTOHINT is set or if we don't
+ * have a native font hinter.
*
* - Otherwise, auto-hint for LIGHT hinting mode.
*
- * - Exception: The font is `tricky' and requires
- * the native hinter to load properly.
+ * - Exception: The font is `tricky' and requires the native hinter to
+ * load properly.
*/
if ( hinter &&
@@ -607,8 +614,10 @@
FT_DRIVER_IS_SCALABLE( driver ) &&
FT_DRIVER_USES_OUTLINES( driver ) &&
!FT_IS_TRICKY( face ) &&
- face->internal->transform_matrix.yy > 0 &&
- face->internal->transform_matrix.yx == 0 )
+ ( ( face->internal->transform_matrix.yx == 0 &&
+ face->internal->transform_matrix.xx != 0 ) ||
+ ( face->internal->transform_matrix.xx == 0 &&
+ face->internal->transform_matrix.yx != 0 ) ) )
{
if ( ( load_flags & FT_LOAD_FORCE_AUTOHINT ) ||
!FT_DRIVER_HAS_HINTER( driver ) )
@@ -733,11 +742,30 @@
renderer, slot,
&internal->transform_matrix,
&internal->transform_delta );
+ else if ( slot->format == FT_GLYPH_FORMAT_OUTLINE )
+ {
+ /* apply `standard' transformation if no renderer is available */
+ if ( &internal->transform_matrix )
+ FT_Outline_Transform( &slot->outline,
+ &internal->transform_matrix );
+
+ if ( &internal->transform_delta )
+ FT_Outline_Translate( &slot->outline,
+ internal->transform_delta.x,
+ internal->transform_delta.y );
+ }
+
/* transform advance */
FT_Vector_Transform( &slot->advance, &internal->transform_matrix );
}
}
+ FT_TRACE5(( " x advance: %d\n" , slot->advance.x ));
+ FT_TRACE5(( " y advance: %d\n" , slot->advance.y ));
+
+ FT_TRACE5(( " linear x advance: %d\n" , slot->linearHoriAdvance ));
+ FT_TRACE5(( " linear y advance: %d\n" , slot->linearVertAdvance ));
+
/* do we need to render the image now? */
if ( !error &&
slot->format != FT_GLYPH_FORMAT_BITMAP &&
@@ -2398,12 +2426,24 @@
ft_synthesize_vertical_metrics( FT_Glyph_Metrics* metrics,
FT_Pos advance )
{
+ FT_Pos height = metrics->height;
+
+
+ /* compensate for glyph with bbox above/below the baseline */
+ if ( metrics->horiBearingY < 0 )
+ {
+ if ( height < metrics->horiBearingY )
+ height = metrics->horiBearingY;
+ }
+ else if ( metrics->horiBearingY > 0 )
+ height -= metrics->horiBearingY;
+
/* the factor 1.2 is a heuristical value */
if ( !advance )
- advance = metrics->height * 12 / 10;
+ advance = height * 12 / 10;
- metrics->vertBearingX = -( metrics->width / 2 );
- metrics->vertBearingY = ( advance - metrics->height ) / 2;
+ metrics->vertBearingX = metrics->horiBearingX - metrics->horiAdvance / 2;
+ metrics->vertBearingY = ( advance - height ) / 2;
metrics->vertAdvance = advance;
}
@@ -3048,7 +3088,12 @@
FT_CMap cmap = FT_CMAP( face->charmap );
- result = cmap->clazz->char_index( cmap, charcode );
+ if ( charcode > 0xFFFFFFFFUL )
+ {
+ FT_TRACE1(( "FT_Get_Char_Index: too large charcode" ));
+ FT_TRACE1(( " 0x%x is truncated\n", charcode ));
+ }
+ result = cmap->clazz->char_index( cmap, (FT_UInt32)charcode );
}
return result;
}
@@ -3128,8 +3173,20 @@
FT_CMap vcmap = FT_CMAP( charmap );
- result = vcmap->clazz->char_var_index( vcmap, ucmap, charcode,
- variantSelector );
+ if ( charcode > 0xFFFFFFFFUL )
+ {
+ FT_TRACE1(( "FT_Get_Char_Index: too large charcode" ));
+ FT_TRACE1(( " 0x%x is truncated\n", charcode ));
+ }
+ if ( variantSelector > 0xFFFFFFFFUL )
+ {
+ FT_TRACE1(( "FT_Get_Char_Index: too large variantSelector" ));
+ FT_TRACE1(( " 0x%x is truncated\n", variantSelector ));
+ }
+
+ result = vcmap->clazz->char_var_index( vcmap, ucmap,
+ (FT_UInt32)charcode,
+ (FT_UInt32)variantSelector );
}
}
@@ -3157,8 +3214,20 @@
FT_CMap vcmap = FT_CMAP( charmap );
- result = vcmap->clazz->char_var_default( vcmap, charcode,
- variantSelector );
+ if ( charcode > 0xFFFFFFFFUL )
+ {
+ FT_TRACE1(( "FT_Get_Char_Index: too large charcode" ));
+ FT_TRACE1(( " 0x%x is truncated\n", charcode ));
+ }
+ if ( variantSelector > 0xFFFFFFFFUL )
+ {
+ FT_TRACE1(( "FT_Get_Char_Index: too large variantSelector" ));
+ FT_TRACE1(( " 0x%x is truncated\n", variantSelector ));
+ }
+
+ result = vcmap->clazz->char_var_default( vcmap,
+ (FT_UInt32)charcode,
+ (FT_UInt32)variantSelector );
}
}
@@ -3213,7 +3282,14 @@
FT_Memory memory = FT_FACE_MEMORY( face );
- result = vcmap->clazz->charvariant_list( vcmap, memory, charcode );
+ if ( charcode > 0xFFFFFFFFUL )
+ {
+ FT_TRACE1(( "FT_Get_Char_Index: too large charcode" ));
+ FT_TRACE1(( " 0x%x is truncated\n", charcode ));
+ }
+
+ result = vcmap->clazz->charvariant_list( vcmap, memory,
+ (FT_UInt32)charcode );
}
}
return result;
@@ -3240,8 +3316,14 @@
FT_Memory memory = FT_FACE_MEMORY( face );
+ if ( variantSelector > 0xFFFFFFFFUL )
+ {
+ FT_TRACE1(( "FT_Get_Char_Index: too large variantSelector" ));
+ FT_TRACE1(( " 0x%x is truncated\n", variantSelector ));
+ }
+
result = vcmap->clazz->variantchar_list( vcmap, memory,
- variantSelector );
+ (FT_UInt32)variantSelector );
}
}
@@ -3291,7 +3373,7 @@
((FT_Byte*)buffer)[0] = 0;
if ( face &&
- glyph_index <= (FT_UInt)face->num_glyphs &&
+ (FT_Long)glyph_index <= face->num_glyphs &&
FT_HAS_GLYPH_NAMES( face ) )
{
FT_Service_GlyphDict service;
@@ -3391,6 +3473,7 @@
FT_ULong *length )
{
FT_Service_SFNT_Table service;
+ FT_ULong offset;
if ( !face || !FT_IS_SFNT( face ) )
@@ -3400,7 +3483,7 @@
if ( service == NULL )
return FT_Err_Unimplemented_Feature;
- return service->table_info( face, table_index, tag, length );
+ return service->table_info( face, table_index, tag, &offset, length );
}
@@ -4123,6 +4206,13 @@
library->memory = memory;
+#ifdef FT_CONFIG_OPTION_PIC
+ /* initialize position independent code containers */
+ error = ft_pic_container_init( library );
+ if ( error )
+ goto Fail;
+#endif
+
/* allocate the render pool */
library->raster_pool_size = FT_RENDER_POOL_SIZE;
#if FT_RENDER_POOL_SIZE > 0
@@ -4130,12 +4220,19 @@
goto Fail;
#endif
+ library->version_major = FREETYPE_MAJOR;
+ library->version_minor = FREETYPE_MINOR;
+ library->version_patch = FREETYPE_PATCH;
+
/* That's ok now */
*alibrary = library;
return FT_Err_Ok;
Fail:
+#ifdef FT_CONFIG_OPTION_PIC
+ ft_pic_container_destroy( library );
+#endif
FT_FREE( library );
return error;
}
@@ -4216,7 +4313,7 @@
{
FT_Done_Face( FT_FACE( faces->head->data ) );
if ( faces->head )
- FT_ERROR(( "FT_Done_Library: failed to free some faces\n" ));
+ FT_TRACE0(( "FT_Done_Library: failed to free some faces\n" ));
}
}
}
@@ -4252,6 +4349,11 @@
FT_FREE( library->raster_pool );
library->raster_pool_size = 0;
+#ifdef FT_CONFIG_OPTION_PIC
+ /* Destroy pic container contents */
+ ft_pic_container_destroy( library );
+#endif
+
FT_FREE( library );
return FT_Err_Ok;
}
diff --git a/src/base/ftoutln.c b/src/base/ftoutln.c
index 49ef82e..5bb6ef3 100644
--- a/src/base/ftoutln.c
+++ b/src/base/ftoutln.c
@@ -4,7 +4,7 @@
/* */
/* FreeType outline management (body). */
/* */
-/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 by */
+/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -304,7 +304,7 @@
*anoutline = null_outline;
- if ( FT_NEW_ARRAY( anoutline->points, numPoints * 2L ) ||
+ if ( FT_NEW_ARRAY( anoutline->points, numPoints ) ||
FT_NEW_ARRAY( anoutline->tags, numPoints ) ||
FT_NEW_ARRAY( anoutline->contours, numContours ) )
goto Fail;
diff --git a/src/base/ftpatent.c b/src/base/ftpatent.c
index 9f129d8..af29786 100644
--- a/src/base/ftpatent.c
+++ b/src/base/ftpatent.c
@@ -5,7 +5,7 @@
/* FreeType API for checking patented TrueType bytecode instructions */
/* (body). */
/* */
-/* Copyright 2007, 2008 by David Turner. */
+/* Copyright 2007, 2008, 2010 by David Turner. */
/* */
/* This file is part of the FreeType project, and may only be used, */
/* modified, and distributed under the terms of the FreeType project */
@@ -103,6 +103,7 @@
}
Exit:
+ FT_UNUSED( error );
FT_FRAME_EXIT();
return result;
}
@@ -113,7 +114,7 @@
FT_ULong tag )
{
FT_Stream stream = face->stream;
- FT_Error error;
+ FT_Error error = FT_Err_Ok;
FT_Service_SFNT_Table service;
FT_Bool result = FALSE;
@@ -122,15 +123,19 @@
if ( service )
{
- FT_ULong offset, size;
+ FT_UInt i = 0;
+ FT_ULong tag_i = 0, offset_i = 0, length_i = 0;
- error = service->table_info( face, tag, &offset, &size );
+ for ( i = 0; !error && tag_i != tag ; i++ )
+ error = service->table_info( face, i,
+ &tag_i, &offset_i, &length_i );
+
if ( error ||
- FT_STREAM_SEEK( offset ) )
+ FT_STREAM_SEEK( offset_i ) )
goto Exit;
- result = _tt_check_patents_in_range( stream, size );
+ result = _tt_check_patents_in_range( stream, length_i );
}
Exit:
diff --git a/src/base/ftpic.c b/src/base/ftpic.c
new file mode 100644
index 0000000..d5271a9
--- /dev/null
+++ b/src/base/ftpic.c
@@ -0,0 +1,54 @@
+/***************************************************************************/
+/* */
+/* ftpic.c */
+/* */
+/* The FreeType position independent code services (body). */
+/* */
+/* Copyright 2009 by */
+/* Oran Agra and Mickey Gabel. */
+/* */
+/* This file is part of the FreeType project, and may only be used, */
+/* modified, and distributed under the terms of the FreeType project */
+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
+/* this file you indicate that you have read the license and */
+/* understand and accept it fully. */
+/* */
+/***************************************************************************/
+
+
+#include <ft2build.h>
+#include FT_FREETYPE_H
+#include FT_INTERNAL_OBJECTS_H
+#include "basepic.h"
+
+#ifdef FT_CONFIG_OPTION_PIC
+
+ /* documentation is in ftpic.h */
+
+ FT_BASE_DEF( FT_Error )
+ ft_pic_container_init( FT_Library library )
+ {
+ FT_PIC_Container* pic_container = &library->pic_container;
+ FT_Error error = FT_Err_Ok;
+
+ FT_MEM_SET( pic_container, 0, sizeof(*pic_container) );
+
+ error = ft_base_pic_init( library );
+ if(error)
+ return error;
+
+ return FT_Err_Ok;
+ }
+
+
+ /* Destroy the contents of the container. */
+ FT_BASE_DEF( void )
+ ft_pic_container_destroy( FT_Library library )
+ {
+ ft_base_pic_free( library );
+ }
+
+#endif /* FT_CONFIG_OPTION_PIC */
+
+
+/* END */
diff --git a/src/base/ftrfork.c b/src/base/ftrfork.c
index d59a076..133c2de 100644
--- a/src/base/ftrfork.c
+++ b/src/base/ftrfork.c
@@ -752,9 +752,9 @@
const char *insertion )
{
char* new_name;
- char* tmp;
+ const char* tmp;
const char* slash;
- unsigned new_length;
+ size_t new_length;
FT_Error error = FT_Err_Ok;
FT_UNUSED( error );
diff --git a/src/base/ftnames.c b/src/base/ftsnames.c
index 7fde5c4..3447888 100644
--- a/src/base/ftnames.c
+++ b/src/base/ftsnames.c
@@ -1,13 +1,13 @@
/***************************************************************************/
/* */
-/* ftnames.c */
+/* ftsnames.c */
/* */
/* Simple interface to access SFNT name tables (which are used */
/* to hold font names, copyright info, notices, etc.) (body). */
/* */
/* This is _not_ used to retrieve glyph names! */
/* */
-/* Copyright 1996-2001, 2002 by */
+/* Copyright 1996-2001, 2002, 2009 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -28,16 +28,16 @@
#ifdef TT_CONFIG_OPTION_SFNT_NAMES
- /* documentation is in ftnames.h */
+ /* documentation is in ftsnames.h */
FT_EXPORT_DEF( FT_UInt )
FT_Get_Sfnt_Name_Count( FT_Face face )
{
- return (face && FT_IS_SFNT( face )) ? ((TT_Face)face)->num_names : 0;
+ return ( face && FT_IS_SFNT( face ) ) ? ((TT_Face)face)->num_names : 0;
}
- /* documentation is in ftnames.h */
+ /* documentation is in ftsnames.h */
FT_EXPORT_DEF( FT_Error )
FT_Get_Sfnt_Name( FT_Face face,
diff --git a/src/base/ftstream.c b/src/base/ftstream.c
index cff67e0..b638599 100644
--- a/src/base/ftstream.c
+++ b/src/base/ftstream.c
@@ -4,7 +4,7 @@
/* */
/* I/O stream support (body). */
/* */
-/* Copyright 2000-2001, 2002, 2004, 2005, 2006, 2008 by */
+/* Copyright 2000-2001, 2002, 2004, 2005, 2006, 2008, 2009 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -60,13 +60,12 @@
FT_Error error = FT_Err_Ok;
- stream->pos = pos;
-
if ( stream->read )
{
if ( stream->read( stream, pos, 0, 0 ) )
{
- FT_ERROR(( "FT_Stream_Seek: invalid i/o; pos = 0x%lx, size = 0x%lx\n",
+ FT_ERROR(( "FT_Stream_Seek:"
+ " invalid i/o; pos = 0x%lx, size = 0x%lx\n",
pos, stream->size ));
error = FT_Err_Invalid_Stream_Operation;
@@ -75,12 +74,16 @@
/* note that seeking to the first position after the file is valid */
else if ( pos > stream->size )
{
- FT_ERROR(( "FT_Stream_Seek: invalid i/o; pos = 0x%lx, size = 0x%lx\n",
+ FT_ERROR(( "FT_Stream_Seek:"
+ " invalid i/o; pos = 0x%lx, size = 0x%lx\n",
pos, stream->size ));
error = FT_Err_Invalid_Stream_Operation;
}
+ if ( !error )
+ stream->pos = pos;
+
return error;
}
@@ -124,7 +127,8 @@
if ( pos >= stream->size )
{
- FT_ERROR(( "FT_Stream_ReadAt: invalid i/o; pos = 0x%lx, size = 0x%lx\n",
+ FT_ERROR(( "FT_Stream_ReadAt:"
+ " invalid i/o; pos = 0x%lx, size = 0x%lx\n",
pos, stream->size ));
return FT_Err_Invalid_Stream_Operation;
@@ -145,8 +149,8 @@
if ( read_bytes < count )
{
- FT_ERROR(( "FT_Stream_ReadAt:" ));
- FT_ERROR(( " invalid read; expected %lu bytes, got %lu\n",
+ FT_ERROR(( "FT_Stream_ReadAt:"
+ " invalid read; expected %lu bytes, got %lu\n",
count, read_bytes ));
error = FT_Err_Invalid_Stream_Operation;
@@ -211,7 +215,7 @@
FT_Stream_ReleaseFrame( FT_Stream stream,
FT_Byte** pbytes )
{
- if ( stream->read )
+ if ( stream && stream->read )
{
FT_Memory memory = stream->memory;
@@ -256,8 +260,8 @@
stream->base, count );
if ( read_bytes < count )
{
- FT_ERROR(( "FT_Stream_EnterFrame:" ));
- FT_ERROR(( " invalid read; expected %lu bytes, got %lu\n",
+ FT_ERROR(( "FT_Stream_EnterFrame:"
+ " invalid read; expected %lu bytes, got %lu\n",
count, read_bytes ));
FT_FREE( stream->base );
@@ -273,8 +277,8 @@
if ( stream->pos >= stream->size ||
stream->pos + count > stream->size )
{
- FT_ERROR(( "FT_Stream_EnterFrame:" ));
- FT_ERROR(( " invalid i/o; pos = 0x%lx, count = %lu, size = 0x%lx\n",
+ FT_ERROR(( "FT_Stream_EnterFrame:"
+ " invalid i/o; pos = 0x%lx, count = %lu, size = 0x%lx\n",
stream->pos, count, stream->size ));
error = FT_Err_Invalid_Stream_Operation;
@@ -459,7 +463,8 @@
Fail:
*error = FT_Err_Invalid_Stream_Operation;
- FT_ERROR(( "FT_Stream_ReadChar: invalid i/o; pos = 0x%lx, size = 0x%lx\n",
+ FT_ERROR(( "FT_Stream_ReadChar:"
+ " invalid i/o; pos = 0x%lx, size = 0x%lx\n",
stream->pos, stream->size ));
return 0;
@@ -505,8 +510,8 @@
Fail:
*error = FT_Err_Invalid_Stream_Operation;
- FT_ERROR(( "FT_Stream_ReadShort:" ));
- FT_ERROR(( " invalid i/o; pos = 0x%lx, size = 0x%lx\n",
+ FT_ERROR(( "FT_Stream_ReadShort:"
+ " invalid i/o; pos = 0x%lx, size = 0x%lx\n",
stream->pos, stream->size ));
return 0;
@@ -552,8 +557,8 @@
Fail:
*error = FT_Err_Invalid_Stream_Operation;
- FT_ERROR(( "FT_Stream_ReadShortLE:" ));
- FT_ERROR(( " invalid i/o; pos = 0x%lx, size = 0x%lx\n",
+ FT_ERROR(( "FT_Stream_ReadShortLE:"
+ " invalid i/o; pos = 0x%lx, size = 0x%lx\n",
stream->pos, stream->size ));
return 0;
@@ -599,8 +604,8 @@
Fail:
*error = FT_Err_Invalid_Stream_Operation;
- FT_ERROR(( "FT_Stream_ReadOffset:" ));
- FT_ERROR(( " invalid i/o; pos = 0x%lx, size = 0x%lx\n",
+ FT_ERROR(( "FT_Stream_ReadOffset:"
+ " invalid i/o; pos = 0x%lx, size = 0x%lx\n",
stream->pos, stream->size ));
return 0;
@@ -645,9 +650,10 @@
return result;
Fail:
- FT_ERROR(( "FT_Stream_ReadLong: invalid i/o; pos = 0x%lx, size = 0x%lx\n",
- stream->pos, stream->size ));
*error = FT_Err_Invalid_Stream_Operation;
+ FT_ERROR(( "FT_Stream_ReadLong:"
+ " invalid i/o; pos = 0x%lx, size = 0x%lx\n",
+ stream->pos, stream->size ));
return 0;
}
@@ -691,10 +697,10 @@
return result;
Fail:
- FT_ERROR(( "FT_Stream_ReadLongLE:" ));
- FT_ERROR(( " invalid i/o; pos = 0x%lx, size = 0x%lx\n",
- stream->pos, stream->size ));
*error = FT_Err_Invalid_Stream_Operation;
+ FT_ERROR(( "FT_Stream_ReadLongLE:"
+ " invalid i/o; pos = 0x%lx, size = 0x%lx\n",
+ stream->pos, stream->size ));
return 0;
}
diff --git a/src/base/ftstroke.c b/src/base/ftstroke.c
index 3f5421f..75bcbde 100644
--- a/src/base/ftstroke.c
+++ b/src/base/ftstroke.c
@@ -4,7 +4,7 @@
/* */
/* FreeType path stroker (body). */
/* */
-/* Copyright 2002, 2003, 2004, 2005, 2006, 2008, 2009 by */
+/* Copyright 2002, 2003, 2004, 2005, 2006, 2008, 2009, 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -706,7 +706,7 @@
FT_Bool valid;
FT_StrokeBorderRec borders[2];
- FT_Memory memory;
+ FT_Library library;
} FT_StrokerRec;
@@ -729,7 +729,7 @@
if ( !FT_NEW( stroker ) )
{
- stroker->memory = memory;
+ stroker->library = library;
ft_stroke_border_init( &stroker->borders[0], memory );
ft_stroke_border_init( &stroker->borders[1], memory );
@@ -777,13 +777,13 @@
{
if ( stroker )
{
- FT_Memory memory = stroker->memory;
+ FT_Memory memory = stroker->library->memory;
ft_stroke_border_done( &stroker->borders[0] );
ft_stroke_border_done( &stroker->borders[1] );
- stroker->memory = NULL;
+ stroker->library = NULL;
FT_FREE( stroker );
}
}
@@ -859,6 +859,31 @@
error = ft_stroke_border_lineto( border, &delta, FALSE );
}
+ else if ( stroker->line_cap == FT_STROKER_LINECAP_BUTT )
+ {
+ /* add a butt ending */
+ FT_Vector delta;
+ FT_Angle rotate = FT_SIDE_TO_ROTATE( side );
+ FT_Fixed radius = stroker->radius;
+ FT_StrokeBorder border = stroker->borders + side;
+
+
+ FT_Vector_From_Polar( &delta, radius, angle + rotate );
+
+ delta.x += stroker->center.x;
+ delta.y += stroker->center.y;
+
+ error = ft_stroke_border_lineto( border, &delta, FALSE );
+ if ( error )
+ goto Exit;
+
+ FT_Vector_From_Polar( &delta, radius, angle - rotate );
+
+ delta.x += stroker->center.x;
+ delta.y += stroker->center.y;
+
+ error = ft_stroke_border_lineto( border, &delta, FALSE );
+ }
Exit:
return error;
@@ -954,7 +979,8 @@
thcos = FT_Cos( theta );
sigma = FT_MulFix( stroker->miter_limit, thcos );
- if ( sigma >= 0x10000L )
+ /* FT_Sin(x) = 0 for x <= 57 */
+ if ( sigma >= 0x10000L || ft_pos_abs( theta ) <= 57 )
miter = FALSE;
if ( miter ) /* this is a miter (broken angle) */
@@ -1335,7 +1361,7 @@
phi1 = (angle_mid + angle_in ) / 2;
phi2 = (angle_mid + angle_out ) / 2;
length1 = FT_DivFix( stroker->radius, FT_Cos( theta1 ) );
- length2 = FT_DivFix( stroker->radius, FT_Cos(theta2) );
+ length2 = FT_DivFix( stroker->radius, FT_Cos( theta2 ) );
for ( side = 0; side <= 1; side++ )
{
@@ -1710,13 +1736,10 @@
}
else
{
- /* if both first and last points are conic, */
- /* start at their middle and record its position */
- /* for closure */
+ /* if both first and last points are conic, */
+ /* start at their middle */
v_start.x = ( v_start.x + v_last.x ) / 2;
v_start.y = ( v_start.y + v_last.y ) / 2;
-
- v_last = v_start;
}
point--;
tags--;
@@ -1844,8 +1867,13 @@
return FT_Err_Invalid_Outline;
}
-
+/* declare an extern to access ft_outline_glyph_class global allocated
+ in ftglyph.c, and use the FT_OUTLINE_GLYPH_CLASS_GET macro to access
+ it when FT_CONFIG_OPTION_PIC is defined */
+#ifndef FT_CONFIG_OPTION_PIC
extern const FT_Glyph_Class ft_outline_glyph_class;
+#endif
+#include "basepic.h"
/* documentation is in ftstroke.h */
@@ -1857,13 +1885,14 @@
{
FT_Error error = FT_Err_Invalid_Argument;
FT_Glyph glyph = NULL;
-
+ FT_Library library = stroker->library;
+ FT_UNUSED(library);
if ( pglyph == NULL )
goto Exit;
glyph = *pglyph;
- if ( glyph == NULL || glyph->clazz != &ft_outline_glyph_class )
+ if ( glyph == NULL || glyph->clazz != FT_OUTLINE_GLYPH_CLASS_GET )
goto Exit;
{
@@ -1930,13 +1959,14 @@
{
FT_Error error = FT_Err_Invalid_Argument;
FT_Glyph glyph = NULL;
-
+ FT_Library library = stroker->library;
+ FT_UNUSED(library);
if ( pglyph == NULL )
goto Exit;
glyph = *pglyph;
- if ( glyph == NULL || glyph->clazz != &ft_outline_glyph_class )
+ if ( glyph == NULL || glyph->clazz != FT_OUTLINE_GLYPH_CLASS_GET )
goto Exit;
{
diff --git a/src/base/ftsynth.c b/src/base/ftsynth.c
index 443d272..ba3c633 100644
--- a/src/base/ftsynth.c
+++ b/src/base/ftsynth.c
@@ -4,7 +4,7 @@
/* */
/* FreeType synthesizing code for emboldening and slanting (body). */
/* */
-/* Copyright 2000-2001, 2002, 2003, 2004, 2005, 2006 by */
+/* Copyright 2000-2001, 2002, 2003, 2004, 2005, 2006, 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -18,12 +18,22 @@
#include <ft2build.h>
#include FT_SYNTHESIS_H
+#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_OBJECTS_H
#include FT_OUTLINE_H
#include FT_BITMAP_H
/*************************************************************************/
+ /* */
+ /* The macro FT_COMPONENT is used in trace mode. It is an implicit */
+ /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
+ /* messages during execution. */
+ /* */
+#undef FT_COMPONENT
+#define FT_COMPONENT trace_synth
+
+ /*************************************************************************/
/*************************************************************************/
/**** ****/
/**** EXPERIMENTAL OBLIQUING SUPPORT ****/
@@ -90,8 +100,8 @@
if ( slot->format == FT_GLYPH_FORMAT_OUTLINE )
{
- error = FT_Outline_Embolden( &slot->outline, xstr );
/* ignore error */
+ (void)FT_Outline_Embolden( &slot->outline, xstr );
/* this is more than enough for most glyphs; if you need accurate */
/* values, you have to call FT_Outline_Get_CBox */
@@ -106,6 +116,18 @@
xstr = 1 << 6;
ystr &= ~63;
+ /*
+ * XXX: overflow check for 16-bit system, for compatibility
+ * with FT_GlyphSlot_Embolden() since freetype-2.1.10.
+ * unfortunately, this function return no informations
+ * about the cause of error.
+ */
+ if ( ( ystr >> 6 ) > FT_INT_MAX || ( ystr >> 6 ) < FT_INT_MIN )
+ {
+ FT_TRACE1(( "FT_GlyphSlot_Embolden:" ));
+ FT_TRACE1(( "too strong embolding parameter ystr=%d\n", ystr ));
+ return;
+ }
error = FT_GlyphSlot_Own_Bitmap( slot );
if ( error )
return;
@@ -129,8 +151,9 @@
slot->metrics.vertBearingY += ystr;
slot->metrics.vertAdvance += ystr;
+ /* XXX: 16-bit overflow case must be excluded before here */
if ( slot->format == FT_GLYPH_FORMAT_BITMAP )
- slot->bitmap_top += ystr >> 6;
+ slot->bitmap_top += (FT_Int)( ystr >> 6 );
}
diff --git a/src/base/ftsystem.c b/src/base/ftsystem.c
index f64908f..4d06d6d 100644
--- a/src/base/ftsystem.c
+++ b/src/base/ftsystem.c
@@ -4,7 +4,7 @@
/* */
/* ANSI-specific FreeType low-level system interface (body). */
/* */
-/* Copyright 1996-2001, 2002, 2006, 2008 by */
+/* Copyright 1996-2001, 2002, 2006, 2008, 2009 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -205,7 +205,8 @@
file = STREAM_FILE( stream );
- ft_fseek( file, offset, SEEK_SET );
+ if ( stream->pos != offset )
+ ft_fseek( file, offset, SEEK_SET );
return (unsigned long)ft_fread( buffer, 1, count, file );
}
@@ -226,8 +227,8 @@
file = ft_fopen( filepathname, "rb" );
if ( !file )
{
- FT_ERROR(( "FT_Stream_Open:" ));
- FT_ERROR(( " could not open `%s'\n", filepathname ));
+ FT_ERROR(( "FT_Stream_Open:"
+ " could not open `%s'\n", filepathname ));
return FT_Err_Cannot_Open_Resource;
}
diff --git a/src/base/fttrigon.c b/src/base/fttrigon.c
index 9f51394..fdf433a 100644
--- a/src/base/fttrigon.c
+++ b/src/base/fttrigon.c
@@ -72,10 +72,10 @@
val = ( val >= 0 ) ? val : -val;
v1 = (FT_UInt32)val >> 16;
- v2 = (FT_UInt32)val & 0xFFFFL;
+ v2 = (FT_UInt32)(val & 0xFFFFL);
- k1 = FT_TRIG_SCALE >> 16; /* constant */
- k2 = FT_TRIG_SCALE & 0xFFFFL; /* constant */
+ k1 = (FT_UInt32)FT_TRIG_SCALE >> 16; /* constant */
+ k2 = (FT_UInt32)(FT_TRIG_SCALE & 0xFFFFL); /* constant */
hi = k1 * v1;
lo1 = k1 * v2 + k2 * v1; /* can't overflow */
@@ -86,7 +86,7 @@
hi += lo1 >> 16;
if ( lo1 < lo3 )
- hi += 0x10000UL;
+ hi += (FT_UInt32)0x10000UL;
val = (FT_Fixed)hi;
@@ -433,7 +433,7 @@
if ( shift > 0 )
{
- FT_Int32 half = 1L << ( shift - 1 );
+ FT_Int32 half = (FT_Int32)1L << ( shift - 1 );
vec->x = ( v.x + half + FT_SIGN_LONG( v.x ) ) >> shift;