updated freetype to 2.3.11

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33650 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Scott McCreary 2009-10-19 07:03:46 +00:00
parent 3221645ea1
commit f1b1e2fc9a
208 changed files with 6763 additions and 2125 deletions

View File

@ -4,7 +4,7 @@
/* */ /* */
/* User-selectable configuration macros (specification only). */ /* User-selectable configuration macros (specification only). */
/* */ /* */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 by */ /* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */ /* */
/* This file is part of the FreeType project, and may only be used, */ /* This file is part of the FreeType project, and may only be used, */
@ -92,9 +92,7 @@ FT_BEGIN_HEADER
/* This is done to allow FreeType clients to run unmodified, forcing */ /* This is done to allow FreeType clients to run unmodified, forcing */
/* them to display normal gray-level anti-aliased glyphs. */ /* them to display normal gray-level anti-aliased glyphs. */
/* */ /* */
#if HAIKU_INCLUDE_PATENTED_CODE /* #define FT_CONFIG_OPTION_SUBPIXEL_RENDERING */
# define FT_CONFIG_OPTION_SUBPIXEL_RENDERING
#endif
/*************************************************************************/ /*************************************************************************/
@ -398,6 +396,20 @@ FT_BEGIN_HEADER
#undef FT_CONFIG_OPTION_USE_MODULE_ERRORS #undef FT_CONFIG_OPTION_USE_MODULE_ERRORS
/*************************************************************************/
/* */
/* Position Independent Code */
/* */
/* If this macro is set (which is _not_ the default), FreeType2 will */
/* avoid creating constants that require address fixups. Instead the */
/* constants will be moved into a struct and additional intialization */
/* code will be used. */
/* */
/* Setting this macro is needed for systems that prohibit address */
/* fixups, such as BREW. */
/* */
/* #define FT_CONFIG_OPTION_PIC */
/*************************************************************************/ /*************************************************************************/
/*************************************************************************/ /*************************************************************************/
@ -441,7 +453,7 @@ FT_BEGIN_HEADER
/* does not contain any glyph name though. */ /* does not contain any glyph name though. */
/* */ /* */
/* Accessing SFNT names is done through the functions declared in */ /* Accessing SFNT names is done through the functions declared in */
/* `freetype/ftnames.h'. */ /* `freetype/ftsnames.h'. */
/* */ /* */
#define TT_CONFIG_OPTION_SFNT_NAMES #define TT_CONFIG_OPTION_SFNT_NAMES
@ -459,6 +471,7 @@ FT_BEGIN_HEADER
#define TT_CONFIG_CMAP_FORMAT_8 #define TT_CONFIG_CMAP_FORMAT_8
#define TT_CONFIG_CMAP_FORMAT_10 #define TT_CONFIG_CMAP_FORMAT_10
#define TT_CONFIG_CMAP_FORMAT_12 #define TT_CONFIG_CMAP_FORMAT_12
#define TT_CONFIG_CMAP_FORMAT_13
#define TT_CONFIG_CMAP_FORMAT_14 #define TT_CONFIG_CMAP_FORMAT_14
@ -482,9 +495,7 @@ FT_BEGIN_HEADER
/* Do not #undef this macro here, since the build system might */ /* Do not #undef this macro here, since the build system might */
/* define it for certain configurations only. */ /* define it for certain configurations only. */
/* */ /* */
#if HAIKU_INCLUDE_PATENTED_CODE /* #define TT_CONFIG_OPTION_BYTECODE_INTERPRETER */
# define TT_CONFIG_OPTION_BYTECODE_INTERPRETER
#endif
/*************************************************************************/ /*************************************************************************/

View File

@ -61,6 +61,7 @@
#define FT_CHAR_BIT CHAR_BIT #define FT_CHAR_BIT CHAR_BIT
#define FT_INT_MAX INT_MAX #define FT_INT_MAX INT_MAX
#define FT_INT_MIN INT_MIN
#define FT_UINT_MAX UINT_MAX #define FT_UINT_MAX UINT_MAX
#define FT_ULONG_MAX ULONG_MAX #define FT_ULONG_MAX ULONG_MAX

View File

@ -519,10 +519,7 @@ FT_BEGIN_HEADER
/* <Note> */ /* <Note> */
/* Despite the name, this enumeration lists specific character */ /* Despite the name, this enumeration lists specific character */
/* repertories (i.e., charsets), and not text encoding methods (e.g., */ /* repertories (i.e., charsets), and not text encoding methods (e.g., */
/* UTF-8, UTF-16, GB2312_EUC, etc.). */ /* UTF-8, UTF-16, etc.). */
/* */
/* Because of 32-bit charcodes defined in Unicode (i.e., surrogates), */
/* all character codes must be expressed as FT_Longs. */
/* */ /* */
/* Other encodings might be defined in the future. */ /* Other encodings might be defined in the future. */
/* */ /* */
@ -536,6 +533,10 @@ FT_BEGIN_HEADER
/* Latin-1. Most fonts include a Unicode charmap, but not all */ /* Latin-1. Most fonts include a Unicode charmap, but not all */
/* of them. */ /* of them. */
/* */ /* */
/* For example, if you want to access Unicode value U+1F028 (and */
/* the font contains it), use value 0x1F028 as the input value for */
/* @FT_Get_Char_Index. */
/* */
/* FT_ENCODING_MS_SYMBOL :: */ /* FT_ENCODING_MS_SYMBOL :: */
/* Corresponds to the Microsoft Symbol encoding, used to encode */ /* Corresponds to the Microsoft Symbol encoding, used to encode */
/* mathematical symbols in the 32..255 character code range. For */ /* mathematical symbols in the 32..255 character code range. For */
@ -1651,6 +1652,11 @@ FT_BEGIN_HEADER
/* <Return> */ /* <Return> */
/* FreeType error code. 0~means success. */ /* FreeType error code. 0~means success. */
/* */ /* */
/* <Note> */
/* In case you want to provide your own memory allocating routines, */
/* use @FT_New_Library instead, followed by a call to */
/* @FT_Add_Default_Modules (or a series of calls to @FT_Add_Module). */
/* */
FT_EXPORT( FT_Error ) FT_EXPORT( FT_Error )
FT_Init_FreeType( FT_Library *alibrary ); FT_Init_FreeType( FT_Library *alibrary );
@ -3757,7 +3763,7 @@ FT_BEGIN_HEADER
*/ */
#define FREETYPE_MAJOR 2 #define FREETYPE_MAJOR 2
#define FREETYPE_MINOR 3 #define FREETYPE_MINOR 3
#define FREETYPE_PATCH 9 #define FREETYPE_PATCH 11
/*************************************************************************/ /*************************************************************************/

View File

@ -5,7 +5,7 @@
/* FreeType glyph image formats and default raster interface */ /* FreeType glyph image formats and default raster interface */
/* (specification). */ /* (specification). */
/* */ /* */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 by */ /* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */ /* */
/* This file is part of the FreeType project, and may only be used, */ /* This file is part of the FreeType project, and may only be used, */
@ -318,14 +318,23 @@ FT_BEGIN_HEADER
/* elements, giving the outline's point coordinates. */ /* elements, giving the outline's point coordinates. */
/* */ /* */
/* tags :: A pointer to an array of `n_points' chars, giving */ /* tags :: A pointer to an array of `n_points' chars, giving */
/* each outline point's type. If bit~0 is unset, the */ /* each outline point's type. */
/* point is `off' the curve, i.e., a Bézier control */ /* */
/* point, while it is `on' when set. */ /* If bit~0 is unset, the point is `off' the curve, */
/* i.e., a Bézier control point, while it is `on' if */
/* set. */
/* */ /* */
/* Bit~1 is meaningful for `off' points only. If set, */ /* Bit~1 is meaningful for `off' points only. If set, */
/* it indicates a third-order Bézier arc control point; */ /* it indicates a third-order Bézier arc control point; */
/* and a second-order control point if unset. */ /* and a second-order control point if unset. */
/* */ /* */
/* If bit~2 is set, bits 5-7 contain the drop-out mode */
/* (as defined in the OpenType specification; the value */
/* is the same as the argument to the SCANMODE */
/* instruction). */
/* */
/* Bits 3 and~4 are reserved for internal purposes. */
/* */
/* contours :: An array of `n_contours' shorts, giving the end */ /* contours :: An array of `n_contours' shorts, giving the end */
/* point of each contour within the outline. For */ /* point of each contour within the outline. For */
/* example, the first contour is defined by the points */ /* example, the first contour is defined by the points */
@ -336,6 +345,12 @@ FT_BEGIN_HEADER
/* and give hints to the scan-converter and hinter on */ /* and give hints to the scan-converter and hinter on */
/* how to convert/grid-fit it. See @FT_OUTLINE_FLAGS. */ /* how to convert/grid-fit it. See @FT_OUTLINE_FLAGS. */
/* */ /* */
/* <Note> */
/* The B/W rasterizer only checks bit~2 in the `tags' array for the */
/* first point of each contour. The drop-out mode as given with */
/* @FT_OUTLINE_IGNORE_DROPOUTS, @FT_OUTLINE_SMART_DROPOUTS, and */
/* @FT_OUTLINE_INCLUDE_STUBS in `flags' is then overridden. */
/* */
typedef struct FT_Outline_ typedef struct FT_Outline_
{ {
short n_contours; /* number of contours in glyph */ short n_contours; /* number of contours in glyph */
@ -349,6 +364,11 @@ FT_BEGIN_HEADER
} FT_Outline; } FT_Outline;
/* Following limits must be consistent with */
/* FT_Outline.{n_contours,n_points} */
#define FT_OUTLINE_CONTOURS_MAX SHRT_MAX
#define FT_OUTLINE_POINTS_MAX SHRT_MAX
/*************************************************************************/ /*************************************************************************/
/* */ /* */
@ -371,7 +391,7 @@ FT_BEGIN_HEADER
/* FT_OUTLINE_EVEN_ODD_FILL :: */ /* FT_OUTLINE_EVEN_ODD_FILL :: */
/* By default, outlines are filled using the non-zero winding rule. */ /* By default, outlines are filled using the non-zero winding rule. */
/* If set to 1, the outline will be filled using the even-odd fill */ /* If set to 1, the outline will be filled using the even-odd fill */
/* rule (only works with the smooth raster). */ /* rule (only works with the smooth rasterizer). */
/* */ /* */
/* FT_OUTLINE_REVERSE_FILL :: */ /* FT_OUTLINE_REVERSE_FILL :: */
/* By default, outside contours of an outline are oriented in */ /* By default, outside contours of an outline are oriented in */
@ -384,15 +404,17 @@ FT_BEGIN_HEADER
/* By default, the scan converter will try to detect drop-outs in */ /* By default, the scan converter will try to detect drop-outs in */
/* an outline and correct the glyph bitmap to ensure consistent */ /* an outline and correct the glyph bitmap to ensure consistent */
/* shape continuity. If set, this flag hints the scan-line */ /* shape continuity. If set, this flag hints the scan-line */
/* converter to ignore such cases. */ /* converter to ignore such cases. See below for more information. */
/* */ /* */
/* FT_OUTLINE_SMART_DROPOUTS :: */ /* FT_OUTLINE_SMART_DROPOUTS :: */
/* Select smart dropout control. If unset, use simple dropout */ /* Select smart dropout control. If unset, use simple dropout */
/* control. Ignored if @FT_OUTLINE_IGNORE_DROPOUTS is set. */ /* control. Ignored if @FT_OUTLINE_IGNORE_DROPOUTS is set. See */
/* below for more information. */
/* */ /* */
/* FT_OUTLINE_INCLUDE_STUBS :: */ /* FT_OUTLINE_INCLUDE_STUBS :: */
/* If set, turn pixels on for `stubs', otherwise exclude them. */ /* If set, turn pixels on for `stubs', otherwise exclude them. */
/* Ignored if @FT_OUTLINE_IGNORE_DROPOUTS is set. */ /* Ignored if @FT_OUTLINE_IGNORE_DROPOUTS is set. See below for */
/* more information. */
/* */ /* */
/* FT_OUTLINE_HIGH_PRECISION :: */ /* FT_OUTLINE_HIGH_PRECISION :: */
/* This flag indicates that the scan-line converter should try to */ /* This flag indicates that the scan-line converter should try to */
@ -409,6 +431,13 @@ FT_BEGIN_HEADER
/* scan-converter. */ /* scan-converter. */
/* */ /* */
/* <Note> */ /* <Note> */
/* The flags @FT_OUTLINE_IGNORE_DROPOUTS, @FT_OUTLINE_SMART_DROPOUTS, */
/* and @FT_OUTLINE_INCLUDE_STUBS are ignored by the smooth */
/* rasterizer. */
/* */
/* There exists a second mechanism to pass the drop-out mode to the */
/* B/W rasterizer; see the `tags' field in @FT_Outline. */
/* */
/* Please refer to the description of the `SCANTYPE' instruction in */ /* Please refer to the description of the `SCANTYPE' instruction in */
/* the OpenType specification (in file `ttinst1.doc') how simple */ /* the OpenType specification (in file `ttinst1.doc') how simple */
/* drop-outs, smart drop-outs, and stubs are defined. */ /* drop-outs, smart drop-outs, and stubs are defined. */
@ -459,6 +488,8 @@ FT_BEGIN_HEADER
#define FT_CURVE_TAG_CONIC 0 #define FT_CURVE_TAG_CONIC 0
#define FT_CURVE_TAG_CUBIC 2 #define FT_CURVE_TAG_CUBIC 2
#define FT_CURVE_TAG_HAS_SCANMODE 4
#define FT_CURVE_TAG_TOUCH_X 8 /* reserved for the TrueType hinter */ #define FT_CURVE_TAG_TOUCH_X 8 /* reserved for the TrueType hinter */
#define FT_CURVE_TAG_TOUCH_Y 16 /* reserved for the TrueType hinter */ #define FT_CURVE_TAG_TOUCH_Y 16 /* reserved for the TrueType hinter */
@ -1011,7 +1042,7 @@ FT_BEGIN_HEADER
/* */ /* */
/* gray_spans :: The gray span drawing callback. */ /* gray_spans :: The gray span drawing callback. */
/* */ /* */
/* black_spans :: The black span drawing callback. */ /* black_spans :: The black span drawing callback. UNIMPLEMENTED! */
/* */ /* */
/* bit_test :: The bit test callback. UNIMPLEMENTED! */ /* bit_test :: The bit test callback. UNIMPLEMENTED! */
/* */ /* */
@ -1048,7 +1079,7 @@ FT_BEGIN_HEADER
const void* source; const void* source;
int flags; int flags;
FT_SpanFunc gray_spans; FT_SpanFunc gray_spans;
FT_SpanFunc black_spans; FT_SpanFunc black_spans; /* doesn't work! */
FT_Raster_BitTest_Func bit_test; /* doesn't work! */ FT_Raster_BitTest_Func bit_test; /* doesn't work! */
FT_Raster_BitSet_Func bit_set; /* doesn't work! */ FT_Raster_BitSet_Func bit_set; /* doesn't work! */
void* user; void* user;

View File

@ -4,7 +4,7 @@
/* */ /* */
/* FreeType modules public interface (specification). */ /* FreeType modules public interface (specification). */
/* */ /* */
/* Copyright 1996-2001, 2002, 2003, 2006, 2008 by */ /* Copyright 1996-2001, 2002, 2003, 2006, 2008, 2009 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */ /* */
/* This file is part of the FreeType project, and may only be used, */ /* This file is part of the FreeType project, and may only be used, */
@ -259,6 +259,10 @@ FT_BEGIN_HEADER
/* from a given memory object. It is thus possible to use libraries */ /* from a given memory object. It is thus possible to use libraries */
/* with distinct memory allocators within the same program. */ /* with distinct memory allocators within the same program. */
/* */ /* */
/* Normally, you would call this function (followed by a call to */
/* @FT_Add_Default_Modules or a series of calls to @FT_Add_Module) */
/* instead of @FT_Init_FreeType to initialize the FreeType library. */
/* */
/* <Input> */ /* <Input> */
/* memory :: A handle to the original memory object. */ /* memory :: A handle to the original memory object. */
/* */ /* */

View File

@ -7,7 +7,7 @@
/* */ /* */
/* This is _not_ used to retrieve glyph names! */ /* This is _not_ used to retrieve glyph names! */
/* */ /* */
/* Copyright 1996-2001, 2002, 2003, 2006 by */ /* Copyright 1996-2001, 2002, 2003, 2006, 2009 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */ /* */
/* This file is part of the FreeType project, and may only be used, */ /* This file is part of the FreeType project, and may only be used, */
@ -147,7 +147,8 @@ FT_BEGIN_HEADER
/* */ /* */
/* <Note> */ /* <Note> */
/* The `string' array returned in the `aname' structure is not */ /* The `string' array returned in the `aname' structure is not */
/* null-terminated. */ /* null-terminated. The application should deallocate it if it is no */
/* longer in use. */
/* */ /* */
/* Use @FT_Get_Sfnt_Name_Count to get the total number of available */ /* Use @FT_Get_Sfnt_Name_Count to get the total number of available */
/* `name' table entries, then do a loop until you get the right */ /* `name' table entries, then do a loop until you get the right */

View File

@ -598,7 +598,7 @@ FT_BEGIN_HEADER
* *
* @description: * @description:
* Call this function after @FT_Stroker_GetBorderCounts to * Call this function after @FT_Stroker_GetBorderCounts to
* export the all borders to your own @FT_Outline structure. * export all borders to your own @FT_Outline structure.
* *
* Note that this function appends the border points and * Note that this function appends the border points and
* contours to your outline, but does not try to resize its * contours to your outline, but does not try to resize its

View File

@ -474,6 +474,7 @@ FT_BEGIN_HEADER
/* this macro. */ /* this macro. */
/* */ /* */
#define FT_MAKE_TAG( _x1, _x2, _x3, _x4 ) \ #define FT_MAKE_TAG( _x1, _x2, _x3, _x4 ) \
(FT_Tag) \
( ( (FT_ULong)_x1 << 24 ) | \ ( ( (FT_ULong)_x1 << 24 ) | \
( (FT_ULong)_x2 << 16 ) | \ ( (FT_ULong)_x2 << 16 ) | \
( (FT_ULong)_x3 << 8 ) | \ ( (FT_ULong)_x3 << 8 ) | \

View File

@ -49,6 +49,9 @@ FT_BEGIN_HEADER
/* however, there are special cases (like in PDF devices) where it is */ /* however, there are special cases (like in PDF devices) where it is */
/* important to differentiate, in spite of FreeType's uniform API. */ /* important to differentiate, in spite of FreeType's uniform API. */
/* */ /* */
/* This function is in the X11/xf86 namespace for historical reasons */
/* and in no way depends on that windowing system. */
/* */
/*************************************************************************/ /*************************************************************************/

View File

@ -196,6 +196,32 @@ FT_BEGIN_HEADER
} FT_AutoHinter_ServiceRec, *FT_AutoHinter_Service; } FT_AutoHinter_ServiceRec, *FT_AutoHinter_Service;
#ifndef FT_CONFIG_OPTION_PIC
#define FT_DEFINE_AUTOHINTER_SERVICE(class_, reset_face_, get_global_hints_, \
done_global_hints_, load_glyph_) \
FT_CALLBACK_TABLE_DEF \
const FT_AutoHinter_ServiceRec class_ = \
{ \
reset_face_, get_global_hints_, done_global_hints_, load_glyph_ \
};
#else /* FT_CONFIG_OPTION_PIC */
#define FT_DEFINE_AUTOHINTER_SERVICE(class_, reset_face_, get_global_hints_, \
done_global_hints_, load_glyph_) \
void \
FT_Init_Class_##class_( FT_Library library, \
FT_AutoHinter_ServiceRec* clazz) \
{ \
FT_UNUSED(library); \
clazz->reset_face = reset_face_; \
clazz->get_global_hints = get_global_hints_; \
clazz->done_global_hints = done_global_hints_; \
clazz->load_glyph = load_glyph_; \
}
#endif /* FT_CONFIG_OPTION_PIC */
FT_END_HEADER FT_END_HEADER

View File

@ -4,7 +4,7 @@
/* */ /* */
/* Arithmetic computations (specification). */ /* Arithmetic computations (specification). */
/* */ /* */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2008 by */ /* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */ /* */
/* This file is part of the FreeType project, and may only be used, */ /* This file is part of the FreeType project, and may only be used, */
@ -165,6 +165,7 @@ FT_BEGIN_HEADER
#define INT_TO_FIXED( x ) ( (FT_Long)(x) << 16 ) #define INT_TO_FIXED( x ) ( (FT_Long)(x) << 16 )
#define F2DOT14_TO_FIXED( x ) ( (FT_Long)(x) << 2 ) #define F2DOT14_TO_FIXED( x ) ( (FT_Long)(x) << 2 )
#define FLOAT_TO_FIXED( x ) ( (FT_Long)( x * 65536.0 ) ) #define FLOAT_TO_FIXED( x ) ( (FT_Long)( x * 65536.0 ) )
#define FIXED_TO_INT( x ) ( FT_RoundFix( x ) >> 16 )
#define ROUND_F26DOT6( x ) ( x >= 0 ? ( ( (x) + 32 ) & -64 ) \ #define ROUND_F26DOT6( x ) ( x >= 0 ? ( ( (x) + 32 ) & -64 ) \
: ( -( ( 32 - (x) ) & -64 ) ) ) : ( -( ( 32 - (x) ) & -64 ) ) )

View File

@ -240,6 +240,179 @@ FT_BEGIN_HEADER
#endif /* FT_CONFIG_OPTION_OLD_INTERNALS */ #endif /* FT_CONFIG_OPTION_OLD_INTERNALS */
/*************************************************************************/
/* */
/* <Macro> */
/* FT_DECLARE_DRIVER */
/* */
/* <Description> */
/* Used to create a forward declaration of a */
/* FT_Driver_ClassRec stract instance. */
/* */
/* <Macro> */
/* FT_DEFINE_DRIVER */
/* */
/* <Description> */
/* Used to initialize an instance of FT_Driver_ClassRec struct. */
/* */
/* When FT_CONFIG_OPTION_PIC is defined a Create funtion will need */
/* to called with a pointer where the allocated stracture is returned.*/
/* And when it is no longer needed a Destroy function needs */
/* to be called to release that allocation. */
/* fcinit.c (ft_create_default_module_classes) already contains */
/* a mechanism to call these functions for the default modules */
/* described in ftmodule.h */
/* */
/* Notice that the created Create and Destroy functions call */
/* pic_init and pic_free function to allow you to manually allocate */
/* and initialize any additional global data, like module specific */
/* interface, and put them in the global pic container defined in */
/* ftpic.h. if you don't need them just implement the functions as */
/* empty to resolve the link error. */
/* */
/* When FT_CONFIG_OPTION_PIC is not defined the struct will be */
/* allocated in the global scope (or the scope where the macro */
/* is used). */
/* */
#ifndef FT_CONFIG_OPTION_PIC
#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
#define FT_DEFINE_DRIVERS_OLD_INTERNALS(a_,b_) \
a_, b_,
#else
#define FT_DEFINE_DRIVERS_OLD_INTERNALS(a_,b_)
#endif
#define FT_DECLARE_DRIVER(class_) \
FT_CALLBACK_TABLE \
const FT_Driver_ClassRec class_;
#define FT_DEFINE_DRIVER(class_, \
flags_, size_, name_, version_, requires_, \
interface_, init_, done_, get_interface_, \
face_object_size_, size_object_size_, \
slot_object_size_, init_face_, done_face_, \
init_size_, done_size_, init_slot_, done_slot_, \
old_set_char_sizes_, old_set_pixel_sizes_, \
load_glyph_, get_kerning_, attach_file_, \
get_advances_, request_size_, select_size_ ) \
FT_CALLBACK_TABLE_DEF \
const FT_Driver_ClassRec class_ = \
{ \
FT_DEFINE_ROOT_MODULE(flags_,size_,name_,version_,requires_,interface_, \
init_,done_,get_interface_) \
\
face_object_size_, \
size_object_size_, \
slot_object_size_, \
\
init_face_, \
done_face_, \
\
init_size_, \
done_size_, \
\
init_slot_, \
done_slot_, \
\
FT_DEFINE_DRIVERS_OLD_INTERNALS(old_set_char_sizes_, old_set_pixel_sizes_) \
\
load_glyph_, \
\
get_kerning_, \
attach_file_, \
get_advances_, \
\
request_size_, \
select_size_ \
};
#else /* FT_CONFIG_OPTION_PIC */
#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
#define FT_DEFINE_DRIVERS_OLD_INTERNALS(a_,b_) \
clazz->set_char_sizes = a_; \
clazz->set_pixel_sizes = b_;
#else
#define FT_DEFINE_DRIVERS_OLD_INTERNALS(a_,b_)
#endif
#define FT_DECLARE_DRIVER(class_) FT_DECLARE_MODULE(class_)
#define FT_DEFINE_DRIVER(class_, \
flags_, size_, name_, version_, requires_, \
interface_, init_, done_, get_interface_, \
face_object_size_, size_object_size_, \
slot_object_size_, init_face_, done_face_, \
init_size_, done_size_, init_slot_, done_slot_, \
old_set_char_sizes_, old_set_pixel_sizes_, \
load_glyph_, get_kerning_, attach_file_, \
get_advances_, request_size_, select_size_ ) \
void class_##_pic_free( FT_Library library ); \
FT_Error class_##_pic_init( FT_Library library ); \
\
void \
FT_Destroy_Class_##class_( FT_Library library, \
FT_Module_Class* clazz ) \
{ \
FT_Memory memory = library->memory; \
FT_Driver_Class dclazz = (FT_Driver_Class)clazz; \
class_##_pic_free( library ); \
if ( dclazz ) \
FT_FREE( dclazz ); \
} \
\
FT_Error \
FT_Create_Class_##class_( FT_Library library, \
FT_Module_Class** output_class ) \
{ \
FT_Driver_Class clazz; \
FT_Error error; \
FT_Memory memory = library->memory; \
\
if ( FT_ALLOC( clazz, sizeof(*clazz) ) ) \
return error; \
\
error = class_##_pic_init( library ); \
if(error) \
{ \
FT_FREE( clazz ); \
return error; \
} \
\
FT_DEFINE_ROOT_MODULE(flags_,size_,name_,version_,requires_,interface_, \
init_,done_,get_interface_) \
\
clazz->face_object_size = face_object_size_; \
clazz->size_object_size = size_object_size_; \
clazz->slot_object_size = slot_object_size_; \
\
clazz->init_face = init_face_; \
clazz->done_face = done_face_; \
\
clazz->init_size = init_size_; \
clazz->done_size = done_size_; \
\
clazz->init_slot = init_slot_; \
clazz->done_slot = done_slot_; \
\
FT_DEFINE_DRIVERS_OLD_INTERNALS(old_set_char_sizes_, old_set_pixel_sizes_) \
\
clazz->load_glyph = load_glyph_; \
\
clazz->get_kerning = get_kerning_; \
clazz->attach_file = attach_file_; \
clazz->get_advances = get_advances_; \
\
clazz->request_size = request_size_; \
clazz->select_size = select_size_; \
\
*output_class = (FT_Module_Class*)clazz; \
return FT_Err_Ok; \
}
#endif /* FT_CONFIG_OPTION_PIC */
FT_END_HEADER FT_END_HEADER

View File

@ -122,14 +122,14 @@ FT_BEGIN_HEADER
#define FT_GLYPHLOADER_CHECK_P( _loader, _count ) \ #define FT_GLYPHLOADER_CHECK_P( _loader, _count ) \
( (_count) == 0 || (int)((_loader)->base.outline.n_points + \ ( (_count) == 0 || ((_loader)->base.outline.n_points + \
(_loader)->current.outline.n_points + \ (_loader)->current.outline.n_points + \
(_count)) <= (int)(_loader)->max_points ) (unsigned long)(_count)) <= (_loader)->max_points )
#define FT_GLYPHLOADER_CHECK_C( _loader, _count ) \ #define FT_GLYPHLOADER_CHECK_C( _loader, _count ) \
( (_count) == 0 || (int)((_loader)->base.outline.n_contours + \ ( (_count) == 0 || ((_loader)->base.outline.n_contours + \
(_loader)->current.outline.n_contours + \ (_loader)->current.outline.n_contours + \
(_count)) <= (int)(_loader)->max_contours ) (unsigned long)(_count)) <= (_loader)->max_contours )
#define FT_GLYPHLOADER_CHECK_POINTS( _loader, _points,_contours ) \ #define FT_GLYPHLOADER_CHECK_POINTS( _loader, _points,_contours ) \
( ( FT_GLYPHLOADER_CHECK_P( _loader, _points ) && \ ( ( FT_GLYPHLOADER_CHECK_P( _loader, _points ) && \

View File

@ -35,6 +35,7 @@
#include FT_INTERNAL_DRIVER_H #include FT_INTERNAL_DRIVER_H
#include FT_INTERNAL_AUTOHINT_H #include FT_INTERNAL_AUTOHINT_H
#include FT_INTERNAL_SERVICE_H #include FT_INTERNAL_SERVICE_H
#include FT_INTERNAL_PIC_H
#ifdef FT_CONFIG_OPTION_INCREMENTAL #ifdef FT_CONFIG_OPTION_INCREMENTAL
#include FT_INCREMENTAL_H #include FT_INCREMENTAL_H
@ -205,6 +206,45 @@ FT_BEGIN_HEADER
} FT_CMap_ClassRec; } FT_CMap_ClassRec;
#ifndef FT_CONFIG_OPTION_PIC
#define FT_DECLARE_CMAP_CLASS(class_) \
FT_CALLBACK_TABLE const FT_CMap_ClassRec class_;
#define FT_DEFINE_CMAP_CLASS(class_, size_, init_, done_, char_index_, \
char_next_, char_var_index_, char_var_default_, variant_list_, \
charvariant_list_, variantchar_list_) \
FT_CALLBACK_TABLE_DEF \
const FT_CMap_ClassRec class_ = \
{ \
size_, init_, done_, char_index_, char_next_, char_var_index_, \
char_var_default_, variant_list_, charvariant_list_, variantchar_list_ \
};
#else /* FT_CONFIG_OPTION_PIC */
#define FT_DECLARE_CMAP_CLASS(class_) \
void FT_Init_Class_##class_( FT_Library library, FT_CMap_ClassRec* clazz);
#define FT_DEFINE_CMAP_CLASS(class_, size_, init_, done_, char_index_, \
char_next_, char_var_index_, char_var_default_, variant_list_, \
charvariant_list_, variantchar_list_) \
void \
FT_Init_Class_##class_( FT_Library library, \
FT_CMap_ClassRec* clazz) \
{ \
FT_UNUSED(library); \
clazz->size = size_; \
clazz->init = init_; \
clazz->done = done_; \
clazz->char_index = char_index_; \
clazz->char_next = char_next_; \
clazz->char_var_index = char_var_index_; \
clazz->char_var_default = char_var_default_; \
clazz->variant_list = variant_list_; \
clazz->charvariant_list = charvariant_list_; \
clazz->variantchar_list = variantchar_list_; \
}
#endif /* FT_CONFIG_OPTION_PIC */
/* create a new charmap and add it to charmap->face */ /* create a new charmap and add it to charmap->face */
FT_BASE( FT_Error ) FT_BASE( FT_Error )
@ -765,6 +805,10 @@ FT_BEGIN_HEADER
/* */ /* */
/* debug_hooks :: XXX */ /* debug_hooks :: XXX */
/* */ /* */
/* pic_container :: Contains global structs and tables, instead */
/* of defining them globallly. */
/* */
typedef struct FT_LibraryRec_ typedef struct FT_LibraryRec_
{ {
FT_Memory memory; /* library's memory manager */ FT_Memory memory; /* library's memory manager */
@ -795,6 +839,10 @@ FT_BEGIN_HEADER
FT_Bitmap_LcdFilterFunc lcd_filter_func; /* filtering callback */ FT_Bitmap_LcdFilterFunc lcd_filter_func; /* filtering callback */
#endif #endif
#ifdef FT_CONFIG_OPTION_PIC
FT_PIC_Container pic_container;
#endif
} FT_LibraryRec; } FT_LibraryRec;
@ -866,6 +914,484 @@ FT_BEGIN_HEADER
FT_EXPORT_VAR( FT_Raster_Funcs ) ft_default_raster; FT_EXPORT_VAR( FT_Raster_Funcs ) ft_default_raster;
#endif #endif
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/**** ****/
/**** ****/
/**** PIC-Support Macros for ftimage.h ****/
/**** ****/
/**** ****/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/* */
/* <Macro> */
/* FT_DEFINE_OUTLINE_FUNCS */
/* */
/* <Description> */
/* Used to initialize an instance of FT_Outline_Funcs struct. */
/* When FT_CONFIG_OPTION_PIC is defined an init funtion will need to */
/* called with a pre-allocated stracture to be filled. */
/* When FT_CONFIG_OPTION_PIC is not defined the struct will be */
/* allocated in the global scope (or the scope where the macro */
/* is used). */
/* */
#ifndef FT_CONFIG_OPTION_PIC
#define FT_DEFINE_OUTLINE_FUNCS(class_, move_to_, line_to_, conic_to_, \
cubic_to_, shift_, delta_) \
static const FT_Outline_Funcs class_ = \
{ \
move_to_, line_to_, conic_to_, cubic_to_, shift_, delta_ \
};
#else /* FT_CONFIG_OPTION_PIC */
#define FT_DEFINE_OUTLINE_FUNCS(class_, move_to_, line_to_, conic_to_, \
cubic_to_, shift_, delta_) \
static FT_Error \
Init_Class_##class_( FT_Outline_Funcs* clazz ) \
{ \
clazz->move_to = move_to_; \
clazz->line_to = line_to_; \
clazz->conic_to = conic_to_; \
clazz->cubic_to = cubic_to_; \
clazz->shift = shift_; \
clazz->delta = delta_; \
return FT_Err_Ok; \
}
#endif /* FT_CONFIG_OPTION_PIC */
/*************************************************************************/
/* */
/* <Macro> */
/* FT_DEFINE_RASTER_FUNCS */
/* */
/* <Description> */
/* Used to initialize an instance of FT_Raster_Funcs struct. */
/* When FT_CONFIG_OPTION_PIC is defined an init funtion will need to */
/* called with a pre-allocated stracture to be filled. */
/* When FT_CONFIG_OPTION_PIC is not defined the struct will be */
/* allocated in the global scope (or the scope where the macro */
/* is used). */
/* */
#ifndef FT_CONFIG_OPTION_PIC
#define FT_DEFINE_RASTER_FUNCS(class_, glyph_format_, raster_new_, \
raster_reset_, raster_set_mode_, \
raster_render_, raster_done_) \
const FT_Raster_Funcs class_ = \
{ \
glyph_format_, raster_new_, raster_reset_, \
raster_set_mode_, raster_render_, raster_done_ \
};
#else /* FT_CONFIG_OPTION_PIC */
#define FT_DEFINE_RASTER_FUNCS(class_, glyph_format_, raster_new_, \
raster_reset_, raster_set_mode_, raster_render_, raster_done_) \
void \
FT_Init_Class_##class_( FT_Raster_Funcs* clazz ) \
{ \
clazz->glyph_format = glyph_format_; \
clazz->raster_new = raster_new_; \
clazz->raster_reset = raster_reset_; \
clazz->raster_set_mode = raster_set_mode_; \
clazz->raster_render = raster_render_; \
clazz->raster_done = raster_done_; \
}
#endif /* FT_CONFIG_OPTION_PIC */
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/**** ****/
/**** ****/
/**** PIC-Support Macros for ftrender.h ****/
/**** ****/
/**** ****/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/* */
/* <Macro> */
/* FT_DEFINE_GLYPH */
/* */
/* <Description> */
/* Used to initialize an instance of FT_Glyph_Class struct. */
/* When FT_CONFIG_OPTION_PIC is defined an init funtion will need to */
/* called with a pre-allocated stracture to be filled. */
/* When FT_CONFIG_OPTION_PIC is not defined the struct will be */
/* allocated in the global scope (or the scope where the macro */
/* is used). */
/* */
#ifndef FT_CONFIG_OPTION_PIC
#define FT_DEFINE_GLYPH(class_, size_, format_, init_, done_, copy_, \
transform_, bbox_, prepare_) \
FT_CALLBACK_TABLE_DEF \
const FT_Glyph_Class class_ = \
{ \
size_, format_, init_, done_, copy_, transform_, bbox_, prepare_ \
};
#else /* FT_CONFIG_OPTION_PIC */
#define FT_DEFINE_GLYPH(class_, size_, format_, init_, done_, copy_, \
transform_, bbox_, prepare_) \
void \
FT_Init_Class_##class_( FT_Glyph_Class* clazz ) \
{ \
clazz->glyph_size = size_; \
clazz->glyph_format = format_; \
clazz->glyph_init = init_; \
clazz->glyph_done = done_; \
clazz->glyph_copy = copy_; \
clazz->glyph_transform = transform_; \
clazz->glyph_bbox = bbox_; \
clazz->glyph_prepare = prepare_; \
}
#endif /* FT_CONFIG_OPTION_PIC */
/*************************************************************************/
/* */
/* <Macro> */
/* FT_DECLARE_RENDERER */
/* */
/* <Description> */
/* Used to create a forward declaration of a */
/* FT_Renderer_Class stract instance. */
/* */
/* <Macro> */
/* FT_DEFINE_RENDERER */
/* */
/* <Description> */
/* Used to initialize an instance of FT_Renderer_Class struct. */
/* */
/* When FT_CONFIG_OPTION_PIC is defined a Create funtion will need */
/* to called with a pointer where the allocated stracture is returned.*/
/* And when it is no longer needed a Destroy function needs */
/* to be called to release that allocation. */
/* fcinit.c (ft_create_default_module_classes) already contains */
/* a mechanism to call these functions for the default modules */
/* described in ftmodule.h */
/* */
/* Notice that the created Create and Destroy functions call */
/* pic_init and pic_free function to allow you to manually allocate */
/* and initialize any additional global data, like module specific */
/* interface, and put them in the global pic container defined in */
/* ftpic.h. if you don't need them just implement the functions as */
/* empty to resolve the link error. */
/* */
/* When FT_CONFIG_OPTION_PIC is not defined the struct will be */
/* allocated in the global scope (or the scope where the macro */
/* is used). */
/* */
#ifndef FT_CONFIG_OPTION_PIC
#define FT_DECLARE_RENDERER(class_) \
FT_EXPORT_VAR( const FT_Renderer_Class ) class_;
#define FT_DEFINE_RENDERER(class_, \
flags_, size_, name_, version_, requires_, \
interface_, init_, done_, get_interface_, \
glyph_format_, render_glyph_, transform_glyph_, \
get_glyph_cbox_, set_mode_, raster_class_ ) \
FT_CALLBACK_TABLE_DEF \
const FT_Renderer_Class class_ = \
{ \
FT_DEFINE_ROOT_MODULE(flags_,size_,name_,version_,requires_, \
interface_,init_,done_,get_interface_) \
glyph_format_, \
\
render_glyph_, \
transform_glyph_, \
get_glyph_cbox_, \
set_mode_, \
\
raster_class_ \
};
#else /* FT_CONFIG_OPTION_PIC */
#define FT_DECLARE_RENDERER(class_) FT_DECLARE_MODULE(class_)
#define FT_DEFINE_RENDERER(class_, \
flags_, size_, name_, version_, requires_, \
interface_, init_, done_, get_interface_, \
glyph_format_, render_glyph_, transform_glyph_, \
get_glyph_cbox_, set_mode_, raster_class_ ) \
void class_##_pic_free( FT_Library library ); \
FT_Error class_##_pic_init( FT_Library library ); \
\
void \
FT_Destroy_Class_##class_( FT_Library library, \
FT_Module_Class* clazz ) \
{ \
FT_Renderer_Class* rclazz = (FT_Renderer_Class*)clazz; \
FT_Memory memory = library->memory; \
class_##_pic_free( library ); \
if ( rclazz ) \
FT_FREE( rclazz ); \
} \
\
FT_Error \
FT_Create_Class_##class_( FT_Library library, \
FT_Module_Class** output_class ) \
{ \
FT_Renderer_Class* clazz; \
FT_Error error; \
FT_Memory memory = library->memory; \
\
if ( FT_ALLOC( clazz, sizeof(*clazz) ) ) \
return error; \
\
error = class_##_pic_init( library ); \
if(error) \
{ \
FT_FREE( clazz ); \
return error; \
} \
\
FT_DEFINE_ROOT_MODULE(flags_,size_,name_,version_,requires_, \
interface_,init_,done_,get_interface_) \
\
clazz->glyph_format = glyph_format_; \
\
clazz->render_glyph = render_glyph_; \
clazz->transform_glyph = transform_glyph_; \
clazz->get_glyph_cbox = get_glyph_cbox_; \
clazz->set_mode = set_mode_; \
\
clazz->raster_class = raster_class_; \
\
*output_class = (FT_Module_Class*)clazz; \
return FT_Err_Ok; \
}
#endif /* FT_CONFIG_OPTION_PIC */
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/**** ****/
/**** ****/
/**** PIC-Support Macros for ftmodapi.h ****/
/**** ****/
/**** ****/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
#ifdef FT_CONFIG_OPTION_PIC
/*************************************************************************/
/* */
/* <FuncType> */
/* FT_Module_Creator */
/* */
/* <Description> */
/* A function used to create (allocate) a new module class object. */
/* The object's members are initialized, but the module itself is */
/* not. */
/* */
/* <Input> */
/* memory :: A handle to the memory manager. */
/* output_class :: Initialized with the newly allocated class. */
/* */
typedef FT_Error
(*FT_Module_Creator)( FT_Memory memory,
FT_Module_Class** output_class );
/*************************************************************************/
/* */
/* <FuncType> */
/* FT_Module_Destroyer */
/* */
/* <Description> */
/* A function used to destroy (deallocate) a module class object. */
/* */
/* <Input> */
/* memory :: A handle to the memory manager. */
/* clazz :: Module class to destroy. */
/* */
typedef void
(*FT_Module_Destroyer)( FT_Memory memory,
FT_Module_Class* clazz );
#endif
/*************************************************************************/
/* */
/* <Macro> */
/* FT_DECLARE_MODULE */
/* */
/* <Description> */
/* Used to create a forward declaration of a */
/* FT_Module_Class stract instance. */
/* */
/* <Macro> */
/* FT_DEFINE_MODULE */
/* */
/* <Description> */
/* Used to initialize an instance of FT_Module_Class struct. */
/* */
/* When FT_CONFIG_OPTION_PIC is defined a Create funtion will need */
/* to called with a pointer where the allocated stracture is returned.*/
/* And when it is no longer needed a Destroy function needs */
/* to be called to release that allocation. */
/* fcinit.c (ft_create_default_module_classes) already contains */
/* a mechanism to call these functions for the default modules */
/* described in ftmodule.h */
/* */
/* Notice that the created Create and Destroy functions call */
/* pic_init and pic_free function to allow you to manually allocate */
/* and initialize any additional global data, like module specific */
/* interface, and put them in the global pic container defined in */
/* ftpic.h. if you don't need them just implement the functions as */
/* empty to resolve the link error. */
/* */
/* When FT_CONFIG_OPTION_PIC is not defined the struct will be */
/* allocated in the global scope (or the scope where the macro */
/* is used). */
/* */
/* <Macro> */
/* FT_DEFINE_ROOT_MODULE */
/* */
/* <Description> */
/* Used to initialize an instance of FT_Module_Class struct inside */
/* another stract that contains it or in a function that initializes */
/* that containing stract */
/* */
#ifndef FT_CONFIG_OPTION_PIC
#define FT_DECLARE_MODULE(class_) \
FT_CALLBACK_TABLE \
const FT_Module_Class class_; \
#define FT_DEFINE_ROOT_MODULE(flags_, size_, name_, version_, requires_, \
interface_, init_, done_, get_interface_) \
{ \
flags_, \
size_, \
\
name_, \
version_, \
requires_, \
\
interface_, \
\
init_, \
done_, \
get_interface_, \
},
#define FT_DEFINE_MODULE(class_, flags_, size_, name_, version_, requires_, \
interface_, init_, done_, get_interface_) \
FT_CALLBACK_TABLE_DEF \
const FT_Module_Class class_ = \
{ \
flags_, \
size_, \
\
name_, \
version_, \
requires_, \
\
interface_, \
\
init_, \
done_, \
get_interface_, \
};
#else /* FT_CONFIG_OPTION_PIC */
#define FT_DECLARE_MODULE(class_) \
FT_Error FT_Create_Class_##class_( FT_Library library, \
FT_Module_Class** output_class ); \
void FT_Destroy_Class_##class_( FT_Library library, \
FT_Module_Class* clazz );
#define FT_DEFINE_ROOT_MODULE(flags_, size_, name_, version_, requires_, \
interface_, init_, done_, get_interface_) \
clazz->root.module_flags = flags_; \
clazz->root.module_size = size_; \
clazz->root.module_name = name_; \
clazz->root.module_version = version_; \
clazz->root.module_requires = requires_; \
\
clazz->root.module_interface = interface_; \
\
clazz->root.module_init = init_; \
clazz->root.module_done = done_; \
clazz->root.get_interface = get_interface_;
#define FT_DEFINE_MODULE(class_, flags_, size_, name_, version_, requires_, \
interface_, init_, done_, get_interface_) \
void class_##_pic_free( FT_Library library ); \
FT_Error class_##_pic_init( FT_Library library ); \
\
void \
FT_Destroy_Class_##class_( FT_Library library, \
FT_Module_Class* clazz ) \
{ \
FT_Memory memory = library->memory; \
class_##_pic_free( library ); \
if ( clazz ) \
FT_FREE( clazz ); \
} \
\
FT_Error \
FT_Create_Class_##class_( FT_Library library, \
FT_Module_Class** output_class ) \
{ \
FT_Memory memory = library->memory; \
FT_Module_Class* clazz; \
FT_Error error; \
\
if ( FT_ALLOC( clazz, sizeof(*clazz) ) ) \
return error; \
error = class_##_pic_init( library ); \
if(error) \
{ \
FT_FREE( clazz ); \
return error; \
} \
\
clazz->module_flags = flags_; \
clazz->module_size = size_; \
clazz->module_name = name_; \
clazz->module_version = version_; \
clazz->module_requires = requires_; \
\
clazz->module_interface = interface_; \
\
clazz->module_init = init_; \
clazz->module_done = done_; \
clazz->get_interface = get_interface_; \
\
*output_class = clazz; \
return FT_Err_Ok; \
}
#endif /* FT_CONFIG_OPTION_PIC */
FT_END_HEADER FT_END_HEADER

View File

@ -0,0 +1,67 @@
/***************************************************************************/
/* */
/* ftpic.h */
/* */
/* The FreeType position independent code services (declaration). */
/* */
/* 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. */
/* */
/***************************************************************************/
/*************************************************************************/
/* */
/* Modules that ordinarily have const global data that need address */
/* can instead define pointers here. */
/* */
/*************************************************************************/
#ifndef __FTPIC_H__
#define __FTPIC_H__
FT_BEGIN_HEADER
#ifdef FT_CONFIG_OPTION_PIC
typedef struct FT_PIC_Container_
{
/* pic containers for base */
void* base;
/* pic containers for modules */
void* autofit;
void* cff;
void* pshinter;
void* psnames;
void* raster;
void* sfnt;
void* smooth;
void* truetype;
} FT_PIC_Container;
/* Initialize the various function tables, structs, etc. stored in the container. */
FT_BASE( FT_Error )
ft_pic_container_init( FT_Library library );
/* Destroy the contents of the container. */
FT_BASE( void )
ft_pic_container_destroy( FT_Library library );
#endif /* FT_CONFIG_OPTION_PIC */
/* */
FT_END_HEADER
#endif /* __FTPIC_H__ */
/* END */

View File

@ -163,6 +163,298 @@ FT_BEGIN_HEADER
typedef const FT_ServiceDescRec* FT_ServiceDesc; typedef const FT_ServiceDescRec* FT_ServiceDesc;
/*************************************************************************/
/* */
/* <Macro> */
/* FT_DEFINE_SERVICEDESCREC1 .. FT_DEFINE_SERVICEDESCREC6 */
/* */
/* <Description> */
/* Used to initialize an array of FT_ServiceDescRec structs. */
/* */
/* When FT_CONFIG_OPTION_PIC is defined a Create funtion will need */
/* to called with a pointer where the allocated array is returned. */
/* And when it is no longer needed a Destroy function needs */
/* to be called to release that allocation. */
/* */
/* These functions should be manyally called from the pic_init and */
/* pic_free functions of your module (see FT_DEFINE_MODULE) */
/* */
/* When FT_CONFIG_OPTION_PIC is not defined the array will be */
/* allocated in the global scope (or the scope where the macro */
/* is used). */
/* */
#ifndef FT_CONFIG_OPTION_PIC
#define FT_DEFINE_SERVICEDESCREC1(class_, serv_id_1, serv_data_1) \
static const FT_ServiceDescRec class_[] = \
{ \
{serv_id_1, serv_data_1}, \
{NULL, NULL} \
};
#define FT_DEFINE_SERVICEDESCREC2(class_, serv_id_1, serv_data_1, \
serv_id_2, serv_data_2) \
static const FT_ServiceDescRec class_[] = \
{ \
{serv_id_1, serv_data_1}, \
{serv_id_2, serv_data_2}, \
{NULL, NULL} \
};
#define FT_DEFINE_SERVICEDESCREC3(class_, serv_id_1, serv_data_1, \
serv_id_2, serv_data_2, serv_id_3, serv_data_3) \
static const FT_ServiceDescRec class_[] = \
{ \
{serv_id_1, serv_data_1}, \
{serv_id_2, serv_data_2}, \
{serv_id_3, serv_data_3}, \
{NULL, NULL} \
};
#define FT_DEFINE_SERVICEDESCREC4(class_, serv_id_1, serv_data_1, \
serv_id_2, serv_data_2, serv_id_3, serv_data_3, \
serv_id_4, serv_data_4) \
static const FT_ServiceDescRec class_[] = \
{ \
{serv_id_1, serv_data_1}, \
{serv_id_2, serv_data_2}, \
{serv_id_3, serv_data_3}, \
{serv_id_4, serv_data_4}, \
{NULL, NULL} \
};
#define FT_DEFINE_SERVICEDESCREC5(class_, serv_id_1, serv_data_1, \
serv_id_2, serv_data_2, serv_id_3, serv_data_3, \
serv_id_4, serv_data_4, serv_id_5, serv_data_5) \
static const FT_ServiceDescRec class_[] = \
{ \
{serv_id_1, serv_data_1}, \
{serv_id_2, serv_data_2}, \
{serv_id_3, serv_data_3}, \
{serv_id_4, serv_data_4}, \
{serv_id_5, serv_data_5}, \
{NULL, NULL} \
};
#define FT_DEFINE_SERVICEDESCREC6(class_, serv_id_1, serv_data_1, \
serv_id_2, serv_data_2, serv_id_3, serv_data_3, \
serv_id_4, serv_data_4, serv_id_5, serv_data_5, \
serv_id_6, serv_data_6) \
static const FT_ServiceDescRec class_[] = \
{ \
{serv_id_1, serv_data_1}, \
{serv_id_2, serv_data_2}, \
{serv_id_3, serv_data_3}, \
{serv_id_4, serv_data_4}, \
{serv_id_5, serv_data_5}, \
{serv_id_6, serv_data_6}, \
{NULL, NULL} \
};
#else /* FT_CONFIG_OPTION_PIC */
#define FT_DEFINE_SERVICEDESCREC1(class_, serv_id_1, serv_data_1) \
void \
FT_Destroy_Class_##class_( FT_Library library, \
FT_ServiceDescRec* clazz ) \
{ \
FT_Memory memory = library->memory; \
if ( clazz ) \
FT_FREE( clazz ); \
} \
\
FT_Error \
FT_Create_Class_##class_( FT_Library library, \
FT_ServiceDescRec** output_class) \
{ \
FT_ServiceDescRec* clazz; \
FT_Error error; \
FT_Memory memory = library->memory; \
\
if ( FT_ALLOC( clazz, sizeof(*clazz)*2 ) ) \
return error; \
clazz[0].serv_id = serv_id_1; \
clazz[0].serv_data = serv_data_1; \
clazz[1].serv_id = NULL; \
clazz[1].serv_data = NULL; \
*output_class = clazz; \
return FT_Err_Ok; \
}
#define FT_DEFINE_SERVICEDESCREC2(class_, serv_id_1, serv_data_1, \
serv_id_2, serv_data_2) \
void \
FT_Destroy_Class_##class_( FT_Library library, \
FT_ServiceDescRec* clazz ) \
{ \
FT_Memory memory = library->memory; \
if ( clazz ) \
FT_FREE( clazz ); \
} \
\
FT_Error \
FT_Create_Class_##class_( FT_Library library, \
FT_ServiceDescRec** output_class) \
{ \
FT_ServiceDescRec* clazz; \
FT_Error error; \
FT_Memory memory = library->memory; \
\
if ( FT_ALLOC( clazz, sizeof(*clazz)*3 ) ) \
return error; \
clazz[0].serv_id = serv_id_1; \
clazz[0].serv_data = serv_data_1; \
clazz[1].serv_id = serv_id_2; \
clazz[1].serv_data = serv_data_2; \
clazz[2].serv_id = NULL; \
clazz[2].serv_data = NULL; \
*output_class = clazz; \
return FT_Err_Ok; \
}
#define FT_DEFINE_SERVICEDESCREC3(class_, serv_id_1, serv_data_1, \
serv_id_2, serv_data_2, serv_id_3, serv_data_3) \
void \
FT_Destroy_Class_##class_( FT_Library library, \
FT_ServiceDescRec* clazz ) \
{ \
FT_Memory memory = library->memory; \
if ( clazz ) \
FT_FREE( clazz ); \
} \
\
FT_Error \
FT_Create_Class_##class_( FT_Library library, \
FT_ServiceDescRec** output_class) \
{ \
FT_ServiceDescRec* clazz; \
FT_Error error; \
FT_Memory memory = library->memory; \
\
if ( FT_ALLOC( clazz, sizeof(*clazz)*4 ) ) \
return error; \
clazz[0].serv_id = serv_id_1; \
clazz[0].serv_data = serv_data_1; \
clazz[1].serv_id = serv_id_2; \
clazz[1].serv_data = serv_data_2; \
clazz[2].serv_id = serv_id_3; \
clazz[2].serv_data = serv_data_3; \
clazz[3].serv_id = NULL; \
clazz[3].serv_data = NULL; \
*output_class = clazz; \
return FT_Err_Ok; \
}
#define FT_DEFINE_SERVICEDESCREC4(class_, serv_id_1, serv_data_1, \
serv_id_2, serv_data_2, serv_id_3, serv_data_3, \
serv_id_4, serv_data_4) \
void \
FT_Destroy_Class_##class_( FT_Library library, \
FT_ServiceDescRec* clazz ) \
{ \
FT_Memory memory = library->memory; \
if ( clazz ) \
FT_FREE( clazz ); \
} \
\
FT_Error \
FT_Create_Class_##class_( FT_Library library, \
FT_ServiceDescRec** output_class) \
{ \
FT_ServiceDescRec* clazz; \
FT_Error error; \
FT_Memory memory = library->memory; \
\
if ( FT_ALLOC( clazz, sizeof(*clazz)*5 ) ) \
return error; \
clazz[0].serv_id = serv_id_1; \
clazz[0].serv_data = serv_data_1; \
clazz[1].serv_id = serv_id_2; \
clazz[1].serv_data = serv_data_2; \
clazz[2].serv_id = serv_id_3; \
clazz[2].serv_data = serv_data_3; \
clazz[3].serv_id = serv_id_4; \
clazz[3].serv_data = serv_data_4; \
clazz[4].serv_id = NULL; \
clazz[4].serv_data = NULL; \
*output_class = clazz; \
return FT_Err_Ok; \
}
#define FT_DEFINE_SERVICEDESCREC5(class_, serv_id_1, serv_data_1, \
serv_id_2, serv_data_2, serv_id_3, serv_data_3, serv_id_4, \
serv_data_4, serv_id_5, serv_data_5) \
void \
FT_Destroy_Class_##class_( FT_Library library, \
FT_ServiceDescRec* clazz ) \
{ \
FT_Memory memory = library->memory; \
if ( clazz ) \
FT_FREE( clazz ); \
} \
\
FT_Error \
FT_Create_Class_##class_( FT_Library library, \
FT_ServiceDescRec** output_class) \
{ \
FT_ServiceDescRec* clazz; \
FT_Error error; \
FT_Memory memory = library->memory; \
\
if ( FT_ALLOC( clazz, sizeof(*clazz)*6 ) ) \
return error; \
clazz[0].serv_id = serv_id_1; \
clazz[0].serv_data = serv_data_1; \
clazz[1].serv_id = serv_id_2; \
clazz[1].serv_data = serv_data_2; \
clazz[2].serv_id = serv_id_3; \
clazz[2].serv_data = serv_data_3; \
clazz[3].serv_id = serv_id_4; \
clazz[3].serv_data = serv_data_4; \
clazz[4].serv_id = serv_id_5; \
clazz[4].serv_data = serv_data_5; \
clazz[5].serv_id = NULL; \
clazz[5].serv_data = NULL; \
*output_class = clazz; \
return FT_Err_Ok; \
}
#define FT_DEFINE_SERVICEDESCREC6(class_, serv_id_1, serv_data_1, \
serv_id_2, serv_data_2, serv_id_3, serv_data_3, \
serv_id_4, serv_data_4, serv_id_5, serv_data_5, \
serv_id_6, serv_data_6) \
void \
FT_Destroy_Class_##class_( FT_Library library, \
FT_ServiceDescRec* clazz ) \
{ \
FT_Memory memory = library->memory; \
if ( clazz ) \
FT_FREE( clazz ); \
} \
\
FT_Error \
FT_Create_Class_##class_( FT_Library library, \
FT_ServiceDescRec** output_class) \
{ \
FT_ServiceDescRec* clazz; \
FT_Error error; \
FT_Memory memory = library->memory; \
\
if ( FT_ALLOC( clazz, sizeof(*clazz)*7 ) ) \
return error; \
clazz[0].serv_id = serv_id_1; \
clazz[0].serv_data = serv_data_1; \
clazz[1].serv_id = serv_id_2; \
clazz[1].serv_data = serv_data_2; \
clazz[2].serv_id = serv_id_3; \
clazz[2].serv_data = serv_data_3; \
clazz[3].serv_id = serv_id_4; \
clazz[3].serv_data = serv_data_4; \
clazz[4].serv_id = serv_id_5; \
clazz[4].serv_data = serv_data_5; \
clazz[5].serv_id = serv_id_6; \
clazz[5].serv_data = serv_data_6; \
clazz[6].serv_id = NULL; \
clazz[6].serv_data = NULL; \
*output_class = clazz; \
return FT_Err_Ok; \
}
#endif /* FT_CONFIG_OPTION_PIC */
/* /*
* Parse a list of FT_ServiceDescRec descriptors and look for * Parse a list of FT_ServiceDescRec descriptors and look for

View File

@ -31,16 +31,19 @@ FT_TRACE_DEF( init ) /* initialization (ftinit.c) */
FT_TRACE_DEF( objs ) /* base objects (ftobjs.c) */ FT_TRACE_DEF( objs ) /* base objects (ftobjs.c) */
FT_TRACE_DEF( outline ) /* outline management (ftoutln.c) */ FT_TRACE_DEF( outline ) /* outline management (ftoutln.c) */
FT_TRACE_DEF( glyph ) /* glyph management (ftglyph.c) */ FT_TRACE_DEF( glyph ) /* glyph management (ftglyph.c) */
FT_TRACE_DEF( gloader ) /* glyph loader (ftgloadr.c) */
FT_TRACE_DEF( raster ) /* monochrome rasterizer (ftraster.c) */ FT_TRACE_DEF( raster ) /* monochrome rasterizer (ftraster.c) */
FT_TRACE_DEF( smooth ) /* anti-aliasing raster (ftgrays.c) */ FT_TRACE_DEF( smooth ) /* anti-aliasing raster (ftgrays.c) */
FT_TRACE_DEF( mm ) /* MM interface (ftmm.c) */ FT_TRACE_DEF( mm ) /* MM interface (ftmm.c) */
FT_TRACE_DEF( raccess ) /* resource fork accessor (ftrfork.c) */ FT_TRACE_DEF( raccess ) /* resource fork accessor (ftrfork.c) */
FT_TRACE_DEF( synth ) /* bold/slant synthesizer (ftsynth.c) */
/* Cache sub-system */ /* Cache sub-system */
FT_TRACE_DEF( cache ) /* cache sub-system (ftcache.c, etc.) */ FT_TRACE_DEF( cache ) /* cache sub-system (ftcache.c, etc.) */
/* SFNT driver components */ /* SFNT driver components */
FT_TRACE_DEF( sfdriver ) /* SFNT font driver (sfdriver.c) */
FT_TRACE_DEF( sfobjs ) /* SFNT object handler (sfobjs.c) */ FT_TRACE_DEF( sfobjs ) /* SFNT object handler (sfobjs.c) */
FT_TRACE_DEF( ttcmap ) /* charmap handler (ttcmap.c) */ FT_TRACE_DEF( ttcmap ) /* charmap handler (ttcmap.c) */
FT_TRACE_DEF( ttkern ) /* kerning handler (ttkern.c) */ FT_TRACE_DEF( ttkern ) /* kerning handler (ttkern.c) */
@ -48,6 +51,7 @@ FT_TRACE_DEF( ttload ) /* basic TrueType tables (ttload.c) */
FT_TRACE_DEF( ttmtx ) /* metrics-related tables (ttmtx.c) */ FT_TRACE_DEF( ttmtx ) /* metrics-related tables (ttmtx.c) */
FT_TRACE_DEF( ttpost ) /* PS table processing (ttpost.c) */ FT_TRACE_DEF( ttpost ) /* PS table processing (ttpost.c) */
FT_TRACE_DEF( ttsbit ) /* TrueType sbit handling (ttsbit.c) */ FT_TRACE_DEF( ttsbit ) /* TrueType sbit handling (ttsbit.c) */
FT_TRACE_DEF( ttbdf ) /* TrueType embedded BDF (ttbdf.c) */
/* TrueType driver components */ /* TrueType driver components */
FT_TRACE_DEF( ttdriver ) /* TT font driver (ttdriver.c) */ FT_TRACE_DEF( ttdriver ) /* TT font driver (ttdriver.c) */
@ -58,6 +62,7 @@ FT_TRACE_DEF( ttpload ) /* TT data/program loader (ttpload.c) */
FT_TRACE_DEF( ttgxvar ) /* TrueType GX var handler (ttgxvar.c) */ FT_TRACE_DEF( ttgxvar ) /* TrueType GX var handler (ttgxvar.c) */
/* Type 1 driver components */ /* Type 1 driver components */
FT_TRACE_DEF( t1afm )
FT_TRACE_DEF( t1driver ) FT_TRACE_DEF( t1driver )
FT_TRACE_DEF( t1gload ) FT_TRACE_DEF( t1gload )
FT_TRACE_DEF( t1hint ) FT_TRACE_DEF( t1hint )

View File

@ -25,6 +25,7 @@
#define FT_INTERNAL_OBJECTS_H <freetype/internal/ftobjs.h> #define FT_INTERNAL_OBJECTS_H <freetype/internal/ftobjs.h>
#define FT_INTERNAL_PIC_H <freetype/internal/ftpic.h>
#define FT_INTERNAL_STREAM_H <freetype/internal/ftstream.h> #define FT_INTERNAL_STREAM_H <freetype/internal/ftstream.h>
#define FT_INTERNAL_MEMORY_H <freetype/internal/ftmemory.h> #define FT_INTERNAL_MEMORY_H <freetype/internal/ftmemory.h>
#define FT_INTERNAL_DEBUG_H <freetype/internal/ftdebug.h> #define FT_INTERNAL_DEBUG_H <freetype/internal/ftdebug.h>

View File

@ -360,7 +360,7 @@ FT_BEGIN_HEADER
FT_Error FT_Error
(*to_bytes)( PS_Parser parser, (*to_bytes)( PS_Parser parser,
FT_Byte* bytes, FT_Byte* bytes,
FT_Long max_bytes, FT_Offset max_bytes,
FT_Long* pnum_bytes, FT_Long* pnum_bytes,
FT_Bool delimiters ); FT_Bool delimiters );
@ -533,8 +533,6 @@ FT_BEGIN_HEADER
/* */ /* */
/* max_contours :: Maximal number of contours in builder outline. */ /* max_contours :: Maximal number of contours in builder outline. */
/* */ /* */
/* last :: The last point position. */
/* */
/* pos_x :: The horizontal translation (if composite glyph). */ /* pos_x :: The horizontal translation (if composite glyph). */
/* */ /* */
/* pos_y :: The vertical translation (if composite glyph). */ /* pos_y :: The vertical translation (if composite glyph). */
@ -567,8 +565,6 @@ FT_BEGIN_HEADER
FT_Outline* base; FT_Outline* base;
FT_Outline* current; FT_Outline* current;
FT_Vector last;
FT_Pos pos_x; FT_Pos pos_x;
FT_Pos pos_y; FT_Pos pos_y;
@ -579,7 +575,6 @@ FT_BEGIN_HEADER
T1_ParseState parse_state; T1_ParseState parse_state;
FT_Bool load_points; FT_Bool load_points;
FT_Bool no_recurse; FT_Bool no_recurse;
FT_Bool shift;
FT_Bool metrics_only; FT_Bool metrics_only;
@ -694,9 +689,11 @@ FT_BEGIN_HEADER
T1_Decoder_Callback parse_callback; T1_Decoder_Callback parse_callback;
T1_Decoder_FuncsRec funcs; T1_Decoder_FuncsRec funcs;
FT_Int* buildchar; FT_Long* buildchar;
FT_UInt len_buildchar; FT_UInt len_buildchar;
FT_Bool seac;
} T1_DecoderRec; } T1_DecoderRec;
@ -758,7 +755,7 @@ FT_BEGIN_HEADER
FT_Int FT_Int
(*get_index)( const char* name, (*get_index)( const char* name,
FT_UInt len, FT_Offset len,
void* user_data ); void* user_data );
void* user_data; void* user_data;

View File

@ -6,7 +6,7 @@
/* recorders (specification only). These are used to support native */ /* recorders (specification only). These are used to support native */
/* T1/T2 hints in the `type1', `cid', and `cff' font drivers. */ /* T1/T2 hints in the `type1', `cid', and `cff' font drivers. */
/* */ /* */
/* Copyright 2001, 2002, 2003, 2005, 2006, 2007 by */ /* Copyright 2001, 2002, 2003, 2005, 2006, 2007, 2009 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */ /* */
/* This file is part of the FreeType project, and may only be used, */ /* This file is part of the FreeType project, and may only be used, */
@ -157,7 +157,8 @@ FT_BEGIN_HEADER
* 0 for horizontal stems (hstem), 1 for vertical ones (vstem). * 0 for horizontal stems (hstem), 1 for vertical ones (vstem).
* *
* coords :: * coords ::
* Array of 2 integers, used as (position,length) stem descriptor. * Array of 2 coordinates in 16.16 format, used as (position,length)
* stem descriptor.
* *
* @note: * @note:
* Use vertical coordinates (y) for horizontal stems (dim=0). Use * Use vertical coordinates (y) for horizontal stems (dim=0). Use
@ -177,7 +178,7 @@ FT_BEGIN_HEADER
typedef void typedef void
(*T1_Hints_SetStemFunc)( T1_Hints hints, (*T1_Hints_SetStemFunc)( T1_Hints hints,
FT_UInt dimension, FT_UInt dimension,
FT_Long* coords ); FT_Fixed* coords );
/************************************************************************* /*************************************************************************
@ -197,8 +198,8 @@ FT_BEGIN_HEADER
* 0 for horizontal stems, 1 for vertical ones. * 0 for horizontal stems, 1 for vertical ones.
* *
* coords :: * coords ::
* An array of 6 integers, holding 3 (position,length) pairs for the * An array of 6 values in 16.16 format, holding 3 (position,length)
* counter-controlled stems. * pairs for the counter-controlled stems.
* *
* @note: * @note:
* Use vertical coordinates (y) for horizontal stems (dim=0). Use * Use vertical coordinates (y) for horizontal stems (dim=0). Use
@ -211,7 +212,7 @@ FT_BEGIN_HEADER
typedef void typedef void
(*T1_Hints_SetStem3Func)( T1_Hints hints, (*T1_Hints_SetStem3Func)( T1_Hints hints,
FT_UInt dimension, FT_UInt dimension,
FT_Long* coords ); FT_Fixed* coords );
/************************************************************************* /*************************************************************************
@ -446,7 +447,7 @@ FT_BEGIN_HEADER
* The number of stems. * The number of stems.
* *
* coords :: * coords ::
* An array of `count' (position,length) pairs. * An array of `count' (position,length) pairs in 16.16 format.
* *
* @note: * @note:
* Use vertical coordinates (y) for horizontal stems (dim=0). Use * Use vertical coordinates (y) for horizontal stems (dim=0). Use
@ -678,6 +679,30 @@ FT_BEGIN_HEADER
typedef PSHinter_Interface* PSHinter_Service; typedef PSHinter_Interface* PSHinter_Service;
#ifndef FT_CONFIG_OPTION_PIC
#define FT_DEFINE_PSHINTER_INTERFACE(class_, get_globals_funcs_, \
get_t1_funcs_, get_t2_funcs_) \
static const PSHinter_Interface class_ = \
{ \
get_globals_funcs_, get_t1_funcs_, get_t2_funcs_ \
};
#else /* FT_CONFIG_OPTION_PIC */
#define FT_DEFINE_PSHINTER_INTERFACE(class_, get_globals_funcs_, \
get_t1_funcs_, get_t2_funcs_) \
void \
FT_Init_Class_##class_( FT_Library library, \
PSHinter_Interface* clazz) \
{ \
FT_UNUSED(library); \
clazz->get_globals_funcs = get_globals_funcs_; \
clazz->get_t1_funcs = get_t1_funcs_; \
clazz->get_t2_funcs = get_t2_funcs_; \
}
#endif /* FT_CONFIG_OPTION_PIC */
FT_END_HEADER FT_END_HEADER

View File

@ -45,6 +45,26 @@ FT_BEGIN_HEADER
FT_BDF_GetPropertyFunc get_property; FT_BDF_GetPropertyFunc get_property;
}; };
#ifndef FT_CONFIG_OPTION_PIC
#define FT_DEFINE_SERVICE_BDFRec(class_, get_charset_id_, get_property_) \
static const FT_Service_BDFRec class_ = \
{ \
get_charset_id_, get_property_ \
};
#else /* FT_CONFIG_OPTION_PIC */
#define FT_DEFINE_SERVICE_BDFRec(class_, get_charset_id_, get_property_) \
void \
FT_Init_Class_##class_( FT_Service_BDFRec* clazz ) \
{ \
clazz->get_charset_id = get_charset_id_; \
clazz->get_property = get_property_; \
}
#endif /* FT_CONFIG_OPTION_PIC */
/* */ /* */

View File

@ -46,6 +46,31 @@ FT_BEGIN_HEADER
FT_CID_GetCIDFromGlyphIndexFunc get_cid_from_glyph_index; FT_CID_GetCIDFromGlyphIndexFunc get_cid_from_glyph_index;
}; };
#ifndef FT_CONFIG_OPTION_PIC
#define FT_DEFINE_SERVICE_CIDREC(class_, get_ros_, \
get_is_cid_, get_cid_from_glyph_index_ ) \
static const FT_Service_CIDRec class_ = \
{ \
get_ros_, get_is_cid_, get_cid_from_glyph_index_ \
};
#else /* FT_CONFIG_OPTION_PIC */
#define FT_DEFINE_SERVICE_CIDREC(class_, get_ros_, \
get_is_cid_, get_cid_from_glyph_index_ ) \
void \
FT_Init_Class_##class_( FT_Library library, \
FT_Service_CIDRec* clazz) \
{ \
FT_UNUSED(library); \
clazz->get_ros = get_ros_; \
clazz->get_is_cid = get_is_cid_; \
clazz->get_cid_from_glyph_index = get_cid_from_glyph_index_; \
}
#endif /* FT_CONFIG_OPTION_PIC */
/* */ /* */

View File

@ -51,6 +51,28 @@ FT_BEGIN_HEADER
FT_GlyphDict_NameIndexFunc name_index; /* optional */ FT_GlyphDict_NameIndexFunc name_index; /* optional */
}; };
#ifndef FT_CONFIG_OPTION_PIC
#define FT_DEFINE_SERVICE_GLYPHDICTREC(class_, get_name_, name_index_) \
static const FT_Service_GlyphDictRec class_ = \
{ \
get_name_, name_index_ \
};
#else /* FT_CONFIG_OPTION_PIC */
#define FT_DEFINE_SERVICE_GLYPHDICTREC(class_, get_name_, name_index_) \
void \
FT_Init_Class_##class_( FT_Library library, \
FT_Service_GlyphDictRec* clazz) \
{ \
FT_UNUSED(library); \
clazz->get_name = get_name_; \
clazz->name_index = name_index_; \
}
#endif /* FT_CONFIG_OPTION_PIC */
/* */ /* */

View File

@ -68,6 +68,31 @@ FT_BEGIN_HEADER
FT_Set_Var_Design_Func set_var_design; FT_Set_Var_Design_Func set_var_design;
}; };
#ifndef FT_CONFIG_OPTION_PIC
#define FT_DEFINE_SERVICE_MULTIMASTERSREC(class_, get_mm_, set_mm_design_, \
set_mm_blend_, get_mm_var_, set_var_design_) \
static const FT_Service_MultiMastersRec class_ = \
{ \
get_mm_, set_mm_design_, set_mm_blend_, get_mm_var_, set_var_design_ \
};
#else /* FT_CONFIG_OPTION_PIC */
#define FT_DEFINE_SERVICE_MULTIMASTERSREC(class_, get_mm_, set_mm_design_, \
set_mm_blend_, get_mm_var_, set_var_design_) \
void \
FT_Init_Class_##class_( FT_Service_MultiMastersRec* clazz ) \
{ \
clazz->get_mm = get_mm_; \
clazz->set_mm_design = set_mm_design_; \
clazz->set_mm_blend = set_mm_blend_; \
clazz->get_mm_var = get_mm_var_; \
clazz->set_var_design = set_var_design_; \
}
#endif /* FT_CONFIG_OPTION_PIC */
/* */ /* */

View File

@ -46,6 +46,27 @@ FT_BEGIN_HEADER
FT_PsName_GetFunc get_ps_font_name; FT_PsName_GetFunc get_ps_font_name;
}; };
#ifndef FT_CONFIG_OPTION_PIC
#define FT_DEFINE_SERVICE_PSFONTNAMEREC(class_, get_ps_font_name_) \
static const FT_Service_PsFontNameRec class_ = \
{ \
get_ps_font_name_ \
};
#else /* FT_CONFIG_OPTION_PIC */
#define FT_DEFINE_SERVICE_PSFONTNAMEREC(class_, get_ps_font_name_) \
void \
FT_Init_Class_##class_( FT_Library library, \
FT_Service_PsFontNameRec* clazz) \
{ \
FT_UNUSED(library); \
clazz->get_ps_font_name = get_ps_font_name_; \
}
#endif /* FT_CONFIG_OPTION_PIC */
/* */ /* */

View File

@ -98,7 +98,7 @@ FT_BEGIN_HEADER
(*PS_Unicodes_CharIndexFunc)( PS_Unicodes unicodes, (*PS_Unicodes_CharIndexFunc)( PS_Unicodes unicodes,
FT_UInt32 unicode ); FT_UInt32 unicode );
typedef FT_ULong typedef FT_UInt32
(*PS_Unicodes_CharNextFunc)( PS_Unicodes unicodes, (*PS_Unicodes_CharNextFunc)( PS_Unicodes unicodes,
FT_UInt32 *unicode ); FT_UInt32 *unicode );
@ -117,6 +117,41 @@ FT_BEGIN_HEADER
const unsigned short* adobe_expert_encoding; const unsigned short* adobe_expert_encoding;
}; };
#ifndef FT_CONFIG_OPTION_PIC
#define FT_DEFINE_SERVICE_PSCMAPSREC(class_, unicode_value_, unicodes_init_, \
unicodes_char_index_, unicodes_char_next_, macintosh_name_, \
adobe_std_strings_, adobe_std_encoding_, adobe_expert_encoding_) \
static const FT_Service_PsCMapsRec class_ = \
{ \
unicode_value_, unicodes_init_, \
unicodes_char_index_, unicodes_char_next_, macintosh_name_, \
adobe_std_strings_, adobe_std_encoding_, adobe_expert_encoding_ \
};
#else /* FT_CONFIG_OPTION_PIC */
#define FT_DEFINE_SERVICE_PSCMAPSREC(class_, unicode_value_, unicodes_init_, \
unicodes_char_index_, unicodes_char_next_, macintosh_name_, \
adobe_std_strings_, adobe_std_encoding_, adobe_expert_encoding_) \
void \
FT_Init_Class_##class_( FT_Library library, \
FT_Service_PsCMapsRec* clazz) \
{ \
FT_UNUSED(library); \
clazz->unicode_value = unicode_value_; \
clazz->unicodes_init = unicodes_init_; \
clazz->unicodes_char_index = unicodes_char_index_; \
clazz->unicodes_char_next = unicodes_char_next_; \
clazz->macintosh_name = macintosh_name_; \
clazz->adobe_std_strings = adobe_std_strings_; \
clazz->adobe_std_encoding = adobe_std_encoding_; \
clazz->adobe_expert_encoding = adobe_expert_encoding_; \
}
#endif /* FT_CONFIG_OPTION_PIC */
/* */ /* */

View File

@ -53,6 +53,33 @@ FT_BEGIN_HEADER
PS_GetFontPrivateFunc ps_get_font_private; PS_GetFontPrivateFunc ps_get_font_private;
}; };
#ifndef FT_CONFIG_OPTION_PIC
#define FT_DEFINE_SERVICE_PSINFOREC(class_, get_font_info_, \
ps_get_font_extra_, has_glyph_names_, get_font_private_) \
static const FT_Service_PsInfoRec class_ = \
{ \
get_font_info_, ps_get_font_extra_, has_glyph_names_, \
get_font_private_ \
};
#else /* FT_CONFIG_OPTION_PIC */
#define FT_DEFINE_SERVICE_PSINFOREC(class_, get_font_info_, \
ps_get_font_extra_, has_glyph_names_, get_font_private_) \
void \
FT_Init_Class_##class_( FT_Library library, \
FT_Service_PsInfoRec* clazz) \
{ \
FT_UNUSED(library); \
clazz->ps_get_font_info = get_font_info_; \
clazz->ps_get_font_extra = ps_get_font_extra_; \
clazz->ps_has_glyph_names = has_glyph_names_; \
clazz->ps_get_font_private = get_font_private_; \
}
#endif /* FT_CONFIG_OPTION_PIC */
/* */ /* */

View File

@ -58,6 +58,7 @@ FT_BEGIN_HEADER
(*FT_SFNT_TableInfoFunc)( FT_Face face, (*FT_SFNT_TableInfoFunc)( FT_Face face,
FT_UInt idx, FT_UInt idx,
FT_ULong *tag, FT_ULong *tag,
FT_ULong *offset,
FT_ULong *length ); FT_ULong *length );
@ -68,6 +69,27 @@ FT_BEGIN_HEADER
FT_SFNT_TableInfoFunc table_info; FT_SFNT_TableInfoFunc table_info;
}; };
#ifndef FT_CONFIG_OPTION_PIC
#define FT_DEFINE_SERVICE_SFNT_TABLEREC(class_, load_, get_, info_) \
static const FT_Service_SFNT_TableRec class_ = \
{ \
load_, get_, info_ \
};
#else /* FT_CONFIG_OPTION_PIC */
#define FT_DEFINE_SERVICE_SFNT_TABLEREC(class_, load_, get_, info_) \
void \
FT_Init_Class_##class_( FT_Service_SFNT_TableRec* clazz ) \
{ \
clazz->load_table = load_; \
clazz->get_table = get_; \
clazz->table_info = info_; \
}
#endif /* FT_CONFIG_OPTION_PIC */
/* */ /* */

View File

@ -1,6 +1,6 @@
/***************************************************************************/ /***************************************************************************/
/* */ /* */
/* svsttcmap.h */ /* svttcmap.h */
/* */ /* */
/* The FreeType TrueType/sfnt cmap extra information service. */ /* The FreeType TrueType/sfnt cmap extra information service. */
/* */ /* */
@ -74,6 +74,27 @@ FT_BEGIN_HEADER
TT_CMap_Info_GetFunc get_cmap_info; TT_CMap_Info_GetFunc get_cmap_info;
}; };
#ifndef FT_CONFIG_OPTION_PIC
#define FT_DEFINE_SERVICE_TTCMAPSREC(class_, get_cmap_info_) \
static const FT_Service_TTCMapsRec class_ = \
{ \
get_cmap_info_ \
};
#else /* FT_CONFIG_OPTION_PIC */
#define FT_DEFINE_SERVICE_TTCMAPSREC(class_, get_cmap_info_) \
void \
FT_Init_Class_##class_( FT_Library library, \
FT_Service_TTCMapsRec* clazz) \
{ \
FT_UNUSED(library); \
clazz->get_cmap_info = get_cmap_info_; \
}
#endif /* FT_CONFIG_OPTION_PIC */
/* */ /* */

View File

@ -37,6 +37,25 @@ FT_BEGIN_HEADER
TT_Glyf_GetLocationFunc get_location; TT_Glyf_GetLocationFunc get_location;
}; };
#ifndef FT_CONFIG_OPTION_PIC
#define FT_DEFINE_SERVICE_TTGLYFREC(class_, get_location_ ) \
static const FT_Service_TTGlyfRec class_ = \
{ \
get_location_ \
};
#else /* FT_CONFIG_OPTION_PIC */
#define FT_DEFINE_SERVICE_TTGLYFREC(class_, get_location_ ) \
void \
FT_Init_Class_##class_( FT_Service_TTGlyfRec* clazz ) \
{ \
clazz->get_location = get_location_; \
}
#endif /* FT_CONFIG_OPTION_PIC */
/* */ /* */

View File

@ -753,6 +753,141 @@ FT_BEGIN_HEADER
/* transitional */ /* transitional */
typedef SFNT_Interface* SFNT_Service; typedef SFNT_Interface* SFNT_Service;
#ifndef FT_CONFIG_OPTION_PIC
#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
#define FT_DEFINE_DRIVERS_OLD_INTERNAL(a) \
a,
#else
#define FT_DEFINE_DRIVERS_OLD_INTERNAL(a)
#endif
#define FT_INTERNAL(a) \
a,
#define FT_DEFINE_SFNT_INTERFACE(class_, \
goto_table_, init_face_, load_face_, done_face_, get_interface_, \
load_any_, load_sfnt_header_, load_directory_, load_head_, \
load_hhea_, load_cmap_, load_maxp_, load_os2_, load_post_, \
load_name_, free_name_, load_hdmx_stub_, free_hdmx_stub_, \
load_kern_, load_gasp_, load_pclt_, load_bhed_, \
set_sbit_strike_stub_, load_sbits_stub_, find_sbit_image_, \
load_sbit_metrics_, load_sbit_image_, free_sbits_stub_, \
get_psname_, free_psnames_, load_charmap_stub_, free_charmap_stub_, \
get_kerning_, load_font_dir_, load_hmtx_, load_eblc_, free_eblc_, \
set_sbit_strike_, load_strike_metrics_, get_metrics_ ) \
static const SFNT_Interface class_ = \
{ \
FT_INTERNAL(goto_table_) \
FT_INTERNAL(init_face_) \
FT_INTERNAL(load_face_) \
FT_INTERNAL(done_face_) \
FT_INTERNAL(get_interface_) \
FT_INTERNAL(load_any_) \
FT_DEFINE_DRIVERS_OLD_INTERNAL(load_sfnt_header_) \
FT_DEFINE_DRIVERS_OLD_INTERNAL(load_directory_) \
FT_INTERNAL(load_head_) \
FT_INTERNAL(load_hhea_) \
FT_INTERNAL(load_cmap_) \
FT_INTERNAL(load_maxp_) \
FT_INTERNAL(load_os2_) \
FT_INTERNAL(load_post_) \
FT_INTERNAL(load_name_) \
FT_INTERNAL(free_name_) \
FT_DEFINE_DRIVERS_OLD_INTERNAL(load_hdmx_stub_) \
FT_DEFINE_DRIVERS_OLD_INTERNAL(free_hdmx_stub_) \
FT_INTERNAL(load_kern_) \
FT_INTERNAL(load_gasp_) \
FT_INTERNAL(load_pclt_) \
FT_INTERNAL(load_bhed_) \
FT_DEFINE_DRIVERS_OLD_INTERNAL(set_sbit_strike_stub_) \
FT_DEFINE_DRIVERS_OLD_INTERNAL(load_sbits_stub_) \
FT_DEFINE_DRIVERS_OLD_INTERNAL(find_sbit_image_) \
FT_DEFINE_DRIVERS_OLD_INTERNAL(load_sbit_metrics_) \
FT_INTERNAL(load_sbit_image_) \
FT_DEFINE_DRIVERS_OLD_INTERNAL(free_sbits_stub_) \
FT_INTERNAL(get_psname_) \
FT_INTERNAL(free_psnames_) \
FT_DEFINE_DRIVERS_OLD_INTERNAL(load_charmap_stub_) \
FT_DEFINE_DRIVERS_OLD_INTERNAL(free_charmap_stub_) \
FT_INTERNAL(get_kerning_) \
FT_INTERNAL(load_font_dir_) \
FT_INTERNAL(load_hmtx_) \
FT_INTERNAL(load_eblc_) \
FT_INTERNAL(free_eblc_) \
FT_INTERNAL(set_sbit_strike_) \
FT_INTERNAL(load_strike_metrics_) \
FT_INTERNAL(get_metrics_) \
};
#else /* FT_CONFIG_OPTION_PIC */
#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
#define FT_DEFINE_DRIVERS_OLD_INTERNAL(a, a_) \
clazz->a = a_;
#else
#define FT_DEFINE_DRIVERS_OLD_INTERNAL(a, a_)
#endif
#define FT_INTERNAL(a, a_) \
clazz->a = a_;
#define FT_DEFINE_SFNT_INTERFACE(class_, \
goto_table_, init_face_, load_face_, done_face_, get_interface_, \
load_any_, load_sfnt_header_, load_directory_, load_head_, \
load_hhea_, load_cmap_, load_maxp_, load_os2_, load_post_, \
load_name_, free_name_, load_hdmx_stub_, free_hdmx_stub_, \
load_kern_, load_gasp_, load_pclt_, load_bhed_, \
set_sbit_strike_stub_, load_sbits_stub_, find_sbit_image_, \
load_sbit_metrics_, load_sbit_image_, free_sbits_stub_, \
get_psname_, free_psnames_, load_charmap_stub_, free_charmap_stub_, \
get_kerning_, load_font_dir_, load_hmtx_, load_eblc_, free_eblc_, \
set_sbit_strike_, load_strike_metrics_, get_metrics_ ) \
void \
FT_Init_Class_##class_( FT_Library library, SFNT_Interface* clazz ) \
{ \
FT_UNUSED(library); \
FT_INTERNAL(goto_table,goto_table_) \
FT_INTERNAL(init_face,init_face_) \
FT_INTERNAL(load_face,load_face_) \
FT_INTERNAL(done_face,done_face_) \
FT_INTERNAL(get_interface,get_interface_) \
FT_INTERNAL(load_any,load_any_) \
FT_DEFINE_DRIVERS_OLD_INTERNAL(load_sfnt_header,load_sfnt_header_) \
FT_DEFINE_DRIVERS_OLD_INTERNAL(load_directory,load_directory_) \
FT_INTERNAL(load_head,load_head_) \
FT_INTERNAL(load_hhea,load_hhea_) \
FT_INTERNAL(load_cmap,load_cmap_) \
FT_INTERNAL(load_maxp,load_maxp_) \
FT_INTERNAL(load_os2,load_os2_) \
FT_INTERNAL(load_post,load_post_) \
FT_INTERNAL(load_name,load_name_) \
FT_INTERNAL(free_name,free_name_) \
FT_DEFINE_DRIVERS_OLD_INTERNAL(load_hdmx_stub,load_hdmx_stub_) \
FT_DEFINE_DRIVERS_OLD_INTERNAL(free_hdmx_stub,free_hdmx_stub_) \
FT_INTERNAL(load_kern,load_kern_) \
FT_INTERNAL(load_gasp,load_gasp_) \
FT_INTERNAL(load_pclt,load_pclt_) \
FT_INTERNAL(load_bhed,load_bhed_) \
FT_DEFINE_DRIVERS_OLD_INTERNAL(set_sbit_strike_stub,set_sbit_strike_stub_) \
FT_DEFINE_DRIVERS_OLD_INTERNAL(load_sbits_stub,load_sbits_stub_) \
FT_DEFINE_DRIVERS_OLD_INTERNAL(find_sbit_image,find_sbit_image_) \
FT_DEFINE_DRIVERS_OLD_INTERNAL(load_sbit_metrics,load_sbit_metrics_) \
FT_INTERNAL(load_sbit_image,load_sbit_image_) \
FT_DEFINE_DRIVERS_OLD_INTERNAL(free_sbits_stub,free_sbits_stub_) \
FT_INTERNAL(get_psname,get_psname_) \
FT_INTERNAL(free_psnames,free_psnames_) \
FT_DEFINE_DRIVERS_OLD_INTERNAL(load_charmap_stub,load_charmap_stub_) \
FT_DEFINE_DRIVERS_OLD_INTERNAL(free_charmap_stub,free_charmap_stub_) \
FT_INTERNAL(get_kerning,get_kerning_) \
FT_INTERNAL(load_font_dir,load_font_dir_) \
FT_INTERNAL(load_hmtx,load_hmtx_) \
FT_INTERNAL(load_eblc,load_eblc_) \
FT_INTERNAL(free_eblc,free_eblc_) \
FT_INTERNAL(set_sbit_strike,set_sbit_strike_) \
FT_INTERNAL(load_strike_metrics,load_strike_metrics_) \
FT_INTERNAL(get_metrics,get_metrics_) \
}
#endif /* FT_CONFIG_OPTION_PIC */
FT_END_HEADER FT_END_HEADER

View File

@ -58,7 +58,9 @@ FT_BEGIN_HEADER
/* */ /* */
/* code_first :: The lowest valid character code in the encoding. */ /* code_first :: The lowest valid character code in the encoding. */
/* */ /* */
/* code_last :: The highest valid character code in the encoding. */ /* code_last :: The highest valid character code in the encoding */
/* + 1. When equal to code_first there are no valid */
/* character codes. */
/* */ /* */
/* char_index :: An array of corresponding glyph indices. */ /* char_index :: An array of corresponding glyph indices. */
/* */ /* */
@ -230,7 +232,7 @@ FT_BEGIN_HEADER
/* undocumented, optional: has the same meaning as len_buildchar */ /* undocumented, optional: has the same meaning as len_buildchar */
/* for Type 2 fonts; manipulated by othersubrs 19, 24, and 25 */ /* for Type 2 fonts; manipulated by othersubrs 19, 24, and 25 */
FT_UInt len_buildchar; FT_UInt len_buildchar;
FT_Int* buildchar; FT_Long* buildchar;
/* since version 2.1 - interface to PostScript hinter */ /* since version 2.1 - interface to PostScript hinter */
const void* pshinter; const void* pshinter;

View File

@ -902,7 +902,7 @@ FT_BEGIN_HEADER
FT_Byte* table; FT_Byte* table;
FT_Byte* table_end; FT_Byte* table_end;
FT_Byte* strings; FT_Byte* strings;
FT_UInt32 strings_size; FT_ULong strings_size;
FT_UInt num_strikes; FT_UInt num_strikes;
FT_Bool loaded; FT_Bool loaded;
@ -1401,7 +1401,7 @@ FT_BEGIN_HEADER
FT_Byte* vert_metrics; FT_Byte* vert_metrics;
FT_ULong vert_metrics_size; FT_ULong vert_metrics_size;
FT_UInt num_locations; FT_ULong num_locations; /* in broken TTF, gid > 0xFFFF */
FT_Byte* glyph_locations; FT_Byte* glyph_locations;
FT_Byte* hdmx_table; FT_Byte* hdmx_table;

View File

@ -4,7 +4,7 @@
/* */ /* */
/* Auto-fitter hinting routines for CJK script (body). */ /* Auto-fitter hinting routines for CJK script (body). */
/* */ /* */
/* Copyright 2006, 2007, 2008 by */ /* Copyright 2006, 2007, 2008, 2009 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */ /* */
/* This file is part of the FreeType project, and may only be used, */ /* This file is part of the FreeType project, and may only be used, */
@ -58,9 +58,12 @@
if ( FT_Select_Charmap( face, FT_ENCODING_UNICODE ) ) if ( FT_Select_Charmap( face, FT_ENCODING_UNICODE ) )
face->charmap = NULL; face->charmap = NULL;
else
{
/* latin's version would suffice */ /* latin's version would suffice */
af_latin_metrics_init_widths( metrics, face, 0x7530 ); af_latin_metrics_init_widths( metrics, face, 0x7530 );
af_latin_metrics_check_digits( metrics, face );
}
FT_Set_Charmap( face, oldmap ); FT_Set_Charmap( face, oldmap );
@ -1017,7 +1020,7 @@
AF_AxisHints axis = &hints->axis[dim]; AF_AxisHints axis = &hints->axis[dim];
AF_Edge edges = axis->edges; AF_Edge edges = axis->edges;
AF_Edge edge_limit = edges + axis->num_edges; AF_Edge edge_limit = edges + axis->num_edges;
FT_Int n_edges; FT_PtrDist n_edges;
AF_Edge edge; AF_Edge edge;
AF_Edge anchor = 0; AF_Edge anchor = 0;
FT_Pos delta = 0; FT_Pos delta = 0;
@ -1441,35 +1444,33 @@
static const AF_Script_UniRangeRec af_cjk_uniranges[] = static const AF_Script_UniRangeRec af_cjk_uniranges[] =
{ {
#if 0 #if 0
{ 0x0100UL, 0xFFFFUL }, /* why this? */ AF_UNIRANGE_REC( 0x0100UL, 0xFFFFUL ), /* why this? */
#endif #endif
{ 0x2E80UL, 0x2EFFUL }, /* CJK Radicals Supplement */ AF_UNIRANGE_REC( 0x2E80UL, 0x2EFFUL ), /* CJK Radicals Supplement */
{ 0x2F00UL, 0x2FDFUL }, /* Kangxi Radicals */ AF_UNIRANGE_REC( 0x2F00UL, 0x2FDFUL ), /* Kangxi Radicals */
{ 0x3000UL, 0x303FUL }, /* CJK Symbols and Punctuation */ AF_UNIRANGE_REC( 0x3000UL, 0x303FUL ), /* CJK Symbols and Punctuation */
{ 0x3040UL, 0x309FUL }, /* Hiragana */ AF_UNIRANGE_REC( 0x3040UL, 0x309FUL ), /* Hiragana */
{ 0x30A0UL, 0x30FFUL }, /* Katakana */ AF_UNIRANGE_REC( 0x30A0UL, 0x30FFUL ), /* Katakana */
{ 0x3100UL, 0x312FUL }, /* Bopomofo */ AF_UNIRANGE_REC( 0x3100UL, 0x312FUL ), /* Bopomofo */
{ 0x3130UL, 0x318FUL }, /* Hangul Compatibility Jamo */ AF_UNIRANGE_REC( 0x3130UL, 0x318FUL ), /* Hangul Compatibility Jamo */
{ 0x31A0UL, 0x31BFUL }, /* Bopomofo Extended */ AF_UNIRANGE_REC( 0x31A0UL, 0x31BFUL ), /* Bopomofo Extended */
{ 0x31C0UL, 0x31EFUL }, /* CJK Strokes */ AF_UNIRANGE_REC( 0x31C0UL, 0x31EFUL ), /* CJK Strokes */
{ 0x31F0UL, 0x31FFUL }, /* Katakana Phonetic Extensions */ AF_UNIRANGE_REC( 0x31F0UL, 0x31FFUL ), /* Katakana Phonetic Extensions */
{ 0x3200UL, 0x32FFUL }, /* Enclosed CJK Letters and Months */ AF_UNIRANGE_REC( 0x3200UL, 0x32FFUL ), /* Enclosed CJK Letters and Months */
{ 0x3300UL, 0x33FFUL }, /* CJK Compatibility */ AF_UNIRANGE_REC( 0x3300UL, 0x33FFUL ), /* CJK Compatibility */
{ 0x3400UL, 0x4DBFUL }, /* CJK Unified Ideographs Extension A */ AF_UNIRANGE_REC( 0x3400UL, 0x4DBFUL ), /* CJK Unified Ideographs Extension A */
{ 0x4DC0UL, 0x4DFFUL }, /* Yijing Hexagram Symbols */ AF_UNIRANGE_REC( 0x4DC0UL, 0x4DFFUL ), /* Yijing Hexagram Symbols */
{ 0x4E00UL, 0x9FFFUL }, /* CJK Unified Ideographs */ AF_UNIRANGE_REC( 0x4E00UL, 0x9FFFUL ), /* CJK Unified Ideographs */
{ 0xF900UL, 0xFAFFUL }, /* CJK Compatibility Ideographs */ AF_UNIRANGE_REC( 0xF900UL, 0xFAFFUL ), /* CJK Compatibility Ideographs */
{ 0xFE30UL, 0xFE4FUL }, /* CJK Compatibility Forms */ AF_UNIRANGE_REC( 0xFE30UL, 0xFE4FUL ), /* CJK Compatibility Forms */
{ 0xFF00UL, 0xFFEFUL }, /* Halfwidth and Fullwidth Forms */ AF_UNIRANGE_REC( 0xFF00UL, 0xFFEFUL ), /* Halfwidth and Fullwidth Forms */
{ 0x20000UL, 0x2A6DFUL }, /* CJK Unified Ideographs Extension B */ AF_UNIRANGE_REC( 0x20000UL, 0x2A6DFUL ), /* CJK Unified Ideographs Extension B */
{ 0x2F800UL, 0x2FA1FUL }, /* CJK Compatibility Ideographs Supplement */ AF_UNIRANGE_REC( 0x2F800UL, 0x2FA1FUL ), /* CJK Compatibility Ideographs Supplement */
{ 0UL, 0UL } AF_UNIRANGE_REC( 0UL, 0UL )
}; };
FT_CALLBACK_TABLE_DEF const AF_ScriptClassRec AF_DEFINE_SCRIPT_CLASS(af_cjk_script_class,
af_cjk_script_class =
{
AF_SCRIPT_CJK, AF_SCRIPT_CJK,
af_cjk_uniranges, af_cjk_uniranges,
@ -1481,19 +1482,17 @@
(AF_Script_InitHintsFunc) af_cjk_hints_init, (AF_Script_InitHintsFunc) af_cjk_hints_init,
(AF_Script_ApplyHintsFunc) af_cjk_hints_apply (AF_Script_ApplyHintsFunc) af_cjk_hints_apply
}; )
#else /* !AF_CONFIG_OPTION_CJK */ #else /* !AF_CONFIG_OPTION_CJK */
static const AF_Script_UniRangeRec af_cjk_uniranges[] = static const AF_Script_UniRangeRec af_cjk_uniranges[] =
{ {
{ 0, 0 } AF_UNIRANGE_REC( 0UL, 0UL )
}; };
FT_CALLBACK_TABLE_DEF const AF_ScriptClassRec AF_DEFINE_SCRIPT_CLASS(af_cjk_script_class,
af_cjk_script_class =
{
AF_SCRIPT_CJK, AF_SCRIPT_CJK,
af_cjk_uniranges, af_cjk_uniranges,
@ -1505,7 +1504,7 @@
(AF_Script_InitHintsFunc) NULL, (AF_Script_InitHintsFunc) NULL,
(AF_Script_ApplyHintsFunc) NULL (AF_Script_ApplyHintsFunc) NULL
}; )
#endif /* !AF_CONFIG_OPTION_CJK */ #endif /* !AF_CONFIG_OPTION_CJK */

View File

@ -27,8 +27,7 @@ FT_BEGIN_HEADER
/* the CJK-specific script class */ /* the CJK-specific script class */
FT_CALLBACK_TABLE const AF_ScriptClassRec AF_DECLARE_SCRIPT_CLASS(af_cjk_script_class)
af_cjk_script_class;
FT_LOCAL( FT_Error ) FT_LOCAL( FT_Error )

View File

@ -42,9 +42,7 @@
} }
FT_CALLBACK_TABLE_DEF const AF_ScriptClassRec AF_DEFINE_SCRIPT_CLASS(af_dummy_script_class,
af_dummy_script_class =
{
AF_SCRIPT_NONE, AF_SCRIPT_NONE,
NULL, NULL,
@ -56,7 +54,7 @@
(AF_Script_InitHintsFunc) af_dummy_hints_init, (AF_Script_InitHintsFunc) af_dummy_hints_init,
(AF_Script_ApplyHintsFunc) af_dummy_hints_apply (AF_Script_ApplyHintsFunc) af_dummy_hints_apply
}; )
/* END */ /* END */

View File

@ -29,8 +29,7 @@ FT_BEGIN_HEADER
* be performed. This is the default for non-latin glyphs! * be performed. This is the default for non-latin glyphs!
*/ */
FT_CALLBACK_TABLE const AF_ScriptClassRec AF_DECLARE_SCRIPT_CLASS(af_dummy_script_class)
af_dummy_script_class;
/* */ /* */

View File

@ -4,7 +4,7 @@
/* */ /* */
/* Auto-fitter routines to compute global hinting values (body). */ /* Auto-fitter routines to compute global hinting values (body). */
/* */ /* */
/* Copyright 2003, 2004, 2005, 2006, 2007, 2008 by */ /* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */ /* */
/* This file is part of the FreeType project, and may only be used, */ /* This file is part of the FreeType project, and may only be used, */
@ -21,6 +21,7 @@
#include "aflatin.h" #include "aflatin.h"
#include "afcjk.h" #include "afcjk.h"
#include "afindic.h" #include "afindic.h"
#include "afpic.h"
#include "aferrors.h" #include "aferrors.h"
@ -28,6 +29,11 @@
#include "aflatin2.h" #include "aflatin2.h"
#endif #endif
#ifndef FT_CONFIG_OPTION_PIC
/* when updating this table, don't forget to update
AF_SCRIPT_CLASSES_COUNT and autofit_module_class_pic_init */
/* populate this list when you add new scripts */ /* populate this list when you add new scripts */
static AF_ScriptClass const af_script_classes[] = static AF_ScriptClass const af_script_classes[] =
{ {
@ -41,10 +47,14 @@
NULL /* do not remove */ NULL /* do not remove */
}; };
#endif /* FT_CONFIG_OPTION_PIC */
/* index of default script in `af_script_classes' */ /* index of default script in `af_script_classes' */
#define AF_SCRIPT_LIST_DEFAULT 2 #define AF_SCRIPT_LIST_DEFAULT 2
/* indicates an uncovered glyph */ /* a bit mask indicating an uncovered glyph */
#define AF_SCRIPT_LIST_NONE 255 #define AF_SCRIPT_LIST_NONE 0x7F
/* if this flag is set, we have an ASCII digit */
#define AF_DIGIT 0x80
/* /*
@ -55,7 +65,7 @@
typedef struct AF_FaceGlobalsRec_ typedef struct AF_FaceGlobalsRec_
{ {
FT_Face face; FT_Face face;
FT_UInt glyph_count; /* same as face->num_glyphs */ FT_Long glyph_count; /* same as face->num_glyphs */
FT_Byte* glyph_scripts; FT_Byte* glyph_scripts;
AF_ScriptMetrics metrics[AF_SCRIPT_MAX]; AF_ScriptMetrics metrics[AF_SCRIPT_MAX];
@ -72,7 +82,7 @@
FT_Face face = globals->face; FT_Face face = globals->face;
FT_CharMap old_charmap = face->charmap; FT_CharMap old_charmap = face->charmap;
FT_Byte* gscripts = globals->glyph_scripts; FT_Byte* gscripts = globals->glyph_scripts;
FT_UInt ss; FT_UInt ss, i;
/* the value 255 means `uncovered glyph' */ /* the value 255 means `uncovered glyph' */
@ -92,9 +102,9 @@
} }
/* scan each script in a Unicode charmap */ /* scan each script in a Unicode charmap */
for ( ss = 0; af_script_classes[ss]; ss++ ) for ( ss = 0; AF_SCRIPT_CLASSES_GET[ss]; ss++ )
{ {
AF_ScriptClass clazz = af_script_classes[ss]; AF_ScriptClass clazz = AF_SCRIPT_CLASSES_GET[ss];
AF_Script_UniRange range; AF_Script_UniRange range;
@ -114,7 +124,7 @@
gindex = FT_Get_Char_Index( face, charcode ); gindex = FT_Get_Char_Index( face, charcode );
if ( gindex != 0 && if ( gindex != 0 &&
gindex < globals->glyph_count && gindex < (FT_ULong)globals->glyph_count &&
gscripts[gindex] == AF_SCRIPT_LIST_NONE ) gscripts[gindex] == AF_SCRIPT_LIST_NONE )
{ {
gscripts[gindex] = (FT_Byte)ss; gscripts[gindex] = (FT_Byte)ss;
@ -127,7 +137,7 @@
if ( gindex == 0 || charcode > range->last ) if ( gindex == 0 || charcode > range->last )
break; break;
if ( gindex < globals->glyph_count && if ( gindex < (FT_ULong)globals->glyph_count &&
gscripts[gindex] == AF_SCRIPT_LIST_NONE ) gscripts[gindex] == AF_SCRIPT_LIST_NONE )
{ {
gscripts[gindex] = (FT_Byte)ss; gscripts[gindex] = (FT_Byte)ss;
@ -136,13 +146,23 @@
} }
} }
/* mark ASCII digits */
for ( i = 0x30; i <= 0x39; i++ )
{
FT_UInt gindex = FT_Get_Char_Index( face, i );
if ( gindex != 0 && gindex < (FT_ULong)globals->glyph_count )
gscripts[gindex] |= AF_DIGIT;
}
Exit: Exit:
/* /*
* By default, all uncovered glyphs are set to the latin script. * By default, all uncovered glyphs are set to the latin script.
* XXX: Shouldn't we disable hinting or do something similar? * XXX: Shouldn't we disable hinting or do something similar?
*/ */
{ {
FT_UInt nn; FT_Long nn;
for ( nn = 0; nn < globals->glyph_count; nn++ ) for ( nn = 0; nn < globals->glyph_count; nn++ )
@ -201,7 +221,7 @@
{ {
if ( globals->metrics[nn] ) if ( globals->metrics[nn] )
{ {
AF_ScriptClass clazz = af_script_classes[nn]; AF_ScriptClass clazz = AF_SCRIPT_CLASSES_GET[nn];
FT_ASSERT( globals->metrics[nn]->clazz == clazz ); FT_ASSERT( globals->metrics[nn]->clazz == clazz );
@ -232,12 +252,12 @@
FT_UInt gidx; FT_UInt gidx;
AF_ScriptClass clazz; AF_ScriptClass clazz;
FT_UInt script = options & 15; FT_UInt script = options & 15;
const FT_UInt script_max = sizeof ( af_script_classes ) / const FT_Offset script_max = sizeof ( AF_SCRIPT_CLASSES_GET ) /
sizeof ( af_script_classes[0] ); sizeof ( AF_SCRIPT_CLASSES_GET[0] );
FT_Error error = AF_Err_Ok; FT_Error error = AF_Err_Ok;
if ( gindex >= globals->glyph_count ) if ( gindex >= (FT_ULong)globals->glyph_count )
{ {
error = AF_Err_Invalid_Argument; error = AF_Err_Invalid_Argument;
goto Exit; goto Exit;
@ -245,9 +265,9 @@
gidx = script; gidx = script;
if ( gidx == 0 || gidx + 1 >= script_max ) if ( gidx == 0 || gidx + 1 >= script_max )
gidx = globals->glyph_scripts[gindex]; gidx = globals->glyph_scripts[gindex] & AF_SCRIPT_LIST_NONE;
clazz = af_script_classes[gidx]; clazz = AF_SCRIPT_CLASSES_GET[gidx];
if ( script == 0 ) if ( script == 0 )
script = clazz->script; script = clazz->script;
@ -286,4 +306,15 @@
} }
FT_LOCAL_DEF( FT_Bool )
af_face_globals_is_digit( AF_FaceGlobals globals,
FT_UInt gindex )
{
if ( gindex < (FT_ULong)globals->glyph_count )
return (FT_Bool)( globals->glyph_scripts[gindex] & AF_DIGIT );
return (FT_Bool)0;
}
/* END */ /* END */

View File

@ -5,7 +5,7 @@
/* Auto-fitter routines to compute global hinting values */ /* Auto-fitter routines to compute global hinting values */
/* (specification). */ /* (specification). */
/* */ /* */
/* Copyright 2003, 2004, 2005, 2007 by */ /* Copyright 2003, 2004, 2005, 2007, 2009 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */ /* */
/* This file is part of the FreeType project, and may only be used, */ /* This file is part of the FreeType project, and may only be used, */
@ -56,6 +56,10 @@ FT_BEGIN_HEADER
FT_LOCAL( void ) FT_LOCAL( void )
af_face_globals_free( AF_FaceGlobals globals ); af_face_globals_free( AF_FaceGlobals globals );
FT_LOCAL_DEF( FT_Bool )
af_face_globals_is_digit( AF_FaceGlobals globals,
FT_UInt gindex );
/* */ /* */

View File

@ -34,7 +34,7 @@
{ {
FT_Int old_max = axis->max_segments; FT_Int old_max = axis->max_segments;
FT_Int new_max = old_max; FT_Int new_max = old_max;
FT_Int big_max = FT_INT_MAX / sizeof ( *segment ); FT_Int big_max = (FT_Int)( FT_INT_MAX / sizeof ( *segment ) );
if ( old_max >= big_max ) if ( old_max >= big_max )
@ -77,7 +77,7 @@
{ {
FT_Int old_max = axis->max_edges; FT_Int old_max = axis->max_edges;
FT_Int new_max = old_max; FT_Int new_max = old_max;
FT_Int big_max = FT_INT_MAX / sizeof ( *edge ); FT_Int big_max = (FT_Int)( FT_INT_MAX / sizeof ( *edge ) );
if ( old_max >= big_max ) if ( old_max >= big_max )
@ -645,6 +645,7 @@
FT_Int contour_index = 0; FT_Int contour_index = 0;
FT_UNUSED( first );
for ( point = points; point < point_limit; point++, vec++, tag++ ) for ( point = points; point < point_limit; point++, vec++, tag++ )
{ {
point->fx = (FT_Short)vec->x; point->fx = (FT_Short)vec->x;
@ -940,7 +941,7 @@
} }
{ {
FT_UInt min, max, mid; FT_PtrDist min, max, mid;
FT_Pos fpos; FT_Pos fpos;
@ -952,7 +953,7 @@
/* for small edge counts, a linear search is better */ /* for small edge counts, a linear search is better */
if ( max <= 8 ) if ( max <= 8 )
{ {
FT_UInt nn; FT_PtrDist nn;
for ( nn = 0; nn < max; nn++ ) for ( nn = 0; nn < max; nn++ )
if ( edges[nn].fpos >= u ) if ( edges[nn].fpos >= u )

View File

@ -81,16 +81,14 @@
static const AF_Script_UniRangeRec af_indic_uniranges[] = static const AF_Script_UniRangeRec af_indic_uniranges[] =
{ {
#if 0 #if 0
{ 0x0100, 0xFFFF }, /* why this? */ AF_UNIRANGE_REC( 0x0100UL, 0xFFFFUL ), /* why this? */
#endif #endif
{ 0x0900, 0x0DFF}, /* Indic Range */ AF_UNIRANGE_REC( 0x0900UL, 0x0DFFUL), /* Indic Range */
{ 0, 0 } AF_UNIRANGE_REC( 0UL, 0UL)
}; };
FT_CALLBACK_TABLE_DEF const AF_ScriptClassRec AF_DEFINE_SCRIPT_CLASS(af_indic_script_class,
af_indic_script_class =
{
AF_SCRIPT_INDIC, AF_SCRIPT_INDIC,
af_indic_uniranges, af_indic_uniranges,
@ -102,7 +100,7 @@
(AF_Script_InitHintsFunc) af_indic_hints_init, (AF_Script_InitHintsFunc) af_indic_hints_init,
(AF_Script_ApplyHintsFunc) af_indic_hints_apply (AF_Script_ApplyHintsFunc) af_indic_hints_apply
}; )
#else /* !AF_CONFIG_OPTION_INDIC */ #else /* !AF_CONFIG_OPTION_INDIC */
@ -112,9 +110,7 @@
}; };
FT_CALLBACK_TABLE_DEF const AF_ScriptClassRec AF_DEFINE_SCRIPT_CLASS(af_indic_script_class,
af_indic_script_class =
{
AF_SCRIPT_INDIC, AF_SCRIPT_INDIC,
af_indic_uniranges, af_indic_uniranges,
@ -126,7 +122,7 @@
(AF_Script_InitHintsFunc) NULL, (AF_Script_InitHintsFunc) NULL,
(AF_Script_ApplyHintsFunc) NULL (AF_Script_ApplyHintsFunc) NULL
}; )
#endif /* !AF_CONFIG_OPTION_INDIC */ #endif /* !AF_CONFIG_OPTION_INDIC */

View File

@ -27,8 +27,7 @@ FT_BEGIN_HEADER
/* the Indic-specific script class */ /* the Indic-specific script class */
FT_CALLBACK_TABLE const AF_ScriptClassRec AF_DECLARE_SCRIPT_CLASS(af_indic_script_class)
af_indic_script_class;
/* */ /* */

View File

@ -4,7 +4,7 @@
/* */ /* */
/* Auto-fitter hinting routines for latin script (body). */ /* Auto-fitter hinting routines for latin script (body). */
/* */ /* */
/* Copyright 2003, 2004, 2005, 2006, 2007, 2008 by */ /* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */ /* */
/* This file is part of the FreeType project, and may only be used, */ /* This file is part of the FreeType project, and may only be used, */
@ -16,6 +16,9 @@
/***************************************************************************/ /***************************************************************************/
#include <ft2build.h>
#include FT_ADVANCES_H
#include "aflatin.h" #include "aflatin.h"
#include "aferrors.h" #include "aferrors.h"
@ -146,7 +149,8 @@
#define AF_LATIN_MAX_TEST_CHARACTERS 12 #define AF_LATIN_MAX_TEST_CHARACTERS 12
static const char* const af_latin_blue_chars[AF_LATIN_MAX_BLUES] = static const char af_latin_blue_chars[AF_LATIN_MAX_BLUES]
[AF_LATIN_MAX_TEST_CHARACTERS + 1] =
{ {
"THEZOCQS", "THEZOCQS",
"HEZLOCUS", "HEZLOCUS",
@ -195,7 +199,8 @@
for ( ; p < limit && *p; p++ ) for ( ; p < limit && *p; p++ )
{ {
FT_UInt glyph_index; FT_UInt glyph_index;
FT_Int best_point, best_y, best_first, best_last; FT_Pos best_y; /* same as points.y */
FT_Int best_point, best_first, best_last;
FT_Vector* points; FT_Vector* points;
FT_Bool round = 0; FT_Bool round = 0;
@ -328,7 +333,7 @@
* we couldn't find a single glyph to compute this blue zone, * we couldn't find a single glyph to compute this blue zone,
* we will simply ignore it then * we will simply ignore it then
*/ */
AF_LOG(( "empty!\n" )); AF_LOG(( "empty\n" ));
continue; continue;
} }
@ -379,7 +384,7 @@
blue->flags |= AF_LATIN_BLUE_TOP; blue->flags |= AF_LATIN_BLUE_TOP;
/* /*
* The following flags is used later to adjust the y and x scales * The following flag is used later to adjust the y and x scales
* in order to optimize the pixel grid alignment of the top of small * in order to optimize the pixel grid alignment of the top of small
* letters. * letters.
*/ */
@ -393,6 +398,52 @@
} }
FT_LOCAL_DEF( void )
af_latin_metrics_check_digits( AF_LatinMetrics metrics,
FT_Face face )
{
FT_UInt i;
FT_Bool started = 0, same_width = 1;
/* check whether all ASCII digits have the same advance width; */
/* digit `0' is 0x30 in all supported charmaps */
for ( i = 0x30; i <= 0x39; i++ )
{
FT_UInt glyph_index;
FT_Fixed advance, old_advance = 0;
glyph_index = FT_Get_Char_Index( face, i );
if ( glyph_index == 0 )
continue;
if ( FT_Get_Advance( face, glyph_index,
FT_LOAD_NO_SCALE |
FT_LOAD_NO_HINTING |
FT_LOAD_IGNORE_TRANSFORM,
&advance ) )
continue;
if ( started )
{
if ( advance != old_advance )
{
same_width = 0;
break;
}
}
else
{
old_advance = advance;
started = 1;
}
}
metrics->root.digits_have_same_width = same_width;
}
FT_LOCAL_DEF( FT_Error ) FT_LOCAL_DEF( FT_Error )
af_latin_metrics_init( AF_LatinMetrics metrics, af_latin_metrics_init( AF_LatinMetrics metrics,
FT_Face face ) FT_Face face )
@ -426,6 +477,7 @@
/* For now, compute the standard width and height from the `o'. */ /* For now, compute the standard width and height from the `o'. */
af_latin_metrics_init_widths( metrics, face, 'o' ); af_latin_metrics_init_widths( metrics, face, 'o' );
af_latin_metrics_init_blues( metrics, face ); af_latin_metrics_init_blues( metrics, face );
af_latin_metrics_check_digits( metrics, face );
} }
FT_Set_Charmap( face, oldmap ); FT_Set_Charmap( face, oldmap );
@ -1567,7 +1619,7 @@
/* not hinted, appear a lot bolder or thinner than the */ /* not hinted, appear a lot bolder or thinner than the */
/* vertical stems. */ /* vertical stems. */
FT_Int delta; FT_Pos delta;
dist = ( dist + 22 ) & ~63; dist = ( dist + 22 ) & ~63;
@ -1651,7 +1703,7 @@
AF_AxisHints axis = &hints->axis[dim]; AF_AxisHints axis = &hints->axis[dim];
AF_Edge edges = axis->edges; AF_Edge edges = axis->edges;
AF_Edge edge_limit = edges + axis->num_edges; AF_Edge edge_limit = edges + axis->num_edges;
FT_Int n_edges; FT_PtrDist n_edges;
AF_Edge edge; AF_Edge edge;
AF_Edge anchor = 0; AF_Edge anchor = 0;
FT_Int has_serifs = 0; FT_Int has_serifs = 0;
@ -2127,39 +2179,37 @@
static const AF_Script_UniRangeRec af_latin_uniranges[] = static const AF_Script_UniRangeRec af_latin_uniranges[] =
{ {
{ 0x0020 , 0x007F }, /* Basic Latin (no control chars) */ AF_UNIRANGE_REC( 0x0020UL, 0x007FUL ), /* Basic Latin (no control chars) */
{ 0x00A0 , 0x00FF }, /* Latin-1 Supplement (no control chars) */ AF_UNIRANGE_REC( 0x00A0UL, 0x00FFUL ), /* Latin-1 Supplement (no control chars) */
{ 0x0100 , 0x017F }, /* Latin Extended-A */ AF_UNIRANGE_REC( 0x0100UL, 0x017FUL ), /* Latin Extended-A */
{ 0x0180 , 0x024F }, /* Latin Extended-B */ AF_UNIRANGE_REC( 0x0180UL, 0x024FUL ), /* Latin Extended-B */
{ 0x0250 , 0x02AF }, /* IPA Extensions */ AF_UNIRANGE_REC( 0x0250UL, 0x02AFUL ), /* IPA Extensions */
{ 0x02B0 , 0x02FF }, /* Spacing Modifier Letters */ AF_UNIRANGE_REC( 0x02B0UL, 0x02FFUL ), /* Spacing Modifier Letters */
{ 0x0300 , 0x036F }, /* Combining Diacritical Marks */ AF_UNIRANGE_REC( 0x0300UL, 0x036FUL ), /* Combining Diacritical Marks */
{ 0x0370 , 0x03FF }, /* Greek and Coptic */ AF_UNIRANGE_REC( 0x0370UL, 0x03FFUL ), /* Greek and Coptic */
{ 0x0400 , 0x04FF }, /* Cyrillic */ AF_UNIRANGE_REC( 0x0400UL, 0x04FFUL ), /* Cyrillic */
{ 0x0500 , 0x052F }, /* Cyrillic Supplement */ AF_UNIRANGE_REC( 0x0500UL, 0x052FUL ), /* Cyrillic Supplement */
{ 0x1D00 , 0x1D7F }, /* Phonetic Extensions */ AF_UNIRANGE_REC( 0x1D00UL, 0x1D7FUL ), /* Phonetic Extensions */
{ 0x1D80 , 0x1DBF }, /* Phonetic Extensions Supplement */ AF_UNIRANGE_REC( 0x1D80UL, 0x1DBFUL ), /* Phonetic Extensions Supplement */
{ 0x1DC0 , 0x1DFF }, /* Combining Diacritical Marks Supplement */ AF_UNIRANGE_REC( 0x1DC0UL, 0x1DFFUL ), /* Combining Diacritical Marks Supplement */
{ 0x1E00 , 0x1EFF }, /* Latin Extended Additional */ AF_UNIRANGE_REC( 0x1E00UL, 0x1EFFUL ), /* Latin Extended Additional */
{ 0x1F00 , 0x1FFF }, /* Greek Extended */ AF_UNIRANGE_REC( 0x1F00UL, 0x1FFFUL ), /* Greek Extended */
{ 0x2000 , 0x206F }, /* General Punctuation */ AF_UNIRANGE_REC( 0x2000UL, 0x206FUL ), /* General Punctuation */
{ 0x2070 , 0x209F }, /* Superscripts and Subscripts */ AF_UNIRANGE_REC( 0x2070UL, 0x209FUL ), /* Superscripts and Subscripts */
{ 0x20A0 , 0x20CF }, /* Currency Symbols */ AF_UNIRANGE_REC( 0x20A0UL, 0x20CFUL ), /* Currency Symbols */
{ 0x2150 , 0x218F }, /* Number Forms */ AF_UNIRANGE_REC( 0x2150UL, 0x218FUL ), /* Number Forms */
{ 0x2460 , 0x24FF }, /* Enclosed Alphanumerics */ AF_UNIRANGE_REC( 0x2460UL, 0x24FFUL ), /* Enclosed Alphanumerics */
{ 0x2C60 , 0x2C7F }, /* Latin Extended-C */ AF_UNIRANGE_REC( 0x2C60UL, 0x2C7FUL ), /* Latin Extended-C */
{ 0x2DE0 , 0x2DFF }, /* Cyrillic Extended-A */ AF_UNIRANGE_REC( 0x2DE0UL, 0x2DFFUL ), /* Cyrillic Extended-A */
{ 0xA640U , 0xA69FU }, /* Cyrillic Extended-B */ AF_UNIRANGE_REC( 0xA640UL, 0xA69FUL ), /* Cyrillic Extended-B */
{ 0xA720U , 0xA7FFU }, /* Latin Extended-D */ AF_UNIRANGE_REC( 0xA720UL, 0xA7FFUL ), /* Latin Extended-D */
{ 0xFB00U , 0xFB06U }, /* Alphab. Present. Forms (Latin Ligs) */ AF_UNIRANGE_REC( 0xFB00UL, 0xFB06UL ), /* Alphab. Present. Forms (Latin Ligs) */
{ 0x1D400UL, 0x1D7FFUL }, /* Mathematical Alphanumeric Symbols */ AF_UNIRANGE_REC( 0x1D400UL, 0x1D7FFUL ), /* Mathematical Alphanumeric Symbols */
{ 0 , 0 } AF_UNIRANGE_REC( 0UL, 0UL )
}; };
FT_CALLBACK_TABLE_DEF const AF_ScriptClassRec AF_DEFINE_SCRIPT_CLASS(af_latin_script_class,
af_latin_script_class =
{
AF_SCRIPT_LATIN, AF_SCRIPT_LATIN,
af_latin_uniranges, af_latin_uniranges,
@ -2171,7 +2221,7 @@
(AF_Script_InitHintsFunc) af_latin_hints_init, (AF_Script_InitHintsFunc) af_latin_hints_init,
(AF_Script_ApplyHintsFunc) af_latin_hints_apply (AF_Script_ApplyHintsFunc) af_latin_hints_apply
}; )
/* END */ /* END */

View File

@ -4,7 +4,7 @@
/* */ /* */
/* Auto-fitter hinting routines for latin script (specification). */ /* Auto-fitter hinting routines for latin script (specification). */
/* */ /* */
/* Copyright 2003, 2004, 2005, 2006, 2007 by */ /* Copyright 2003, 2004, 2005, 2006, 2007, 2009 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */ /* */
/* This file is part of the FreeType project, and may only be used, */ /* This file is part of the FreeType project, and may only be used, */
@ -27,8 +27,7 @@ FT_BEGIN_HEADER
/* the latin-specific script class */ /* the latin-specific script class */
FT_CALLBACK_TABLE const AF_ScriptClassRec AF_DECLARE_SCRIPT_CLASS(af_latin_script_class)
af_latin_script_class;
/* constants are given with units_per_em == 2048 in mind */ /* constants are given with units_per_em == 2048 in mind */
@ -138,6 +137,10 @@ FT_BEGIN_HEADER
FT_Face face, FT_Face face,
FT_ULong charcode ); FT_ULong charcode );
FT_LOCAL( void )
af_latin_metrics_check_digits( AF_LatinMetrics metrics,
FT_Face face );
/*************************************************************************/ /*************************************************************************/
/*************************************************************************/ /*************************************************************************/

View File

@ -4,7 +4,7 @@
/* */ /* */
/* Auto-fitter hinting routines for latin script (body). */ /* Auto-fitter hinting routines for latin script (body). */
/* */ /* */
/* Copyright 2003, 2004, 2005, 2006, 2007, 2008 by */ /* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */ /* */
/* This file is part of the FreeType project, and may only be used, */ /* This file is part of the FreeType project, and may only be used, */
@ -16,6 +16,8 @@
/***************************************************************************/ /***************************************************************************/
#include FT_ADVANCES_H
#include "aflatin.h" #include "aflatin.h"
#include "aflatin2.h" #include "aflatin2.h"
#include "aferrors.h" #include "aferrors.h"
@ -154,7 +156,7 @@
#define AF_LATIN_MAX_TEST_CHARACTERS 12 #define AF_LATIN_MAX_TEST_CHARACTERS 12
static const char* const af_latin2_blue_chars[AF_LATIN_MAX_BLUES] = static const char af_latin2_blue_chars[AF_LATIN_MAX_BLUES][AF_LATIN_MAX_TEST_CHARACTERS+1] =
{ {
"THEZOCQS", "THEZOCQS",
"HEZLOCUS", "HEZLOCUS",
@ -336,7 +338,7 @@
* we couldn't find a single glyph to compute this blue zone, * we couldn't find a single glyph to compute this blue zone,
* we will simply ignore it then * we will simply ignore it then
*/ */
AF_LOG(( "empty!\n" )); AF_LOG(( "empty\n" ));
continue; continue;
} }
@ -401,6 +403,52 @@
} }
FT_LOCAL_DEF( void )
af_latin2_metrics_check_digits( AF_LatinMetrics metrics,
FT_Face face )
{
FT_UInt i;
FT_Bool started = 0, same_width = 1;
/* check whether all ASCII digits have the same advance width; */
/* digit `0' is 0x30 in all supported charmaps */
for ( i = 0x30; i <= 0x39; i++ )
{
FT_UInt glyph_index;
FT_Fixed advance, old_advance;
glyph_index = FT_Get_Char_Index( face, i );
if ( glyph_index == 0 )
continue;
if ( FT_Get_Advance( face, glyph_index,
FT_LOAD_NO_SCALE |
FT_LOAD_NO_HINTING |
FT_LOAD_IGNORE_TRANSFORM,
&advance ) )
continue;
if ( started )
{
if ( advance != old_advance )
{
same_width = 0;
break;
}
}
else
{
old_advance = advance;
started = 1;
}
}
metrics->root.digits_have_same_width = same_width;
}
FT_LOCAL_DEF( FT_Error ) FT_LOCAL_DEF( FT_Error )
af_latin2_metrics_init( AF_LatinMetrics metrics, af_latin2_metrics_init( AF_LatinMetrics metrics,
FT_Face face ) FT_Face face )
@ -434,6 +482,7 @@
/* For now, compute the standard width and height from the `o'. */ /* For now, compute the standard width and height from the `o'. */
af_latin2_metrics_init_widths( metrics, face, 'o' ); af_latin2_metrics_init_widths( metrics, face, 'o' );
af_latin2_metrics_init_blues( metrics, face ); af_latin2_metrics_init_blues( metrics, face );
af_latin2_metrics_check_digits( metrics, face );
} }
FT_Set_Charmap( face, oldmap ); FT_Set_Charmap( face, oldmap );
@ -1739,7 +1788,6 @@
AF_AxisHints axis = &hints->axis[dim]; AF_AxisHints axis = &hints->axis[dim];
AF_Edge edges = axis->edges; AF_Edge edges = axis->edges;
AF_Edge edge_limit = edges + axis->num_edges; AF_Edge edge_limit = edges + axis->num_edges;
FT_Int n_edges;
AF_Edge edge; AF_Edge edge;
AF_Edge anchor = 0; AF_Edge anchor = 0;
FT_Int has_serifs = 0; FT_Int has_serifs = 0;
@ -2050,8 +2098,12 @@
/* We don't handle horizontal edges since we can't easily assure that */ /* We don't handle horizontal edges since we can't easily assure that */
/* the third (lowest) stem aligns with the base line; it might end up */ /* the third (lowest) stem aligns with the base line; it might end up */
/* one pixel higher or lower. */ /* one pixel higher or lower. */
#if 0 #if 0
n_edges = edge_limit - edges; {
FT_Int n_edges = edge_limit - edges;
if ( dim == AF_DIMENSION_HORZ && ( n_edges == 6 || n_edges == 12 ) ) if ( dim == AF_DIMENSION_HORZ && ( n_edges == 6 || n_edges == 12 ) )
{ {
AF_Edge edge1, edge2, edge3; AF_Edge edge1, edge2, edge3;
@ -2097,7 +2149,9 @@
edge3->link->flags |= AF_EDGE_DONE; edge3->link->flags |= AF_EDGE_DONE;
} }
} }
}
#endif #endif
if ( has_serifs || !anchor ) if ( has_serifs || !anchor )
{ {
/* /*
@ -2266,15 +2320,13 @@
static const AF_Script_UniRangeRec af_latin2_uniranges[] = static const AF_Script_UniRangeRec af_latin2_uniranges[] =
{ {
{ 32, 127 }, /* XXX: TODO: Add new Unicode ranges here! */ AF_UNIRANGE_REC( 32UL, 127UL ), /* XXX: TODO: Add new Unicode ranges here! */
{ 160, 255 }, AF_UNIRANGE_REC( 160UL, 255UL ),
{ 0, 0 } AF_UNIRANGE_REC( 0UL, 0UL )
}; };
FT_CALLBACK_TABLE_DEF const AF_ScriptClassRec AF_DEFINE_SCRIPT_CLASS(af_latin2_script_class,
af_latin2_script_class =
{
AF_SCRIPT_LATIN2, AF_SCRIPT_LATIN2,
af_latin2_uniranges, af_latin2_uniranges,
@ -2286,7 +2338,7 @@
(AF_Script_InitHintsFunc) af_latin2_hints_init, (AF_Script_InitHintsFunc) af_latin2_hints_init,
(AF_Script_ApplyHintsFunc) af_latin2_hints_apply (AF_Script_ApplyHintsFunc) af_latin2_hints_apply
}; )
/* END */ /* END */

View File

@ -27,8 +27,7 @@ FT_BEGIN_HEADER
/* the latin-specific script class */ /* the latin-specific script class */
FT_CALLBACK_TABLE const AF_ScriptClassRec AF_DECLARE_SCRIPT_CLASS(af_latin2_script_class)
af_latin2_script_class;
/* */ /* */

View File

@ -4,7 +4,7 @@
/* */ /* */
/* Auto-fitter glyph loading routines (body). */ /* Auto-fitter glyph loading routines (body). */
/* */ /* */
/* Copyright 2003, 2004, 2005, 2006, 2007, 2008 by */ /* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */ /* */
/* This file is part of the FreeType project, and may only be used, */ /* This file is part of the FreeType project, and may only be used, */
@ -19,7 +19,6 @@
#include "afloader.h" #include "afloader.h"
#include "afhints.h" #include "afhints.h"
#include "afglobal.h" #include "afglobal.h"
#include "aflatin.h"
#include "aferrors.h" #include "aferrors.h"
@ -220,6 +219,7 @@
FT_Pos pp1x = loader->pp1.x; FT_Pos pp1x = loader->pp1.x;
FT_Pos pp2x = loader->pp2.x; FT_Pos pp2x = loader->pp2.x;
loader->pp1.x = FT_PIX_ROUND( pp1x ); loader->pp1.x = FT_PIX_ROUND( pp1x );
loader->pp2.x = FT_PIX_ROUND( pp2x ); loader->pp2.x = FT_PIX_ROUND( pp2x );
@ -232,6 +232,7 @@
FT_Pos pp1x = loader->pp1.x; FT_Pos pp1x = loader->pp1.x;
FT_Pos pp2x = loader->pp2.x; FT_Pos pp2x = loader->pp2.x;
loader->pp1.x = FT_PIX_ROUND( pp1x + hints->xmin_delta ); loader->pp1.x = FT_PIX_ROUND( pp1x + hints->xmin_delta );
loader->pp2.x = FT_PIX_ROUND( pp2x + hints->xmax_delta ); loader->pp2.x = FT_PIX_ROUND( pp2x + hints->xmax_delta );
@ -413,7 +414,8 @@
slot->metrics.vertBearingY = FT_PIX_FLOOR( bbox.yMax + vvector.y ); slot->metrics.vertBearingY = FT_PIX_FLOOR( bbox.yMax + vvector.y );
/* for mono-width fonts (like Andale, Courier, etc.) we need */ /* for mono-width fonts (like Andale, Courier, etc.) we need */
/* to keep the original rounded advance width */ /* to keep the original rounded advance width; ditto for */
/* digits if all have the same advance width */
#if 0 #if 0
if ( !FT_IS_FIXED_WIDTH( slot->face ) ) if ( !FT_IS_FIXED_WIDTH( slot->face ) )
slot->metrics.horiAdvance = loader->pp2.x - loader->pp1.x; slot->metrics.horiAdvance = loader->pp2.x - loader->pp1.x;
@ -421,13 +423,9 @@
slot->metrics.horiAdvance = FT_MulFix( slot->metrics.horiAdvance, slot->metrics.horiAdvance = FT_MulFix( slot->metrics.horiAdvance,
x_scale ); x_scale );
#else #else
if ( !FT_IS_FIXED_WIDTH( slot->face ) ) if ( FT_IS_FIXED_WIDTH( slot->face ) ||
{ ( af_face_globals_is_digit( loader->globals, glyph_index ) &&
/* non-spacing glyphs must stay as-is */ metrics->digits_have_same_width ) )
if ( slot->metrics.horiAdvance )
slot->metrics.horiAdvance = loader->pp2.x - loader->pp1.x;
}
else
{ {
slot->metrics.horiAdvance = FT_MulFix( slot->metrics.horiAdvance, slot->metrics.horiAdvance = FT_MulFix( slot->metrics.horiAdvance,
metrics->scaler.x_scale ); metrics->scaler.x_scale );
@ -437,6 +435,12 @@
slot->lsb_delta = 0; slot->lsb_delta = 0;
slot->rsb_delta = 0; slot->rsb_delta = 0;
} }
else
{
/* non-spacing glyphs must stay as-is */
if ( slot->metrics.horiAdvance )
slot->metrics.horiAdvance = loader->pp2.x - loader->pp1.x;
}
#endif #endif
slot->metrics.vertAdvance = FT_MulFix( slot->metrics.vertAdvance, slot->metrics.vertAdvance = FT_MulFix( slot->metrics.vertAdvance,

View File

@ -18,6 +18,7 @@
#include "afmodule.h" #include "afmodule.h"
#include "afloader.h" #include "afloader.h"
#include "afpic.h"
#ifdef AF_DEBUG #ifdef AF_DEBUG
int _af_debug; int _af_debug;
@ -66,19 +67,15 @@
} }
FT_CALLBACK_TABLE_DEF FT_DEFINE_AUTOHINTER_SERVICE(af_autofitter_service,
const FT_AutoHinter_ServiceRec af_autofitter_service =
{
NULL, NULL,
NULL, NULL,
NULL, NULL,
(FT_AutoHinter_GlyphLoadFunc)af_autofitter_load_glyph (FT_AutoHinter_GlyphLoadFunc)af_autofitter_load_glyph
}; )
FT_DEFINE_MODULE(autofit_module_class,
FT_CALLBACK_TABLE_DEF
const FT_Module_Class autofit_module_class =
{
FT_MODULE_HINTER, FT_MODULE_HINTER,
sizeof ( FT_AutofitterRec ), sizeof ( FT_AutofitterRec ),
@ -86,12 +83,12 @@
0x10000L, /* version 1.0 of the autofitter */ 0x10000L, /* version 1.0 of the autofitter */
0x20000L, /* requires FreeType 2.0 or above */ 0x20000L, /* requires FreeType 2.0 or above */
(const void*)&af_autofitter_service, (const void*)&AF_AF_AUTOFITTER_SERVICE_GET,
(FT_Module_Constructor)af_autofitter_init, (FT_Module_Constructor)af_autofitter_init,
(FT_Module_Destructor) af_autofitter_done, (FT_Module_Destructor) af_autofitter_done,
(FT_Module_Requester) NULL (FT_Module_Requester) NULL
}; )
/* END */ /* END */

View File

@ -20,13 +20,13 @@
#define __AFMODULE_H__ #define __AFMODULE_H__
#include <ft2build.h> #include <ft2build.h>
#include FT_INTERNAL_OBJECTS_H
#include FT_MODULE_H #include FT_MODULE_H
FT_BEGIN_HEADER FT_BEGIN_HEADER
FT_CALLBACK_TABLE FT_DECLARE_MODULE(autofit_module_class)
const FT_Module_Class autofit_module_class;
FT_END_HEADER FT_END_HEADER

View File

@ -0,0 +1,92 @@
/***************************************************************************/
/* */
/* afpic.c */
/* */
/* The FreeType position independent code services for autofit module. */
/* */
/* 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 "afpic.h"
#ifdef FT_CONFIG_OPTION_PIC
/* forward declaration of PIC init functions from afmodule.c */
void FT_Init_Class_af_autofitter_service( FT_Library, FT_AutoHinter_ServiceRec*);
/* forward declaration of PIC init functions from script classes */
#include "aflatin.h"
#include "aflatin2.h"
#include "afcjk.h"
#include "afdummy.h"
#include "afindic.h"
void
autofit_module_class_pic_free( FT_Library library )
{
FT_PIC_Container* pic_container = &library->pic_container;
FT_Memory memory = library->memory;
if ( pic_container->autofit )
{
FT_FREE( pic_container->autofit );
pic_container->autofit = NULL;
}
}
FT_Error
autofit_module_class_pic_init( FT_Library library )
{
FT_PIC_Container* pic_container = &library->pic_container;
FT_UInt ss;
FT_Error error = FT_Err_Ok;
AFModulePIC* 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->autofit = container;
/* initialize pointer table - this is how the module usually expects this data */
for ( ss = 0 ; ss < AF_SCRIPT_CLASSES_REC_COUNT ; ss++ )
{
container->af_script_classes[ss] = &container->af_script_classes_rec[ss];
}
container->af_script_classes[AF_SCRIPT_CLASSES_COUNT-1] = NULL;
/* add call to initialization function when you add new scripts */
ss = 0;
FT_Init_Class_af_dummy_script_class(&container->af_script_classes_rec[ss++]);
#ifdef FT_OPTION_AUTOFIT2
FT_Init_Class_af_latin2_script_class(&container->af_script_classes_rec[ss++]);
#endif
FT_Init_Class_af_latin_script_class(&container->af_script_classes_rec[ss++]);
FT_Init_Class_af_cjk_script_class(&container->af_script_classes_rec[ss++]);
FT_Init_Class_af_indic_script_class(&container->af_script_classes_rec[ss++]);
FT_Init_Class_af_autofitter_service(library, &container->af_autofitter_service);
/*Exit:*/
if(error)
autofit_module_class_pic_free(library);
return error;
}
#endif /* FT_CONFIG_OPTION_PIC */
/* END */

View File

@ -0,0 +1,64 @@
/***************************************************************************/
/* */
/* afpic.h */
/* */
/* The FreeType position independent code services for autofit module. */
/* */
/* 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 __AFPIC_H__
#define __AFPIC_H__
FT_BEGIN_HEADER
#include FT_INTERNAL_PIC_H
#ifndef FT_CONFIG_OPTION_PIC
#define AF_SCRIPT_CLASSES_GET af_script_classes
#define AF_AF_AUTOFITTER_SERVICE_GET af_autofitter_service
#else /* FT_CONFIG_OPTION_PIC */
#include "aftypes.h"
/* increase these when you add new scripts, and update autofit_module_class_pic_init */
#ifdef FT_OPTION_AUTOFIT2
#define AF_SCRIPT_CLASSES_COUNT 6
#else
#define AF_SCRIPT_CLASSES_COUNT 5
#endif
#define AF_SCRIPT_CLASSES_REC_COUNT (AF_SCRIPT_CLASSES_COUNT-1)
typedef struct AFModulePIC_
{
AF_ScriptClass af_script_classes[AF_SCRIPT_CLASSES_COUNT];
AF_ScriptClassRec af_script_classes_rec[AF_SCRIPT_CLASSES_REC_COUNT];
FT_AutoHinter_ServiceRec af_autofitter_service;
} AFModulePIC;
#define GET_PIC(lib) ((AFModulePIC*)((lib)->pic_container.autofit))
#define AF_SCRIPT_CLASSES_GET (GET_PIC(FT_FACE_LIBRARY(globals->face))->af_script_classes)
#define AF_AF_AUTOFITTER_SERVICE_GET (GET_PIC(library)->af_autofitter_service)
#endif /* FT_CONFIG_OPTION_PIC */
/* */
FT_END_HEADER
#endif /* __AFPIC_H__ */
/* END */

View File

@ -285,6 +285,7 @@ extern void* _af_debug_hints;
{ {
AF_ScriptClass clazz; AF_ScriptClass clazz;
AF_ScalerRec scaler; AF_ScalerRec scaler;
FT_Bool digits_have_same_width;
} AF_ScriptMetricsRec, *AF_ScriptMetrics; } AF_ScriptMetricsRec, *AF_ScriptMetrics;
@ -321,6 +322,8 @@ extern void* _af_debug_hints;
} AF_Script_UniRangeRec; } AF_Script_UniRangeRec;
#define AF_UNIRANGE_REC( a, b ) { (FT_UInt32)(a), (FT_UInt32)(b) }
typedef const AF_Script_UniRangeRec *AF_Script_UniRange; typedef const AF_Script_UniRangeRec *AF_Script_UniRange;
@ -329,7 +332,7 @@ extern void* _af_debug_hints;
AF_Script script; AF_Script script;
AF_Script_UniRange script_uni_ranges; /* last must be { 0, 0 } */ AF_Script_UniRange script_uni_ranges; /* last must be { 0, 0 } */
FT_UInt script_metrics_size; FT_Offset script_metrics_size;
AF_Script_InitMetricsFunc script_metrics_init; AF_Script_InitMetricsFunc script_metrics_init;
AF_Script_ScaleMetricsFunc script_metrics_scale; AF_Script_ScaleMetricsFunc script_metrics_scale;
AF_Script_DoneMetricsFunc script_metrics_done; AF_Script_DoneMetricsFunc script_metrics_done;
@ -339,6 +342,56 @@ extern void* _af_debug_hints;
} AF_ScriptClassRec; } AF_ScriptClassRec;
/* Declare and define vtables for classes */
#ifndef FT_CONFIG_OPTION_PIC
#define AF_DECLARE_SCRIPT_CLASS(script_class) \
FT_CALLBACK_TABLE const AF_ScriptClassRec \
script_class;
#define AF_DEFINE_SCRIPT_CLASS(script_class, script_, ranges, m_size, \
m_init, m_scale, m_done, h_init, h_apply) \
FT_CALLBACK_TABLE_DEF const AF_ScriptClassRec \
script_class = \
{ \
script_, \
ranges, \
\
m_size, \
\
m_init, \
m_scale, \
m_done, \
\
h_init, \
h_apply \
};
#else
#define AF_DECLARE_SCRIPT_CLASS(script_class) \
FT_LOCAL(void) \
FT_Init_Class_##script_class(AF_ScriptClassRec* ac);
#define AF_DEFINE_SCRIPT_CLASS(script_class, script_, ranges, m_size, \
m_init, m_scale, m_done, h_init, h_apply) \
FT_LOCAL_DEF(void) \
FT_Init_Class_##script_class(AF_ScriptClassRec* ac) \
{ \
ac->script = script_; \
ac->script_uni_ranges = ranges; \
\
ac->script_metrics_size = m_size; \
\
ac->script_metrics_init = m_init; \
ac->script_metrics_scale = m_scale; \
ac->script_metrics_done = m_done; \
\
ac->script_hints_init = h_init; \
ac->script_hints_apply = h_apply; \
}
#endif
/* */ /* */

View File

@ -18,6 +18,7 @@
#define FT_MAKE_OPTION_SINGLE_OBJECT #define FT_MAKE_OPTION_SINGLE_OBJECT
#include <ft2build.h> #include <ft2build.h>
#include "afpic.c"
#include "afangles.c" #include "afangles.c"
#include "afglobal.c" #include "afglobal.c"
#include "afhints.c" #include "afhints.c"

View File

@ -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 */

View File

@ -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 */

View File

@ -140,7 +140,7 @@
if ( flags & FT_ADVANCE_FLAG_FAST_ONLY ) if ( flags & FT_ADVANCE_FLAG_FAST_ONLY )
return FT_Err_Unimplemented_Feature; return FT_Err_Unimplemented_Feature;
flags |= FT_LOAD_ADVANCE_ONLY; flags |= (FT_UInt32)FT_LOAD_ADVANCE_ONLY;
for ( nn = 0; nn < count; nn++ ) for ( nn = 0; nn < count; nn++ )
{ {
error = FT_Load_Glyph( face, start + nn, flags ); error = FT_Load_Glyph( face, start + nn, flags );

View File

@ -4,7 +4,7 @@
/* */ /* */
/* Single object library component (body only). */ /* 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. */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */ /* */
/* This file is part of the FreeType project, and may only be used, */ /* This file is part of the FreeType project, and may only be used, */
@ -20,14 +20,16 @@
#define FT_MAKE_OPTION_SINGLE_OBJECT #define FT_MAKE_OPTION_SINGLE_OBJECT
#include "ftpic.c"
#include "basepic.c"
#include "ftadvanc.c" #include "ftadvanc.c"
#include "ftcalc.c" #include "ftcalc.c"
#include "ftdbgmem.c" #include "ftdbgmem.c"
#include "ftgloadr.c" #include "ftgloadr.c"
#include "ftnames.c"
#include "ftobjs.c" #include "ftobjs.c"
#include "ftoutln.c" #include "ftoutln.c"
#include "ftrfork.c" #include "ftrfork.c"
#include "ftsnames.c"
#include "ftstream.c" #include "ftstream.c"
#include "fttrigon.c" #include "fttrigon.c"
#include "ftutil.c" #include "ftutil.c"

View File

@ -29,6 +29,7 @@
#include FT_IMAGE_H #include FT_IMAGE_H
#include FT_OUTLINE_H #include FT_OUTLINE_H
#include FT_INTERNAL_CALC_H #include FT_INTERNAL_CALC_H
#include FT_INTERNAL_OBJECTS_H
typedef struct TBBox_Rec_ typedef struct TBBox_Rec_
@ -559,6 +560,13 @@
return 0; 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 */ /* documentation is in ftbbox.h */
@ -628,18 +636,13 @@
/* the two boxes are different, now walk over the outline to */ /* the two boxes are different, now walk over the outline to */
/* get the Bezier arc extrema. */ /* 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; FT_Error error;
TBBox_Rec user; TBBox_Rec user;
#ifdef FT_CONFIG_OPTION_PIC
FT_Outline_Funcs bbox_interface;
Init_Class_bbox_interface(&bbox_interface);
#endif
user.bbox = bbox; user.bbox = bbox;

View File

@ -228,8 +228,12 @@
if ( !bitmap || !bitmap->buffer ) if ( !bitmap || !bitmap->buffer )
return FT_Err_Invalid_Argument; return FT_Err_Invalid_Argument;
xstr = FT_PIX_ROUND( xStrength ) >> 6; if ( ( ( FT_PIX_ROUND( xStrength ) >> 6 ) > FT_INT_MAX ) ||
ystr = FT_PIX_ROUND( yStrength ) >> 6; ( ( 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 ) if ( xstr == 0 && ystr == 0 )
return FT_Err_Ok; return FT_Err_Ok;

View File

@ -110,12 +110,12 @@
FT_EXPORT_DEF( FT_Int32 ) FT_EXPORT_DEF( FT_Int32 )
FT_Sqrt32( FT_Int32 x ) FT_Sqrt32( FT_Int32 x )
{ {
FT_ULong val, root, newroot, mask; FT_UInt32 val, root, newroot, mask;
root = 0; root = 0;
mask = 0x40000000L; mask = (FT_UInt32)0x40000000UL;
val = (FT_ULong)x; val = (FT_UInt32)x;
do do
{ {
@ -362,6 +362,7 @@
long s; long s;
/* XXX: this function does not allow 64-bit arguments */
if ( a == 0 || b == c ) if ( a == 0 || b == c )
return a; return a;
@ -377,12 +378,12 @@
FT_Int64 temp, temp2; FT_Int64 temp, temp2;
ft_multo64( a, b, &temp ); ft_multo64( (FT_Int32)a, (FT_Int32)b, &temp );
temp2.hi = 0; temp2.hi = 0;
temp2.lo = (FT_UInt32)(c >> 1); temp2.lo = (FT_UInt32)(c >> 1);
FT_Add64( &temp, &temp2, &temp ); FT_Add64( &temp, &temp2, &temp );
a = ft_div64by32( temp.hi, temp.lo, c ); a = ft_div64by32( temp.hi, temp.lo, (FT_Int32)c );
} }
else else
a = 0x7FFFFFFFL; a = 0x7FFFFFFFL;
@ -416,8 +417,8 @@
FT_Int64 temp; FT_Int64 temp;
ft_multo64( a, b, &temp ); ft_multo64( (FT_Int32)a, (FT_Int32)b, &temp );
a = ft_div64by32( temp.hi, temp.lo, c ); a = ft_div64by32( temp.hi, temp.lo, (FT_Int32)c );
} }
else else
a = 0x7FFFFFFFL; a = 0x7FFFFFFFL;
@ -539,13 +540,14 @@
FT_UInt32 q; FT_UInt32 q;
s = a; a = FT_ABS( a ); /* XXX: this function does not allow 64-bit arguments */
s ^= b; b = FT_ABS( b ); s = (FT_Int32)a; a = FT_ABS( a );
s ^= (FT_Int32)b; b = FT_ABS( b );
if ( b == 0 ) if ( b == 0 )
{ {
/* check for division by 0 */ /* check for division by 0 */
q = 0x7FFFFFFFL; q = (FT_UInt32)0x7FFFFFFFL;
} }
else if ( ( a >> 16 ) == 0 ) else if ( ( a >> 16 ) == 0 )
{ {
@ -562,7 +564,7 @@
temp2.hi = 0; temp2.hi = 0;
temp2.lo = (FT_UInt32)( b >> 1 ); temp2.lo = (FT_UInt32)( b >> 1 );
FT_Add64( &temp, &temp2, &temp ); 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 ); return ( s < 0 ? -(FT_Int32)q : (FT_Int32)q );
@ -840,7 +842,7 @@
FT_Pos out_x, FT_Pos out_x,
FT_Pos out_y ) FT_Pos out_y )
{ {
FT_Int result; FT_Long result; /* avoid overflow on 16-bit system */
/* deal with the trivial cases quickly */ /* deal with the trivial cases quickly */
@ -889,8 +891,9 @@
FT_Int64 z1, z2; FT_Int64 z1, z2;
ft_multo64( in_x, out_y, &z1 ); /* XXX: this function does not allow 64-bit arguments */
ft_multo64( in_y, out_x, &z2 ); 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 ) if ( z1.hi > z2.hi )
result = +1; result = +1;
@ -906,7 +909,8 @@
#endif #endif
} }
return result; /* XXX: only the sign of return value, +1/0/-1 must be used */
return (FT_Int)result;
} }

View File

@ -421,7 +421,7 @@
"FreeType: %ld bytes of memory leaked in %ld blocks\n", "FreeType: %ld bytes of memory leaked in %ld blocks\n",
leaks, leak_count ); leaks, leak_count );
printf( "FreeType: No memory leaks detected!\n" ); printf( "FreeType: no memory leaks detected\n" );
} }
} }

View File

@ -218,6 +218,9 @@
{ {
new_max = FT_PAD_CEIL( new_max, 8 ); 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 ) || if ( FT_RENEW_ARRAY( base->points, old_max, new_max ) ||
FT_RENEW_ARRAY( base->tags, old_max, new_max ) ) FT_RENEW_ARRAY( base->tags, old_max, new_max ) )
goto Exit; goto Exit;
@ -246,6 +249,10 @@
if ( new_max > old_max ) if ( new_max > old_max )
{ {
new_max = FT_PAD_CEIL( new_max, 4 ); 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 ) ) if ( FT_RENEW_ARRAY( base->contours, old_max, new_max ) )
goto Exit; goto Exit;

View File

@ -34,6 +34,7 @@
#include FT_BITMAP_H #include FT_BITMAP_H
#include FT_INTERNAL_OBJECTS_H #include FT_INTERNAL_OBJECTS_H
#include "basepic.h"
/*************************************************************************/ /*************************************************************************/
/* */ /* */
@ -129,9 +130,7 @@
} }
FT_CALLBACK_TABLE_DEF FT_DEFINE_GLYPH(ft_bitmap_glyph_class,
const FT_Glyph_Class ft_bitmap_glyph_class =
{
sizeof ( FT_BitmapGlyphRec ), sizeof ( FT_BitmapGlyphRec ),
FT_GLYPH_FORMAT_BITMAP, FT_GLYPH_FORMAT_BITMAP,
@ -141,7 +140,7 @@
0, /* FT_Glyph_TransformFunc */ 0, /* FT_Glyph_TransformFunc */
ft_bitmap_glyph_bbox, ft_bitmap_glyph_bbox,
0 /* FT_Glyph_PrepareFunc */ 0 /* FT_Glyph_PrepareFunc */
}; )
/*************************************************************************/ /*************************************************************************/
@ -255,9 +254,7 @@
} }
FT_CALLBACK_TABLE_DEF FT_DEFINE_GLYPH( ft_outline_glyph_class,
const FT_Glyph_Class ft_outline_glyph_class =
{
sizeof ( FT_OutlineGlyphRec ), sizeof ( FT_OutlineGlyphRec ),
FT_GLYPH_FORMAT_OUTLINE, FT_GLYPH_FORMAT_OUTLINE,
@ -267,7 +264,7 @@
ft_outline_glyph_transform, ft_outline_glyph_transform,
ft_outline_glyph_bbox, ft_outline_glyph_bbox,
ft_outline_glyph_prepare ft_outline_glyph_prepare
}; )
/*************************************************************************/ /*************************************************************************/
@ -373,11 +370,11 @@
/* if it is a bitmap, that's easy :-) */ /* if it is a bitmap, that's easy :-) */
if ( slot->format == FT_GLYPH_FORMAT_BITMAP ) if ( slot->format == FT_GLYPH_FORMAT_BITMAP )
clazz = &ft_bitmap_glyph_class; clazz = FT_BITMAP_GLYPH_CLASS_GET;
/* it it is an outline too */ /* it it is an outline too */
else if ( slot->format == FT_GLYPH_FORMAT_OUTLINE ) else if ( slot->format == FT_GLYPH_FORMAT_OUTLINE )
clazz = &ft_outline_glyph_class; clazz = FT_OUTLINE_GLYPH_CLASS_GET;
else else
{ {
@ -533,7 +530,7 @@
clazz = glyph->clazz; clazz = glyph->clazz;
/* when called with a bitmap glyph, do nothing and return successfully */ /* 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; goto Exit;
if ( !clazz || !clazz->glyph_prepare ) if ( !clazz || !clazz->glyph_prepare )
@ -546,7 +543,7 @@
dummy.format = clazz->glyph_format; dummy.format = clazz->glyph_format;
/* create result bitmap glyph */ /* 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 ); (FT_Glyph*)(void*)&bitmap );
if ( error ) if ( error )
goto Exit; goto Exit;

View File

@ -4,7 +4,7 @@
/* */ /* */
/* FreeType initialization layer (body). */ /* 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. */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */ /* */
/* This file is part of the FreeType project, and may only be used, */ /* 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_OBJECTS_H
#include FT_INTERNAL_DEBUG_H #include FT_INTERNAL_DEBUG_H
#include FT_MODULE_H #include FT_MODULE_H
#include "basepic.h"
/*************************************************************************/ /*************************************************************************/
@ -53,6 +54,8 @@
#undef FT_COMPONENT #undef FT_COMPONENT
#define FT_COMPONENT trace_init #define FT_COMPONENT trace_init
#ifndef FT_CONFIG_OPTION_PIC
#undef FT_USE_MODULE #undef FT_USE_MODULE
#ifdef __cplusplus #ifdef __cplusplus
#define FT_USE_MODULE( type, x ) extern "C" const type x; #define FT_USE_MODULE( type, x ) extern "C" const type x;
@ -74,6 +77,99 @@
0 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 = 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 = 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 */ /* documentation is in ftmodapi.h */
@ -86,16 +182,15 @@
/* test for valid `library' delayed to FT_Add_Module() */ /* test for valid `library' delayed to FT_Add_Module() */
cur = ft_default_modules; cur = FT_DEFAULT_MODULES_GET;
while ( *cur ) while ( *cur )
{ {
error = FT_Add_Module( library, *cur ); error = FT_Add_Module( library, *cur );
/* notify errors, but don't stop */ /* notify errors, but don't stop */
if ( error ) if ( error )
{ FT_TRACE0(( "FT_Add_Default_Module:"
FT_ERROR(( "FT_Add_Default_Module: Cannot install `%s', error = 0x%x\n", " Cannot install `%s', error = 0x%x\n",
(*cur)->module_name, error )); (*cur)->module_name, error ));
}
cur++; cur++;
} }
} }
@ -127,13 +222,7 @@
if ( error ) if ( error )
FT_Done_Memory( memory ); FT_Done_Memory( memory );
else else
{
(*alibrary)->version_major = FREETYPE_MAJOR;
(*alibrary)->version_minor = FREETYPE_MINOR;
(*alibrary)->version_patch = FREETYPE_PATCH;
FT_Add_Default_Modules( *alibrary ); FT_Add_Default_Modules( *alibrary );
}
return error; return error;
} }

View File

@ -348,6 +348,9 @@
/* free bitmap buffer if needed */ /* free bitmap buffer if needed */
ft_glyphslot_free_bitmap( slot ); ft_glyphslot_free_bitmap( slot );
/* slot->internal might be NULL in out-of-memory situations */
if ( slot->internal )
{
/* free glyph loader */ /* free glyph loader */
if ( FT_DRIVER_USES_OUTLINES( driver ) ) if ( FT_DRIVER_USES_OUTLINES( driver ) )
{ {
@ -357,6 +360,7 @@
FT_FREE( slot->internal ); FT_FREE( slot->internal );
} }
}
/* documentation is in ftobjs.h */ /* documentation is in ftobjs.h */
@ -588,17 +592,17 @@
* Determine whether we need to auto-hint or not. * Determine whether we need to auto-hint or not.
* The general rules are: * The general rules are:
* *
* - Do only auto-hinting if we have a hinter module, * - Do only auto-hinting if we have a hinter module, a scalable font
* a scalable font format dealing with outlines, * format dealing with outlines, and no transforms except simple
* and no transforms except simple slants. * slants and/or rotations by integer multiples of 90 degrees.
* *
* - Then, autohint if FT_LOAD_FORCE_AUTOHINT is set * - Then, auto-hint if FT_LOAD_FORCE_AUTOHINT is set or if we don't
* or if we don't have a native font hinter. * have a native font hinter.
* *
* - Otherwise, auto-hint for LIGHT hinting mode. * - Otherwise, auto-hint for LIGHT hinting mode.
* *
* - Exception: The font is `tricky' and requires * - Exception: The font is `tricky' and requires the native hinter to
* the native hinter to load properly. * load properly.
*/ */
if ( hinter && if ( hinter &&
@ -607,8 +611,10 @@
FT_DRIVER_IS_SCALABLE( driver ) && FT_DRIVER_IS_SCALABLE( driver ) &&
FT_DRIVER_USES_OUTLINES( driver ) && FT_DRIVER_USES_OUTLINES( driver ) &&
!FT_IS_TRICKY( face ) && !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 ) || if ( ( load_flags & FT_LOAD_FORCE_AUTOHINT ) ||
!FT_DRIVER_HAS_HINTER( driver ) ) !FT_DRIVER_HAS_HINTER( driver ) )
@ -2398,12 +2404,24 @@
ft_synthesize_vertical_metrics( FT_Glyph_Metrics* metrics, ft_synthesize_vertical_metrics( FT_Glyph_Metrics* metrics,
FT_Pos advance ) 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 */ /* the factor 1.2 is a heuristical value */
if ( !advance ) if ( !advance )
advance = metrics->height * 12 / 10; advance = height * 12 / 10;
metrics->vertBearingX = -( metrics->width / 2 ); metrics->vertBearingX = metrics->horiBearingX - metrics->horiAdvance / 2;
metrics->vertBearingY = ( advance - metrics->height ) / 2; metrics->vertBearingY = ( advance - height ) / 2;
metrics->vertAdvance = advance; metrics->vertAdvance = advance;
} }
@ -3048,7 +3066,12 @@
FT_CMap cmap = FT_CMAP( face->charmap ); 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; return result;
} }
@ -3128,8 +3151,20 @@
FT_CMap vcmap = FT_CMAP( charmap ); FT_CMap vcmap = FT_CMAP( charmap );
result = vcmap->clazz->char_var_index( vcmap, ucmap, charcode, if ( charcode > 0xFFFFFFFFUL )
variantSelector ); {
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 +3192,20 @@
FT_CMap vcmap = FT_CMAP( charmap ); FT_CMap vcmap = FT_CMAP( charmap );
result = vcmap->clazz->char_var_default( vcmap, charcode, if ( charcode > 0xFFFFFFFFUL )
variantSelector ); {
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 +3260,14 @@
FT_Memory memory = FT_FACE_MEMORY( face ); 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; return result;
@ -3240,8 +3294,14 @@
FT_Memory memory = FT_FACE_MEMORY( face ); 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, result = vcmap->clazz->variantchar_list( vcmap, memory,
variantSelector ); (FT_UInt32)variantSelector );
} }
} }
@ -3291,7 +3351,7 @@
((FT_Byte*)buffer)[0] = 0; ((FT_Byte*)buffer)[0] = 0;
if ( face && if ( face &&
glyph_index <= (FT_UInt)face->num_glyphs && (FT_Long)glyph_index <= face->num_glyphs &&
FT_HAS_GLYPH_NAMES( face ) ) FT_HAS_GLYPH_NAMES( face ) )
{ {
FT_Service_GlyphDict service; FT_Service_GlyphDict service;
@ -3391,6 +3451,7 @@
FT_ULong *length ) FT_ULong *length )
{ {
FT_Service_SFNT_Table service; FT_Service_SFNT_Table service;
FT_ULong offset;
if ( !face || !FT_IS_SFNT( face ) ) if ( !face || !FT_IS_SFNT( face ) )
@ -3400,7 +3461,7 @@
if ( service == NULL ) if ( service == NULL )
return FT_Err_Unimplemented_Feature; 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 +4184,13 @@
library->memory = memory; 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 */ /* allocate the render pool */
library->raster_pool_size = FT_RENDER_POOL_SIZE; library->raster_pool_size = FT_RENDER_POOL_SIZE;
#if FT_RENDER_POOL_SIZE > 0 #if FT_RENDER_POOL_SIZE > 0
@ -4130,12 +4198,19 @@
goto Fail; goto Fail;
#endif #endif
library->version_major = FREETYPE_MAJOR;
library->version_minor = FREETYPE_MINOR;
library->version_patch = FREETYPE_PATCH;
/* That's ok now */ /* That's ok now */
*alibrary = library; *alibrary = library;
return FT_Err_Ok; return FT_Err_Ok;
Fail: Fail:
#ifdef FT_CONFIG_OPTION_PIC
ft_pic_container_destroy( library );
#endif
FT_FREE( library ); FT_FREE( library );
return error; return error;
} }
@ -4216,7 +4291,7 @@
{ {
FT_Done_Face( FT_FACE( faces->head->data ) ); FT_Done_Face( FT_FACE( faces->head->data ) );
if ( faces->head ) 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 +4327,11 @@
FT_FREE( library->raster_pool ); FT_FREE( library->raster_pool );
library->raster_pool_size = 0; library->raster_pool_size = 0;
#ifdef FT_CONFIG_OPTION_PIC
/* Destroy pic container contents */
ft_pic_container_destroy( library );
#endif
FT_FREE( library ); FT_FREE( library );
return FT_Err_Ok; return FT_Err_Ok;
} }

View File

@ -103,6 +103,7 @@
} }
Exit: Exit:
FT_UNUSED( error );
FT_FRAME_EXIT(); FT_FRAME_EXIT();
return result; return result;
} }
@ -113,7 +114,7 @@
FT_ULong tag ) FT_ULong tag )
{ {
FT_Stream stream = face->stream; FT_Stream stream = face->stream;
FT_Error error; FT_Error error = FT_Err_Ok;
FT_Service_SFNT_Table service; FT_Service_SFNT_Table service;
FT_Bool result = FALSE; FT_Bool result = FALSE;
@ -122,15 +123,18 @@
if ( service ) if ( service )
{ {
FT_ULong offset, size; FT_UInt i = 0;
FT_ULong tag_i = 0, offset_i, length_i;
for ( i = 0; !error && tag_i != tag ; i++ )
error = service->table_info( face, i,
&tag_i, &offset_i, &length_i );
error = service->table_info( face, tag, &offset, &size );
if ( error || if ( error ||
FT_STREAM_SEEK( offset ) ) FT_STREAM_SEEK( offset_i ) )
goto Exit; goto Exit;
result = _tt_check_patents_in_range( stream, size ); result = _tt_check_patents_in_range( stream, length_i );
} }
Exit: Exit:

View File

@ -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 */

View File

@ -752,9 +752,9 @@
const char *insertion ) const char *insertion )
{ {
char* new_name; char* new_name;
char* tmp; const char* tmp;
const char* slash; const char* slash;
unsigned new_length; size_t new_length;
FT_Error error = FT_Err_Ok; FT_Error error = FT_Err_Ok;
FT_UNUSED( error ); FT_UNUSED( error );

View File

@ -0,0 +1,94 @@
/***************************************************************************/
/* */
/* 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, 2009 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* 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_SFNT_NAMES_H
#include FT_INTERNAL_TRUETYPE_TYPES_H
#include FT_INTERNAL_STREAM_H
#ifdef TT_CONFIG_OPTION_SFNT_NAMES
/* 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;
}
/* documentation is in ftsnames.h */
FT_EXPORT_DEF( FT_Error )
FT_Get_Sfnt_Name( FT_Face face,
FT_UInt idx,
FT_SfntName *aname )
{
FT_Error error = FT_Err_Invalid_Argument;
if ( aname && face && FT_IS_SFNT( face ) )
{
TT_Face ttface = (TT_Face)face;
if ( idx < (FT_UInt)ttface->num_names )
{
TT_NameEntryRec* entry = ttface->name_table.names + idx;
/* load name on demand */
if ( entry->stringLength > 0 && entry->string == NULL )
{
FT_Memory memory = face->memory;
FT_Stream stream = face->stream;
if ( FT_NEW_ARRAY ( entry->string, entry->stringLength ) ||
FT_STREAM_SEEK( entry->stringOffset ) ||
FT_STREAM_READ( entry->string, entry->stringLength ) )
{
FT_FREE( entry->string );
entry->stringLength = 0;
}
}
aname->platform_id = entry->platformID;
aname->encoding_id = entry->encodingID;
aname->language_id = entry->languageID;
aname->name_id = entry->nameID;
aname->string = (FT_Byte*)entry->string;
aname->string_len = entry->stringLength;
error = FT_Err_Ok;
}
}
return error;
}
#endif /* TT_CONFIG_OPTION_SFNT_NAMES */
/* END */

View File

@ -4,7 +4,7 @@
/* */ /* */
/* I/O stream support (body). */ /* 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. */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */ /* */
/* This file is part of the FreeType project, and may only be used, */ /* This file is part of the FreeType project, and may only be used, */
@ -60,13 +60,12 @@
FT_Error error = FT_Err_Ok; FT_Error error = FT_Err_Ok;
stream->pos = pos;
if ( stream->read ) if ( stream->read )
{ {
if ( stream->read( stream, pos, 0, 0 ) ) 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 )); pos, stream->size ));
error = FT_Err_Invalid_Stream_Operation; error = FT_Err_Invalid_Stream_Operation;
@ -75,12 +74,16 @@
/* note that seeking to the first position after the file is valid */ /* note that seeking to the first position after the file is valid */
else if ( pos > stream->size ) 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 )); pos, stream->size ));
error = FT_Err_Invalid_Stream_Operation; error = FT_Err_Invalid_Stream_Operation;
} }
if ( !error )
stream->pos = pos;
return error; return error;
} }
@ -124,7 +127,8 @@
if ( pos >= stream->size ) 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 )); pos, stream->size ));
return FT_Err_Invalid_Stream_Operation; return FT_Err_Invalid_Stream_Operation;
@ -145,8 +149,8 @@
if ( read_bytes < count ) if ( read_bytes < count )
{ {
FT_ERROR(( "FT_Stream_ReadAt:" )); FT_ERROR(( "FT_Stream_ReadAt:"
FT_ERROR(( " invalid read; expected %lu bytes, got %lu\n", " invalid read; expected %lu bytes, got %lu\n",
count, read_bytes )); count, read_bytes ));
error = FT_Err_Invalid_Stream_Operation; error = FT_Err_Invalid_Stream_Operation;
@ -211,7 +215,7 @@
FT_Stream_ReleaseFrame( FT_Stream stream, FT_Stream_ReleaseFrame( FT_Stream stream,
FT_Byte** pbytes ) FT_Byte** pbytes )
{ {
if ( stream->read ) if ( stream && stream->read )
{ {
FT_Memory memory = stream->memory; FT_Memory memory = stream->memory;
@ -256,8 +260,8 @@
stream->base, count ); stream->base, count );
if ( read_bytes < count ) if ( read_bytes < count )
{ {
FT_ERROR(( "FT_Stream_EnterFrame:" )); FT_ERROR(( "FT_Stream_EnterFrame:"
FT_ERROR(( " invalid read; expected %lu bytes, got %lu\n", " invalid read; expected %lu bytes, got %lu\n",
count, read_bytes )); count, read_bytes ));
FT_FREE( stream->base ); FT_FREE( stream->base );
@ -273,8 +277,8 @@
if ( stream->pos >= stream->size || if ( stream->pos >= stream->size ||
stream->pos + count > stream->size ) stream->pos + count > stream->size )
{ {
FT_ERROR(( "FT_Stream_EnterFrame:" )); FT_ERROR(( "FT_Stream_EnterFrame:"
FT_ERROR(( " invalid i/o; pos = 0x%lx, count = %lu, size = 0x%lx\n", " invalid i/o; pos = 0x%lx, count = %lu, size = 0x%lx\n",
stream->pos, count, stream->size )); stream->pos, count, stream->size ));
error = FT_Err_Invalid_Stream_Operation; error = FT_Err_Invalid_Stream_Operation;
@ -459,7 +463,8 @@
Fail: Fail:
*error = FT_Err_Invalid_Stream_Operation; *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 )); stream->pos, stream->size ));
return 0; return 0;
@ -505,8 +510,8 @@
Fail: Fail:
*error = FT_Err_Invalid_Stream_Operation; *error = FT_Err_Invalid_Stream_Operation;
FT_ERROR(( "FT_Stream_ReadShort:" )); FT_ERROR(( "FT_Stream_ReadShort:"
FT_ERROR(( " invalid i/o; pos = 0x%lx, size = 0x%lx\n", " invalid i/o; pos = 0x%lx, size = 0x%lx\n",
stream->pos, stream->size )); stream->pos, stream->size ));
return 0; return 0;
@ -552,8 +557,8 @@
Fail: Fail:
*error = FT_Err_Invalid_Stream_Operation; *error = FT_Err_Invalid_Stream_Operation;
FT_ERROR(( "FT_Stream_ReadShortLE:" )); FT_ERROR(( "FT_Stream_ReadShortLE:"
FT_ERROR(( " invalid i/o; pos = 0x%lx, size = 0x%lx\n", " invalid i/o; pos = 0x%lx, size = 0x%lx\n",
stream->pos, stream->size )); stream->pos, stream->size ));
return 0; return 0;
@ -599,8 +604,8 @@
Fail: Fail:
*error = FT_Err_Invalid_Stream_Operation; *error = FT_Err_Invalid_Stream_Operation;
FT_ERROR(( "FT_Stream_ReadOffset:" )); FT_ERROR(( "FT_Stream_ReadOffset:"
FT_ERROR(( " invalid i/o; pos = 0x%lx, size = 0x%lx\n", " invalid i/o; pos = 0x%lx, size = 0x%lx\n",
stream->pos, stream->size )); stream->pos, stream->size ));
return 0; return 0;
@ -645,9 +650,10 @@
return result; return result;
Fail: 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; *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; return 0;
} }
@ -691,10 +697,10 @@
return result; return result;
Fail: 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; *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; return 0;
} }

View File

@ -706,7 +706,7 @@
FT_Bool valid; FT_Bool valid;
FT_StrokeBorderRec borders[2]; FT_StrokeBorderRec borders[2];
FT_Memory memory; FT_Library library;
} FT_StrokerRec; } FT_StrokerRec;
@ -729,7 +729,7 @@
if ( !FT_NEW( stroker ) ) if ( !FT_NEW( stroker ) )
{ {
stroker->memory = memory; stroker->library = library;
ft_stroke_border_init( &stroker->borders[0], memory ); ft_stroke_border_init( &stroker->borders[0], memory );
ft_stroke_border_init( &stroker->borders[1], memory ); ft_stroke_border_init( &stroker->borders[1], memory );
@ -777,13 +777,13 @@
{ {
if ( stroker ) 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[0] );
ft_stroke_border_done( &stroker->borders[1] ); ft_stroke_border_done( &stroker->borders[1] );
stroker->memory = NULL; stroker->library = NULL;
FT_FREE( stroker ); FT_FREE( stroker );
} }
} }
@ -859,6 +859,31 @@
error = ft_stroke_border_lineto( border, &delta, FALSE ); 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: Exit:
return error; return error;
@ -1844,8 +1869,13 @@
return FT_Err_Invalid_Outline; 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; extern const FT_Glyph_Class ft_outline_glyph_class;
#endif
#include "basepic.h"
/* documentation is in ftstroke.h */ /* documentation is in ftstroke.h */
@ -1857,13 +1887,14 @@
{ {
FT_Error error = FT_Err_Invalid_Argument; FT_Error error = FT_Err_Invalid_Argument;
FT_Glyph glyph = NULL; FT_Glyph glyph = NULL;
FT_Library library = stroker->library;
FT_UNUSED(library);
if ( pglyph == NULL ) if ( pglyph == NULL )
goto Exit; goto Exit;
glyph = *pglyph; glyph = *pglyph;
if ( glyph == NULL || glyph->clazz != &ft_outline_glyph_class ) if ( glyph == NULL || glyph->clazz != FT_OUTLINE_GLYPH_CLASS_GET )
goto Exit; goto Exit;
{ {
@ -1930,13 +1961,14 @@
{ {
FT_Error error = FT_Err_Invalid_Argument; FT_Error error = FT_Err_Invalid_Argument;
FT_Glyph glyph = NULL; FT_Glyph glyph = NULL;
FT_Library library = stroker->library;
FT_UNUSED(library);
if ( pglyph == NULL ) if ( pglyph == NULL )
goto Exit; goto Exit;
glyph = *pglyph; glyph = *pglyph;
if ( glyph == NULL || glyph->clazz != &ft_outline_glyph_class ) if ( glyph == NULL || glyph->clazz != FT_OUTLINE_GLYPH_CLASS_GET )
goto Exit; goto Exit;
{ {

View File

@ -18,11 +18,21 @@
#include <ft2build.h> #include <ft2build.h>
#include FT_SYNTHESIS_H #include FT_SYNTHESIS_H
#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_OBJECTS_H #include FT_INTERNAL_OBJECTS_H
#include FT_OUTLINE_H #include FT_OUTLINE_H
#include FT_BITMAP_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
/*************************************************************************/ /*************************************************************************/
/*************************************************************************/ /*************************************************************************/
/**** ****/ /**** ****/
@ -106,6 +116,18 @@
xstr = 1 << 6; xstr = 1 << 6;
ystr &= ~63; 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 ); error = FT_GlyphSlot_Own_Bitmap( slot );
if ( error ) if ( error )
return; return;
@ -129,8 +151,9 @@
slot->metrics.vertBearingY += ystr; slot->metrics.vertBearingY += ystr;
slot->metrics.vertAdvance += ystr; slot->metrics.vertAdvance += ystr;
/* XXX: 16-bit overflow case must be excluded before here */
if ( slot->format == FT_GLYPH_FORMAT_BITMAP ) if ( slot->format == FT_GLYPH_FORMAT_BITMAP )
slot->bitmap_top += ystr >> 6; slot->bitmap_top += (FT_Int)( ystr >> 6 );
} }

View File

@ -4,7 +4,7 @@
/* */ /* */
/* ANSI-specific FreeType low-level system interface (body). */ /* 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. */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */ /* */
/* This file is part of the FreeType project, and may only be used, */ /* This file is part of the FreeType project, and may only be used, */
@ -205,6 +205,7 @@
file = STREAM_FILE( stream ); file = STREAM_FILE( stream );
if ( stream->pos != offset )
ft_fseek( file, offset, SEEK_SET ); ft_fseek( file, offset, SEEK_SET );
return (unsigned long)ft_fread( buffer, 1, count, file ); return (unsigned long)ft_fread( buffer, 1, count, file );
@ -226,8 +227,8 @@
file = ft_fopen( filepathname, "rb" ); file = ft_fopen( filepathname, "rb" );
if ( !file ) if ( !file )
{ {
FT_ERROR(( "FT_Stream_Open:" )); FT_ERROR(( "FT_Stream_Open:"
FT_ERROR(( " could not open `%s'\n", filepathname )); " could not open `%s'\n", filepathname ));
return FT_Err_Cannot_Open_Resource; return FT_Err_Cannot_Open_Resource;
} }

View File

@ -72,10 +72,10 @@
val = ( val >= 0 ) ? val : -val; val = ( val >= 0 ) ? val : -val;
v1 = (FT_UInt32)val >> 16; v1 = (FT_UInt32)val >> 16;
v2 = (FT_UInt32)val & 0xFFFFL; v2 = (FT_UInt32)(val & 0xFFFFL);
k1 = FT_TRIG_SCALE >> 16; /* constant */ k1 = (FT_UInt32)FT_TRIG_SCALE >> 16; /* constant */
k2 = FT_TRIG_SCALE & 0xFFFFL; /* constant */ k2 = (FT_UInt32)(FT_TRIG_SCALE & 0xFFFFL); /* constant */
hi = k1 * v1; hi = k1 * v1;
lo1 = k1 * v2 + k2 * v1; /* can't overflow */ lo1 = k1 * v2 + k2 * v1; /* can't overflow */
@ -86,7 +86,7 @@
hi += lo1 >> 16; hi += lo1 >> 16;
if ( lo1 < lo3 ) if ( lo1 < lo3 )
hi += 0x10000UL; hi += (FT_UInt32)0x10000UL;
val = (FT_Fixed)hi; val = (FT_Fixed)hi;
@ -433,7 +433,7 @@
if ( shift > 0 ) 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; vec->x = ( v.x + half + FT_SIGN_LONG( v.x ) ) >> shift;

View File

@ -37,10 +37,10 @@ BASE_SRC := $(BASE_DIR)/ftadvanc.c \
$(BASE_DIR)/ftcalc.c \ $(BASE_DIR)/ftcalc.c \
$(BASE_DIR)/ftdbgmem.c \ $(BASE_DIR)/ftdbgmem.c \
$(BASE_DIR)/ftgloadr.c \ $(BASE_DIR)/ftgloadr.c \
$(BASE_DIR)/ftnames.c \
$(BASE_DIR)/ftobjs.c \ $(BASE_DIR)/ftobjs.c \
$(BASE_DIR)/ftoutln.c \ $(BASE_DIR)/ftoutln.c \
$(BASE_DIR)/ftrfork.c \ $(BASE_DIR)/ftrfork.c \
$(BASE_DIR)/ftsnames.c \
$(BASE_DIR)/ftstream.c \ $(BASE_DIR)/ftstream.c \
$(BASE_DIR)/fttrigon.c \ $(BASE_DIR)/fttrigon.c \
$(BASE_DIR)/ftutil.c $(BASE_DIR)/ftutil.c

View File

@ -114,8 +114,8 @@ FT_BEGIN_HEADER
union union
{ {
char* atom; char* atom;
long int32; long l;
unsigned long card32; unsigned long ul;
} value; /* Value of the property. */ } value; /* Value of the property. */
@ -160,7 +160,7 @@ FT_BEGIN_HEADER
typedef struct _hashnode_ typedef struct _hashnode_
{ {
const char* key; const char* key;
void* data; size_t data;
} _hashnode, *hashnode; } _hashnode, *hashnode;

View File

@ -53,7 +53,7 @@ THE SOFTWARE.
typedef struct BDF_CMapRec_ typedef struct BDF_CMapRec_
{ {
FT_CMapRec cmap; FT_CMapRec cmap;
FT_UInt num_encodings; FT_ULong num_encodings; /* ftobjs.h: FT_CMap->clazz->size */
BDF_encoding_el* encodings; BDF_encoding_el* encodings;
} BDF_CMapRec, *BDF_CMap; } BDF_CMapRec, *BDF_CMap;
@ -92,8 +92,8 @@ THE SOFTWARE.
{ {
BDF_CMap cmap = (BDF_CMap)bdfcmap; BDF_CMap cmap = (BDF_CMap)bdfcmap;
BDF_encoding_el* encodings = cmap->encodings; BDF_encoding_el* encodings = cmap->encodings;
FT_UInt min, max, mid; FT_ULong min, max, mid; /* num_encodings */
FT_UInt result = 0; FT_UShort result = 0; /* encodings->glyph */
min = 0; min = 0;
@ -101,7 +101,7 @@ THE SOFTWARE.
while ( min < max ) while ( min < max )
{ {
FT_UInt32 code; FT_ULong code;
mid = ( min + max ) >> 1; mid = ( min + max ) >> 1;
@ -131,9 +131,9 @@ THE SOFTWARE.
{ {
BDF_CMap cmap = (BDF_CMap)bdfcmap; BDF_CMap cmap = (BDF_CMap)bdfcmap;
BDF_encoding_el* encodings = cmap->encodings; BDF_encoding_el* encodings = cmap->encodings;
FT_UInt min, max, mid; FT_ULong min, max, mid; /* num_encodings */
FT_UInt32 charcode = *acharcode + 1; FT_UShort result = 0; /* encodings->glyph */
FT_UInt result = 0; FT_ULong charcode = *acharcode + 1;
min = 0; min = 0;
@ -141,7 +141,7 @@ THE SOFTWARE.
while ( min < max ) while ( min < max )
{ {
FT_UInt32 code; FT_ULong code; /* same as BDF_encoding_el.enc */
mid = ( min + max ) >> 1; mid = ( min + max ) >> 1;
@ -169,7 +169,14 @@ THE SOFTWARE.
} }
Exit: Exit:
*acharcode = charcode; if ( charcode > 0xFFFFFFFFUL )
{
FT_TRACE1(( "bdf_cmap_char_next: charcode 0x%x > 32bit API" ));
*acharcode = 0;
/* XXX: result should be changed to indicate an overflow error */
}
else
*acharcode = (FT_UInt32)charcode;
return result; return result;
} }
@ -196,9 +203,8 @@ THE SOFTWARE.
bdf_font_t* font = bdf->bdffont; bdf_font_t* font = bdf->bdffont;
bdf_property_t* prop; bdf_property_t* prop;
int nn, len;
char* strings[4] = { NULL, NULL, NULL, NULL }; char* strings[4] = { NULL, NULL, NULL, NULL };
int lengths[4]; size_t nn, len, lengths[4];
face->style_flags = 0; face->style_flags = 0;
@ -284,7 +290,7 @@ THE SOFTWARE.
/* add_style_name and setwidth_name */ /* add_style_name and setwidth_name */
if ( nn == 0 || nn == 3 ) if ( nn == 0 || nn == 3 )
{ {
int mm; size_t mm;
for ( mm = 0; mm < len; mm++ ) for ( mm = 0; mm < len; mm++ )
@ -426,7 +432,7 @@ THE SOFTWARE.
prop = bdf_get_font_property( font, "AVERAGE_WIDTH" ); prop = bdf_get_font_property( font, "AVERAGE_WIDTH" );
if ( prop ) if ( prop )
bsize->width = (FT_Short)( ( prop->value.int32 + 5 ) / 10 ); bsize->width = (FT_Short)( ( prop->value.l + 5 ) / 10 );
else else
bsize->width = (FT_Short)( bsize->height * 2/3 ); bsize->width = (FT_Short)( bsize->height * 2/3 );
@ -434,21 +440,21 @@ THE SOFTWARE.
if ( prop ) if ( prop )
/* convert from 722.7 decipoints to 72 points per inch */ /* convert from 722.7 decipoints to 72 points per inch */
bsize->size = bsize->size =
(FT_Pos)( ( prop->value.int32 * 64 * 7200 + 36135L ) / 72270L ); (FT_Pos)( ( prop->value.l * 64 * 7200 + 36135L ) / 72270L );
else else
bsize->size = bsize->width << 6; bsize->size = bsize->width << 6;
prop = bdf_get_font_property( font, "PIXEL_SIZE" ); prop = bdf_get_font_property( font, "PIXEL_SIZE" );
if ( prop ) if ( prop )
bsize->y_ppem = (FT_Short)prop->value.int32 << 6; bsize->y_ppem = (FT_Short)prop->value.l << 6;
prop = bdf_get_font_property( font, "RESOLUTION_X" ); prop = bdf_get_font_property( font, "RESOLUTION_X" );
if ( prop ) if ( prop )
resolution_x = (FT_Short)prop->value.int32; resolution_x = (FT_Short)prop->value.l;
prop = bdf_get_font_property( font, "RESOLUTION_Y" ); prop = bdf_get_font_property( font, "RESOLUTION_Y" );
if ( prop ) if ( prop )
resolution_y = (FT_Short)prop->value.int32; resolution_y = (FT_Short)prop->value.l;
if ( bsize->y_ppem == 0 ) if ( bsize->y_ppem == 0 )
{ {
@ -479,7 +485,12 @@ THE SOFTWARE.
(face->en_table[n]).glyph = (FT_Short)n; (face->en_table[n]).glyph = (FT_Short)n;
if ( cur[n].encoding == font->default_char ) if ( cur[n].encoding == font->default_char )
face->default_glyph = n; {
if ( n < FT_UINT_MAX )
face->default_glyph = (FT_UInt)n;
else
FT_TRACE1(( "idx %d is too large for this system\n", n ));
}
} }
} }
@ -671,7 +682,10 @@ THE SOFTWARE.
bitmap->rows = glyph.bbx.height; bitmap->rows = glyph.bbx.height;
bitmap->width = glyph.bbx.width; bitmap->width = glyph.bbx.width;
bitmap->pitch = glyph.bpr; if ( glyph.bpr > INT_MAX )
FT_TRACE1(( "BDF_Glyph_Load: too large pitch %d is truncated\n",
glyph.bpr ));
bitmap->pitch = (int)glyph.bpr; /* same as FT_Bitmap.pitch */
/* note: we don't allocate a new array to hold the bitmap; */ /* note: we don't allocate a new array to hold the bitmap; */
/* we can simply point to it */ /* we can simply point to it */
@ -743,13 +757,23 @@ THE SOFTWARE.
break; break;
case BDF_INTEGER: case BDF_INTEGER:
if ( prop->value.l > 0x7FFFFFFFL || prop->value.l < ( -1 - 0x7FFFFFFFL ) )
{
FT_TRACE1(( "bdf_get_bdf_property: " ));
FT_TRACE1(( "too large integer 0x%x is truncated\n" ));
}
aproperty->type = BDF_PROPERTY_TYPE_INTEGER; aproperty->type = BDF_PROPERTY_TYPE_INTEGER;
aproperty->u.integer = prop->value.int32; aproperty->u.integer = (FT_Int32)prop->value.l;
break; break;
case BDF_CARDINAL: case BDF_CARDINAL:
if ( prop->value.ul > 0xFFFFFFFFUL )
{
FT_TRACE1(( "bdf_get_bdf_property: " ));
FT_TRACE1(( "too large cardinal 0x%x is truncated\n" ));
}
aproperty->type = BDF_PROPERTY_TYPE_CARDINAL; aproperty->type = BDF_PROPERTY_TYPE_CARDINAL;
aproperty->u.cardinal = prop->value.card32; aproperty->u.cardinal = (FT_UInt32)prop->value.ul;
break; break;
default: default:

View File

@ -36,6 +36,10 @@ THE SOFTWARE.
FT_BEGIN_HEADER FT_BEGIN_HEADER
#ifdef FT_CONFIG_OPTION_PIC
#error "this module does not support PIC yet"
#endif
typedef struct BDF_encoding_el_ typedef struct BDF_encoding_el_
{ {

View File

@ -281,7 +281,7 @@
static FT_Error static FT_Error
hash_insert( char* key, hash_insert( char* key,
void* data, size_t data,
hashtable* ht, hashtable* ht,
FT_Memory memory ) FT_Memory memory )
{ {
@ -416,16 +416,16 @@
static FT_Error static FT_Error
_bdf_list_ensure( _bdf_list_t* list, _bdf_list_ensure( _bdf_list_t* list,
int num_items ) unsigned long num_items ) /* same as _bdf_list_t.used */
{ {
FT_Error error = BDF_Err_Ok; FT_Error error = BDF_Err_Ok;
if ( num_items > (int)list->size ) if ( num_items > list->size )
{ {
int oldsize = list->size; unsigned long oldsize = list->size; /* same as _bdf_list_t.size */
int newsize = oldsize + ( oldsize >> 1 ) + 4; unsigned long newsize = oldsize + ( oldsize >> 1 ) + 4;
int bigsize = FT_INT_MAX / sizeof ( char* ); unsigned long bigsize = (unsigned long)( FT_INT_MAX / sizeof ( char* ) );
FT_Memory memory = list->memory; FT_Memory memory = list->memory;
@ -614,8 +614,8 @@
{ {
_bdf_line_func_t cb; _bdf_line_func_t cb;
unsigned long lineno, buf_size; unsigned long lineno, buf_size;
int refill, bytes, hold, to_skip; int refill, hold, to_skip;
int start, end, cursor, avail; ptrdiff_t bytes, start, end, cursor, avail;
char* buf = 0; char* buf = 0;
FT_Memory memory = stream->memory; FT_Memory memory = stream->memory;
FT_Error error = BDF_Err_Ok; FT_Error error = BDF_Err_Ok;
@ -648,7 +648,7 @@
{ {
if ( refill ) if ( refill )
{ {
bytes = (int)FT_Stream_TryRead( stream, (FT_Byte*)buf + cursor, bytes = (ptrdiff_t)FT_Stream_TryRead( stream, (FT_Byte*)buf + cursor,
(FT_ULong)(buf_size - cursor) ); (FT_ULong)(buf_size - cursor) );
avail = cursor + bytes; avail = cursor + bytes;
cursor = 0; cursor = 0;
@ -971,7 +971,7 @@
int format, int format,
bdf_font_t* font ) bdf_font_t* font )
{ {
unsigned long n; size_t n;
bdf_property_t* p; bdf_property_t* p;
FT_Memory memory = font->memory; FT_Memory memory = font->memory;
FT_Error error = BDF_Err_Ok; FT_Error error = BDF_Err_Ok;
@ -991,7 +991,9 @@
p = font->user_props + font->nuser_props; p = font->user_props + font->nuser_props;
FT_ZERO( p ); FT_ZERO( p );
n = (unsigned long)( ft_strlen( name ) + 1 ); n = ft_strlen( name ) + 1;
if ( n > FT_ULONG_MAX )
return BDF_Err_Invalid_Argument;
if ( FT_NEW_ARRAY( p->name, n ) ) if ( FT_NEW_ARRAY( p->name, n ) )
goto Exit; goto Exit;
@ -1003,7 +1005,7 @@
n = _num_bdf_properties + font->nuser_props; n = _num_bdf_properties + font->nuser_props;
error = hash_insert( p->name, (void *)n, &(font->proptbl), memory ); error = hash_insert( p->name, n, &(font->proptbl), memory );
if ( error ) if ( error )
goto Exit; goto Exit;
@ -1019,7 +1021,7 @@
bdf_font_t* font ) bdf_font_t* font )
{ {
hashnode hn; hashnode hn;
unsigned long propid; size_t propid;
if ( name == 0 || *name == 0 ) if ( name == 0 || *name == 0 )
@ -1028,7 +1030,7 @@
if ( ( hn = hash_lookup( name, &(font->proptbl) ) ) == 0 ) if ( ( hn = hash_lookup( name, &(font->proptbl) ) ) == 0 )
return 0; return 0;
propid = (unsigned long)hn->data; propid = hn->data;
if ( propid >= _num_bdf_properties ) if ( propid >= _num_bdf_properties )
return font->user_props + ( propid - _num_bdf_properties ); return font->user_props + ( propid - _num_bdf_properties );
@ -1131,7 +1133,7 @@
_bdf_set_default_spacing( bdf_font_t* font, _bdf_set_default_spacing( bdf_font_t* font,
bdf_options_t* opts ) bdf_options_t* opts )
{ {
unsigned long len; size_t len;
char name[256]; char name[256];
_bdf_list_t list; _bdf_list_t list;
FT_Memory memory; FT_Memory memory;
@ -1150,7 +1152,7 @@
font->spacing = opts->font_spacing; font->spacing = opts->font_spacing;
len = (unsigned long)( ft_strlen( font->name ) + 1 ); len = ft_strlen( font->name ) + 1;
/* Limit ourselves to 256 characters in the font name. */ /* Limit ourselves to 256 characters in the font name. */
if ( len >= 256 ) if ( len >= 256 )
{ {
@ -1261,7 +1263,7 @@
char* name, char* name,
char* value ) char* value )
{ {
unsigned long propid; size_t propid;
hashnode hn; hashnode hn;
bdf_property_t *prop, *fp; bdf_property_t *prop, *fp;
FT_Memory memory = font->memory; FT_Memory memory = font->memory;
@ -1273,7 +1275,7 @@
{ {
/* The property already exists in the font, so simply replace */ /* The property already exists in the font, so simply replace */
/* the value of the property with the current value. */ /* the value of the property with the current value. */
fp = font->props + (unsigned long)hn->data; fp = font->props + hn->data;
switch ( fp->format ) switch ( fp->format )
{ {
@ -1289,11 +1291,11 @@
break; break;
case BDF_INTEGER: case BDF_INTEGER:
fp->value.int32 = _bdf_atol( value, 0, 10 ); fp->value.l = _bdf_atol( value, 0, 10 );
break; break;
case BDF_CARDINAL: case BDF_CARDINAL:
fp->value.card32 = _bdf_atoul( value, 0, 10 ); fp->value.ul = _bdf_atoul( value, 0, 10 );
break; break;
default: default:
@ -1335,7 +1337,7 @@
font->props_size++; font->props_size++;
} }
propid = (unsigned long)hn->data; propid = hn->data;
if ( propid >= _num_bdf_properties ) if ( propid >= _num_bdf_properties )
prop = font->user_props + ( propid - _num_bdf_properties ); prop = font->user_props + ( propid - _num_bdf_properties );
else else
@ -1359,11 +1361,11 @@
break; break;
case BDF_INTEGER: case BDF_INTEGER:
fp->value.int32 = _bdf_atol( value, 0, 10 ); fp->value.l = _bdf_atol( value, 0, 10 );
break; break;
case BDF_CARDINAL: case BDF_CARDINAL:
fp->value.card32 = _bdf_atoul( value, 0, 10 ); fp->value.ul = _bdf_atoul( value, 0, 10 );
break; break;
} }
@ -1372,7 +1374,7 @@
if ( ft_memcmp( name, "COMMENT", 7 ) != 0 ) { if ( ft_memcmp( name, "COMMENT", 7 ) != 0 ) {
/* Add the property to the font property table. */ /* Add the property to the font property table. */
error = hash_insert( fp->name, error = hash_insert( fp->name,
(void *)font->props_used, font->props_used,
(hashtable *)font->internal, (hashtable *)font->internal,
memory ); memory );
if ( error ) if ( error )
@ -1387,11 +1389,11 @@
/* present, and the SPACING property should override the default */ /* present, and the SPACING property should override the default */
/* spacing. */ /* spacing. */
if ( ft_memcmp( name, "DEFAULT_CHAR", 12 ) == 0 ) if ( ft_memcmp( name, "DEFAULT_CHAR", 12 ) == 0 )
font->default_char = fp->value.int32; font->default_char = fp->value.l;
else if ( ft_memcmp( name, "FONT_ASCENT", 11 ) == 0 ) else if ( ft_memcmp( name, "FONT_ASCENT", 11 ) == 0 )
font->font_ascent = fp->value.int32; font->font_ascent = fp->value.l;
else if ( ft_memcmp( name, "FONT_DESCENT", 12 ) == 0 ) else if ( ft_memcmp( name, "FONT_DESCENT", 12 ) == 0 )
font->font_descent = fp->value.int32; font->font_descent = fp->value.l;
else if ( ft_memcmp( name, "SPACING", 7 ) == 0 ) else if ( ft_memcmp( name, "SPACING", 7 ) == 0 )
{ {
if ( !fp->value.atom ) if ( !fp->value.atom )
@ -2044,7 +2046,7 @@
p->memory = 0; p->memory = 0;
{ /* setup */ { /* setup */
unsigned long i; size_t i;
bdf_property_t* prop; bdf_property_t* prop;
@ -2054,7 +2056,7 @@
for ( i = 0, prop = (bdf_property_t*)_bdf_properties; for ( i = 0, prop = (bdf_property_t*)_bdf_properties;
i < _num_bdf_properties; i++, prop++ ) i < _num_bdf_properties; i++, prop++ )
{ {
error = hash_insert( prop->name, (void *)i, error = hash_insert( prop->name, i,
&(font->proptbl), memory ); &(font->proptbl), memory );
if ( error ) if ( error )
goto Exit; goto Exit;
@ -2472,7 +2474,7 @@
hn = hash_lookup( name, (hashtable *)font->internal ); hn = hash_lookup( name, (hashtable *)font->internal );
return hn ? ( font->props + (unsigned long)hn->data ) : 0; return hn ? ( font->props + hn->data ) : 0;
} }

View File

@ -4,7 +4,7 @@
/* */ /* */
/* The FreeType basic cache interface (body). */ /* The FreeType basic cache interface (body). */
/* */ /* */
/* Copyright 2003, 2004, 2005, 2006, 2007 by */ /* Copyright 2003, 2004, 2005, 2006, 2007, 2009 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */ /* */
/* This file is part of the FreeType project, and may only be used, */ /* This file is part of the FreeType project, and may only be used, */
@ -17,15 +17,17 @@
#include <ft2build.h> #include <ft2build.h>
#include FT_INTERNAL_DEBUG_H
#include FT_CACHE_H #include FT_CACHE_H
#include "ftcglyph.h" #include "ftcglyph.h"
#include "ftcimage.h" #include "ftcimage.h"
#include "ftcsbits.h" #include "ftcsbits.h"
#include FT_INTERNAL_MEMORY_H
#include "ftccback.h" #include "ftccback.h"
#include "ftcerror.h" #include "ftcerror.h"
#define FT_COMPONENT trace_cache
#ifdef FT_CONFIG_OPTION_OLD_INTERNALS #ifdef FT_CONFIG_OPTION_OLD_INTERNALS
@ -140,8 +142,18 @@
error = FTC_Manager_LookupFace( manager, family->attrs.scaler.face_id, error = FTC_Manager_LookupFace( manager, family->attrs.scaler.face_id,
&face ); &face );
if ( error || !face )
return result;
if ( (FT_ULong)face->num_glyphs > FT_UINT_MAX || 0 > face->num_glyphs )
{
FT_TRACE1(( "ftc_basic_family_get_count: too large number of glyphs " ));
FT_TRACE1(( "in this face, truncated\n", face->num_glyphs ));
}
if ( !error ) if ( !error )
result = face->num_glyphs; result = (FT_UInt)face->num_glyphs;
return result; return result;
} }
@ -304,7 +316,7 @@
FTC_Node *anode ) FTC_Node *anode )
{ {
FTC_BasicQueryRec query; FTC_BasicQueryRec query;
FTC_INode node = 0; /* make compiler happy */ FTC_Node node = 0; /* make compiler happy */
FT_Error error; FT_Error error;
FT_UInt32 hash; FT_UInt32 hash;
@ -320,13 +332,13 @@
if ( anode ) if ( anode )
*anode = NULL; *anode = NULL;
#ifdef FT_CONFIG_OPTION_OLD_INTERNALS #if defined( FT_CONFIG_OPTION_OLD_INTERNALS ) && ( FT_INT_MAX > 0xFFFFU )
/* /*
* This one is a major hack used to detect whether we are passed a * This one is a major hack used to detect whether we are passed a
* regular FTC_ImageType handle, or a legacy FTC_OldImageDesc one. * regular FTC_ImageType handle, or a legacy FTC_OldImageDesc one.
*/ */
if ( type->width >= 0x10000 ) if ( (FT_ULong)type->width >= 0x10000L )
{ {
FTC_OldImageDesc desc = (FTC_OldImageDesc)type; FTC_OldImageDesc desc = (FTC_OldImageDesc)type;
@ -341,10 +353,16 @@
#endif /* FT_CONFIG_OPTION_OLD_INTERNALS */ #endif /* FT_CONFIG_OPTION_OLD_INTERNALS */
{ {
if ( (FT_ULong)(type->flags - FT_INT_MIN) > FT_UINT_MAX )
{
FT_TRACE1(( "FTC_ImageCache_Lookup: higher bits in load_flags" ));
FT_TRACE1(( "0x%x are dropped\n", (type->flags & ~((FT_ULong)FT_UINT_MAX)) ));
}
query.attrs.scaler.face_id = type->face_id; query.attrs.scaler.face_id = type->face_id;
query.attrs.scaler.width = type->width; query.attrs.scaler.width = type->width;
query.attrs.scaler.height = type->height; query.attrs.scaler.height = type->height;
query.attrs.load_flags = type->flags; query.attrs.load_flags = (FT_UInt)type->flags;
} }
query.attrs.scaler.pixel = 1; query.attrs.scaler.pixel = 1;
@ -365,7 +383,7 @@
error = FTC_GCache_Lookup( FTC_GCACHE( cache ), error = FTC_GCache_Lookup( FTC_GCACHE( cache ),
hash, gindex, hash, gindex,
FTC_GQUERY( &query ), FTC_GQUERY( &query ),
(FTC_Node*) &node ); &node );
#endif #endif
if ( !error ) if ( !error )
{ {
@ -373,8 +391,8 @@
if ( anode ) if ( anode )
{ {
*anode = FTC_NODE( node ); *anode = node;
FTC_NODE( node )->ref_count++; node->ref_count++;
} }
} }
@ -394,7 +412,7 @@
FTC_Node *anode ) FTC_Node *anode )
{ {
FTC_BasicQueryRec query; FTC_BasicQueryRec query;
FTC_INode node = 0; /* make compiler happy */ FTC_Node node = 0; /* make compiler happy */
FT_Error error; FT_Error error;
FT_UInt32 hash; FT_UInt32 hash;
@ -410,8 +428,15 @@
if ( anode ) if ( anode )
*anode = NULL; *anode = NULL;
/* FT_Load_Glyph(), FT_Load_Char() take FT_UInt flags */
if ( load_flags > FT_UINT_MAX )
{
FT_TRACE1(( "FTC_ImageCache_LookupScaler: higher bits in load_flags" ));
FT_TRACE1(( "0x%x are dropped\n", (load_flags & ~((FT_ULong)FT_UINT_MAX)) ));
}
query.attrs.scaler = scaler[0]; query.attrs.scaler = scaler[0];
query.attrs.load_flags = load_flags; query.attrs.load_flags = (FT_UInt)load_flags;
hash = FTC_BASIC_ATTR_HASH( &query.attrs ) + gindex; hash = FTC_BASIC_ATTR_HASH( &query.attrs ) + gindex;
@ -428,8 +453,8 @@
if ( anode ) if ( anode )
{ {
*anode = FTC_NODE( node ); *anode = node;
FTC_NODE( node )->ref_count++; node->ref_count++;
} }
} }
@ -630,7 +655,7 @@
{ {
FT_Error error; FT_Error error;
FTC_BasicQueryRec query; FTC_BasicQueryRec query;
FTC_SNode node = 0; /* make compiler happy */ FTC_Node node = 0; /* make compiler happy */
FT_UInt32 hash; FT_UInt32 hash;
@ -643,12 +668,12 @@
*ansbit = NULL; *ansbit = NULL;
#ifdef FT_CONFIG_OPTION_OLD_INTERNALS #if defined( FT_CONFIG_OPTION_OLD_INTERNALS ) && ( FT_INT_MAX > 0xFFFFU )
/* This one is a major hack used to detect whether we are passed a /* This one is a major hack used to detect whether we are passed a
* regular FTC_ImageType handle, or a legacy FTC_OldImageDesc one. * regular FTC_ImageType handle, or a legacy FTC_OldImageDesc one.
*/ */
if ( type->width >= 0x10000 ) if ( (FT_ULong)type->width >= 0x10000L )
{ {
FTC_OldImageDesc desc = (FTC_OldImageDesc)type; FTC_OldImageDesc desc = (FTC_OldImageDesc)type;
@ -663,10 +688,16 @@
#endif /* FT_CONFIG_OPTION_OLD_INTERNALS */ #endif /* FT_CONFIG_OPTION_OLD_INTERNALS */
{ {
if ( (FT_ULong)(type->flags - FT_INT_MIN) > FT_UINT_MAX )
{
FT_TRACE1(( "FTC_ImageCache_Lookup: higher bits in load_flags" ));
FT_TRACE1(( "0x%x are dropped\n", (type->flags & ~((FT_ULong)FT_UINT_MAX)) ));
}
query.attrs.scaler.face_id = type->face_id; query.attrs.scaler.face_id = type->face_id;
query.attrs.scaler.width = type->width; query.attrs.scaler.width = type->width;
query.attrs.scaler.height = type->height; query.attrs.scaler.height = type->height;
query.attrs.load_flags = type->flags; query.attrs.load_flags = (FT_UInt)type->flags;
} }
query.attrs.scaler.pixel = 1; query.attrs.scaler.pixel = 1;
@ -690,17 +721,18 @@
hash, hash,
gindex, gindex,
FTC_GQUERY( &query ), FTC_GQUERY( &query ),
(FTC_Node*)&node ); &node );
#endif #endif
if ( error ) if ( error )
goto Exit; goto Exit;
*ansbit = node->sbits + ( gindex - FTC_GNODE( node )->gindex ); *ansbit = FTC_SNODE( node )->sbits +
( gindex - FTC_GNODE( node )->gindex );
if ( anode ) if ( anode )
{ {
*anode = FTC_NODE( node ); *anode = node;
FTC_NODE( node )->ref_count++; node->ref_count++;
} }
Exit: Exit:
@ -720,7 +752,7 @@
{ {
FT_Error error; FT_Error error;
FTC_BasicQueryRec query; FTC_BasicQueryRec query;
FTC_SNode node = 0; /* make compiler happy */ FTC_Node node = 0; /* make compiler happy */
FT_UInt32 hash; FT_UInt32 hash;
@ -733,8 +765,15 @@
*ansbit = NULL; *ansbit = NULL;
/* FT_Load_Glyph(), FT_Load_Char() take FT_UInt flags */
if ( load_flags > FT_UINT_MAX )
{
FT_TRACE1(( "FTC_ImageCache_LookupScaler: higher bits in load_flags" ));
FT_TRACE1(( "0x%x are dropped\n", (load_flags & ~((FT_ULong)FT_UINT_MAX)) ));
}
query.attrs.scaler = scaler[0]; query.attrs.scaler = scaler[0];
query.attrs.load_flags = load_flags; query.attrs.load_flags = (FT_UInt)load_flags;
/* beware, the hash must be the same for all glyph ranges! */ /* beware, the hash must be the same for all glyph ranges! */
hash = FTC_BASIC_ATTR_HASH( &query.attrs ) + hash = FTC_BASIC_ATTR_HASH( &query.attrs ) +
@ -750,12 +789,13 @@
if ( error ) if ( error )
goto Exit; goto Exit;
*ansbit = node->sbits + ( gindex - FTC_GNODE( node )->gindex ); *ansbit = FTC_SNODE( node )->sbits +
( gindex - FTC_GNODE( node )->gindex );
if ( anode ) if ( anode )
{ {
*anode = FTC_NODE( node ); *anode = node;
FTC_NODE( node )->ref_count++; node->ref_count++;
} }
Exit: Exit:

View File

@ -4,7 +4,7 @@
/* */ /* */
/* The FreeType internal cache interface (body). */ /* The FreeType internal cache interface (body). */
/* */ /* */
/* Copyright 2000-2001, 2002, 2003, 2004, 2005, 2006, 2007 by */ /* Copyright 2000-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */ /* */
/* This file is part of the FreeType project, and may only be used, */ /* This file is part of the FreeType project, and may only be used, */
@ -24,6 +24,9 @@
#include "ftccback.h" #include "ftccback.h"
#include "ftcerror.h" #include "ftcerror.h"
#undef FT_COMPONENT
#define FT_COMPONENT trace_cache
#define FTC_HASH_MAX_LOAD 2 #define FTC_HASH_MAX_LOAD 2
#define FTC_HASH_MIN_LOAD 1 #define FTC_HASH_MIN_LOAD 1
@ -93,9 +96,9 @@
for (;;) for (;;)
{ {
FTC_Node node, *pnode; FTC_Node node, *pnode;
FT_UInt p = cache->p; FT_UFast p = cache->p;
FT_UInt mask = cache->mask; FT_UFast mask = cache->mask;
FT_UInt count = mask + p + 1; /* number of buckets */ FT_UFast count = mask + p + 1; /* number of buckets */
/* do we need to shrink the buckets array? */ /* do we need to shrink the buckets array? */
@ -153,7 +156,7 @@
/* do we need to expand the buckets array? */ /* do we need to expand the buckets array? */
else if ( cache->slack > (FT_Long)count * FTC_HASH_SUB_LOAD ) else if ( cache->slack > (FT_Long)count * FTC_HASH_SUB_LOAD )
{ {
FT_UInt old_index = p + mask; FT_UFast old_index = p + mask;
FTC_Node* pold; FTC_Node* pold;
@ -216,7 +219,7 @@
if ( node == NULL ) if ( node == NULL )
{ {
FT_ERROR(( "ftc_node_hash_unlink: unknown node!\n" )); FT_TRACE0(( "ftc_node_hash_unlink: unknown node\n" ));
return; return;
} }
@ -273,7 +276,7 @@
/* find node's cache */ /* find node's cache */
if ( node->cache_index >= manager->num_caches ) if ( node->cache_index >= manager->num_caches )
{ {
FT_ERROR(( "ftc_node_destroy: invalid node handle\n" )); FT_TRACE0(( "ftc_node_destroy: invalid node handle\n" ));
return; return;
} }
#endif #endif
@ -283,7 +286,7 @@
#ifdef FT_DEBUG_ERROR #ifdef FT_DEBUG_ERROR
if ( cache == NULL ) if ( cache == NULL )
{ {
FT_ERROR(( "ftc_node_destroy: invalid node handle\n" )); FT_TRACE0(( "ftc_node_destroy: invalid node handle\n" ));
return; return;
} }
#endif #endif
@ -302,7 +305,7 @@
#if 0 #if 0
/* check, just in case of general corruption :-) */ /* check, just in case of general corruption :-) */
if ( manager->num_nodes == 0 ) if ( manager->num_nodes == 0 )
FT_ERROR(( "ftc_node_destroy: invalid cache node count! = %d\n", FT_TRACE0(( "ftc_node_destroy: invalid cache node count (%d)\n",
manager->num_nodes )); manager->num_nodes ));
#endif #endif
} }
@ -347,7 +350,7 @@
{ {
FTC_Manager manager = cache->manager; FTC_Manager manager = cache->manager;
FT_UFast i; FT_UFast i;
FT_UInt count; FT_UFast count;
count = cache->p + cache->mask + 1; count = cache->p + cache->mask + 1;

View File

@ -4,7 +4,7 @@
/* */ /* */
/* FreeType internal cache interface (specification). */ /* FreeType internal cache interface (specification). */
/* */ /* */
/* Copyright 2000-2001, 2002, 2003, 2004, 2005, 2006, 2007 by */ /* Copyright 2000-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */ /* */
/* This file is part of the FreeType project, and may only be used, */ /* This file is part of the FreeType project, and may only be used, */
@ -91,7 +91,7 @@ FT_BEGIN_HEADER
FT_Pointer query, FT_Pointer query,
FTC_Cache cache ); FTC_Cache cache );
typedef FT_ULong typedef FT_Offset
(*FTC_Node_WeightFunc)( FTC_Node node, (*FTC_Node_WeightFunc)( FTC_Node node,
FTC_Cache cache ); FTC_Cache cache );
@ -121,7 +121,7 @@ FT_BEGIN_HEADER
FTC_Node_CompareFunc node_remove_faceid; FTC_Node_CompareFunc node_remove_faceid;
FTC_Node_FreeFunc node_free; FTC_Node_FreeFunc node_free;
FT_UInt cache_size; FT_Offset cache_size;
FTC_Cache_InitFunc cache_init; FTC_Cache_InitFunc cache_init;
FTC_Cache_DoneFunc cache_done; FTC_Cache_DoneFunc cache_done;
@ -202,7 +202,7 @@ FT_BEGIN_HEADER
FTC_Cache _cache = FTC_CACHE(cache); \ FTC_Cache _cache = FTC_CACHE(cache); \
FT_UInt32 _hash = (FT_UInt32)(hash); \ FT_UInt32 _hash = (FT_UInt32)(hash); \
FTC_Node_CompareFunc _nodcomp = (FTC_Node_CompareFunc)(nodecmp); \ FTC_Node_CompareFunc _nodcomp = (FTC_Node_CompareFunc)(nodecmp); \
FT_UInt _idx; \ FT_UFast _idx; \
\ \
\ \
error = 0; \ error = 0; \
@ -246,8 +246,7 @@ FT_BEGIN_HEADER
error = FTC_Cache_NewNode( _cache, _hash, query, &_node ); \ error = FTC_Cache_NewNode( _cache, _hash, query, &_node ); \
\ \
_Ok: \ _Ok: \
_pnode = (FTC_Node*)(void*)&(node); \ node = _node; \
*_pnode = _node; \
FT_END_STMNT FT_END_STMNT
#else /* !FTC_INLINE */ #else /* !FTC_INLINE */

View File

@ -36,7 +36,7 @@
FT_Pointer gquery, FT_Pointer gquery,
FTC_Cache cache ); FTC_Cache cache );
FT_LOCAL( FT_ULong ) FT_LOCAL( FT_Offset )
ftc_inode_weight( FTC_Node inode, ftc_inode_weight( FTC_Node inode,
FTC_Cache cache ); FTC_Cache cache );
@ -50,7 +50,7 @@
FT_Pointer gquery, FT_Pointer gquery,
FTC_Cache cache ); FTC_Cache cache );
FT_LOCAL( FT_ULong ) FT_LOCAL( FT_Offset )
ftc_snode_weight( FTC_Node snode, ftc_snode_weight( FTC_Node snode,
FTC_Cache cache ); FTC_Cache cache );

View File

@ -4,7 +4,7 @@
/* */ /* */
/* FreeType CharMap cache (body) */ /* FreeType CharMap cache (body) */
/* */ /* */
/* Copyright 2000-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 by */ /* Copyright 2000-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */ /* */
/* This file is part of the FreeType project, and may only be used, */ /* This file is part of the FreeType project, and may only be used, */
@ -22,7 +22,6 @@
#include "ftcmanag.h" #include "ftcmanag.h"
#include FT_INTERNAL_MEMORY_H #include FT_INTERNAL_MEMORY_H
#include FT_INTERNAL_DEBUG_H #include FT_INTERNAL_DEBUG_H
#include FT_TRUETYPE_IDS_H
#include "ftccback.h" #include "ftccback.h"
#include "ftcerror.h" #include "ftcerror.h"
@ -88,7 +87,7 @@
/* compute a query/node hash */ /* compute a query/node hash */
#define FTC_CMAP_HASH( faceid, index, charcode ) \ #define FTC_CMAP_HASH( faceid, index, charcode ) \
( FTC_FACE_ID_HASH( faceid ) + 211 * (index) + \ ( FTC_FACE_ID_HASH( faceid ) + 211 * (index) + \
( (char_code) / FTC_CMAP_INDICES_MAX ) ) ( (charcode) / FTC_CMAP_INDICES_MAX ) )
/* the charmap query */ /* the charmap query */
typedef struct FTC_CMapQueryRec_ typedef struct FTC_CMapQueryRec_
@ -175,7 +174,7 @@
/* compute the weight of a given cmap node */ /* compute the weight of a given cmap node */
FT_CALLBACK_DEF( FT_ULong ) FT_CALLBACK_DEF( FT_Offset )
ftc_cmap_node_weight( FTC_Node cnode, ftc_cmap_node_weight( FTC_Node cnode,
FTC_Cache cache ) FTC_Cache cache )
{ {
@ -284,7 +283,7 @@
{ {
FTC_Cache cache = FTC_CACHE( cmap_cache ); FTC_Cache cache = FTC_CACHE( cmap_cache );
FTC_CMapQueryRec query; FTC_CMapQueryRec query;
FTC_CMapNode node; FTC_Node node;
FT_Error error; FT_Error error;
FT_UInt gindex = 0; FT_UInt gindex = 0;
FT_UInt32 hash; FT_UInt32 hash;
@ -304,7 +303,7 @@
if ( !cache ) if ( !cache )
{ {
FT_ERROR(( "FTC_CMapCache_Lookup: bad arguments, returning 0!\n" )); FT_TRACE0(( "FTC_CMapCache_Lookup: bad arguments, returning 0\n" ));
return 0; return 0;
} }
@ -374,18 +373,21 @@
FTC_CACHE_LOOKUP_CMP( cache, ftc_cmap_node_compare, hash, &query, FTC_CACHE_LOOKUP_CMP( cache, ftc_cmap_node_compare, hash, &query,
node, error ); node, error );
#else #else
error = FTC_Cache_Lookup( cache, hash, &query, (FTC_Node*) &node ); error = FTC_Cache_Lookup( cache, hash, &query, &node );
#endif #endif
if ( error ) if ( error )
goto Exit; goto Exit;
FT_ASSERT( (FT_UInt)( char_code - node->first ) < FTC_CMAP_INDICES_MAX ); FT_ASSERT( (FT_UInt)( char_code - FTC_CMAP_NODE( node )->first ) <
FTC_CMAP_INDICES_MAX );
/* something rotten can happen with rogue clients */ /* something rotten can happen with rogue clients */
if ( (FT_UInt)( char_code - node->first >= FTC_CMAP_INDICES_MAX ) ) if ( (FT_UInt)( char_code - FTC_CMAP_NODE( node )->first >=
FTC_CMAP_INDICES_MAX ) )
return 0; return 0;
gindex = node->indices[char_code - node->first]; gindex = FTC_CMAP_NODE( node )->indices[char_code -
FTC_CMAP_NODE( node )->first];
if ( gindex == FTC_CMAP_UNKNOWN ) if ( gindex == FTC_CMAP_UNKNOWN )
{ {
FT_Face face; FT_Face face;
@ -393,7 +395,9 @@
gindex = 0; gindex = 0;
error = FTC_Manager_LookupFace( cache->manager, node->face_id, &face ); error = FTC_Manager_LookupFace( cache->manager,
FTC_CMAP_NODE( node )->face_id,
&face );
if ( error ) if ( error )
goto Exit; goto Exit;
@ -414,7 +418,9 @@
FT_Set_Charmap( face, old ); FT_Set_Charmap( face, old );
} }
node->indices[char_code - node->first] = (FT_UShort)gindex; FTC_CMAP_NODE( node )->indices[char_code -
FTC_CMAP_NODE( node )->first]
= (FT_UShort)gindex;
} }
Exit: Exit:

View File

@ -4,7 +4,7 @@
/* */ /* */
/* FreeType Glyph Image (FT_Glyph) cache (body). */ /* FreeType Glyph Image (FT_Glyph) cache (body). */
/* */ /* */
/* Copyright 2000-2001, 2003, 2004, 2006 by */ /* Copyright 2000-2001, 2003, 2004, 2006, 2009 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */ /* */
/* This file is part of the FreeType project, and may only be used, */ /* This file is part of the FreeType project, and may only be used, */
@ -20,8 +20,6 @@
#include FT_CACHE_H #include FT_CACHE_H
#include "ftcglyph.h" #include "ftcglyph.h"
#include FT_ERRORS_H #include FT_ERRORS_H
#include FT_INTERNAL_OBJECTS_H
#include FT_INTERNAL_DEBUG_H
#include "ftccback.h" #include "ftccback.h"
#include "ftcerror.h" #include "ftcerror.h"

View File

@ -277,12 +277,14 @@ FT_BEGIN_HEADER
FTC_GCache _gcache = FTC_GCACHE( cache ); \ FTC_GCache _gcache = FTC_GCACHE( cache ); \
FTC_GQuery _gquery = (FTC_GQuery)( query ); \ FTC_GQuery _gquery = (FTC_GQuery)( query ); \
FTC_MruNode_CompareFunc _fcompare = (FTC_MruNode_CompareFunc)(famcmp); \ FTC_MruNode_CompareFunc _fcompare = (FTC_MruNode_CompareFunc)(famcmp); \
FTC_MruNode _mrunode; \
\ \
\ \
_gquery->gindex = (gindex); \ _gquery->gindex = (gindex); \
\ \
FTC_MRULIST_LOOKUP_CMP( &_gcache->families, _gquery, _fcompare, \ FTC_MRULIST_LOOKUP_CMP( &_gcache->families, _gquery, _fcompare, \
_gquery->family, error ); \ _mrunode, error ); \
_gquery->family = FTC_FAMILY( _mrunode ); \
if ( !error ) \ if ( !error ) \
{ \ { \
FTC_Family _gqfamily = _gquery->family; \ FTC_Family _gqfamily = _gquery->family; \
@ -303,11 +305,10 @@ FT_BEGIN_HEADER
#define FTC_GCACHE_LOOKUP_CMP( cache, famcmp, nodecmp, hash, \ #define FTC_GCACHE_LOOKUP_CMP( cache, famcmp, nodecmp, hash, \
gindex, query, node, error ) \ gindex, query, node, error ) \
FT_BEGIN_STMNT \ FT_BEGIN_STMNT \
void* _n = &(node); \
\
\ \
error = FTC_GCache_Lookup( FTC_GCACHE( cache ), hash, gindex, \ error = FTC_GCache_Lookup( FTC_GCACHE( cache ), hash, gindex, \
FTC_GQUERY( query ), (FTC_Node*)_n ); \ FTC_GQUERY( query ), node ); \
\
FT_END_STMNT FT_END_STMNT
#endif /* !FTC_INLINE */ #endif /* !FTC_INLINE */

View File

@ -103,12 +103,12 @@
} }
FT_LOCAL_DEF( FT_ULong ) FT_LOCAL_DEF( FT_Offset )
ftc_inode_weight( FTC_Node ftcinode, ftc_inode_weight( FTC_Node ftcinode,
FTC_Cache ftccache ) FTC_Cache ftccache )
{ {
FTC_INode inode = (FTC_INode)ftcinode; FTC_INode inode = (FTC_INode)ftcinode;
FT_ULong size = 0; FT_Offset size = 0;
FT_Glyph glyph = inode->glyph; FT_Glyph glyph = inode->glyph;
FT_UNUSED( ftccache ); FT_UNUSED( ftccache );
@ -151,7 +151,7 @@
#if 0 #if 0
FT_LOCAL_DEF( FT_ULong ) FT_LOCAL_DEF( FT_Offset )
FTC_INode_Weight( FTC_INode inode ) FTC_INode_Weight( FTC_INode inode )
{ {
return ftc_inode_weight( FTC_NODE( inode ), NULL ); return ftc_inode_weight( FTC_NODE( inode ), NULL );

View File

@ -26,6 +26,10 @@
#include "ftccback.h" #include "ftccback.h"
#include "ftcerror.h" #include "ftcerror.h"
#ifdef FT_CONFIG_OPTION_PIC
#error "cache system does not support PIC yet"
#endif
#undef FT_COMPONENT #undef FT_COMPONENT
#define FT_COMPONENT trace_cache #define FT_COMPONENT trace_cache
@ -78,6 +82,8 @@
} FTC_SizeNodeRec, *FTC_SizeNode; } FTC_SizeNodeRec, *FTC_SizeNode;
#define FTC_SIZE_NODE( x ) ( (FTC_SizeNode)( x ) )
FT_CALLBACK_DEF( void ) FT_CALLBACK_DEF( void )
ftc_size_node_done( FTC_MruNode ftcnode, ftc_size_node_done( FTC_MruNode ftcnode,
@ -177,7 +183,7 @@
FT_Size *asize ) FT_Size *asize )
{ {
FT_Error error; FT_Error error;
FTC_SizeNode node; FTC_MruNode mrunode;
if ( asize == NULL ) if ( asize == NULL )
@ -191,14 +197,14 @@
#ifdef FTC_INLINE #ifdef FTC_INLINE
FTC_MRULIST_LOOKUP_CMP( &manager->sizes, scaler, ftc_size_node_compare, FTC_MRULIST_LOOKUP_CMP( &manager->sizes, scaler, ftc_size_node_compare,
node, error ); mrunode, error );
#else #else
error = FTC_MruList_Lookup( &manager->sizes, scaler, (FTC_MruNode*)&node ); error = FTC_MruList_Lookup( &manager->sizes, scaler, &mrunode );
#endif #endif
if ( !error ) if ( !error )
*asize = node->size; *asize = FTC_SIZE_NODE( mrunode )->size;
return error; return error;
} }
@ -220,6 +226,8 @@
} FTC_FaceNodeRec, *FTC_FaceNode; } FTC_FaceNodeRec, *FTC_FaceNode;
#define FTC_FACE_NODE( x ) ( ( FTC_FaceNode )( x ) )
FT_CALLBACK_DEF( FT_Error ) FT_CALLBACK_DEF( FT_Error )
ftc_face_node_init( FTC_MruNode ftcnode, ftc_face_node_init( FTC_MruNode ftcnode,
@ -302,7 +310,7 @@
FT_Face *aface ) FT_Face *aface )
{ {
FT_Error error; FT_Error error;
FTC_FaceNode node; FTC_MruNode mrunode;
if ( aface == NULL ) if ( aface == NULL )
@ -317,14 +325,14 @@
#ifdef FTC_INLINE #ifdef FTC_INLINE
FTC_MRULIST_LOOKUP_CMP( &manager->faces, face_id, ftc_face_node_compare, FTC_MRULIST_LOOKUP_CMP( &manager->faces, face_id, ftc_face_node_compare,
node, error ); mrunode, error );
#else #else
error = FTC_MruList_Lookup( &manager->faces, face_id, (FTC_MruNode*)&node ); error = FTC_MruList_Lookup( &manager->faces, face_id, &mrunode );
#endif #endif
if ( !error ) if ( !error )
*aface = node->face; *aface = FTC_FACE_NODE( mrunode )->face;
return error; return error;
} }
@ -476,7 +484,7 @@
if ( (FT_UInt)node->cache_index >= manager->num_caches ) if ( (FT_UInt)node->cache_index >= manager->num_caches )
FT_ERROR(( "FTC_Manager_Check: invalid node (cache index = %ld\n", FT_TRACE0(( "FTC_Manager_Check: invalid node (cache index = %ld\n",
node->cache_index )); node->cache_index ));
else else
weight += cache->clazz.node_weight( node, cache ); weight += cache->clazz.node_weight( node, cache );
@ -486,7 +494,7 @@
} while ( node != first ); } while ( node != first );
if ( weight != manager->cur_weight ) if ( weight != manager->cur_weight )
FT_ERROR(( "FTC_Manager_Check: invalid weight %ld instead of %ld\n", FT_TRACE0(( "FTC_Manager_Check: invalid weight %ld instead of %ld\n",
manager->cur_weight, weight )); manager->cur_weight, weight ));
} }
@ -505,8 +513,8 @@
} while ( node != first ); } while ( node != first );
if ( count != manager->num_nodes ) if ( count != manager->num_nodes )
FT_ERROR(( FT_TRACE0(( "FTC_Manager_Check:"
"FTC_Manager_Check: invalid cache node count %d instead of %d\n", " invalid cache node count %d instead of %d\n",
manager->num_nodes, count )); manager->num_nodes, count ));
} }
} }
@ -534,7 +542,7 @@
#ifdef FT_DEBUG_ERROR #ifdef FT_DEBUG_ERROR
FTC_Manager_Check( manager ); FTC_Manager_Check( manager );
FT_ERROR(( "compressing, weight = %ld, max = %ld, nodes = %d\n", FT_TRACE0(( "compressing, weight = %ld, max = %ld, nodes = %d\n",
manager->cur_weight, manager->max_weight, manager->cur_weight, manager->max_weight,
manager->num_nodes )); manager->num_nodes ));
#endif #endif
@ -579,8 +587,8 @@
if ( manager->num_caches >= FTC_MAX_CACHES ) if ( manager->num_caches >= FTC_MAX_CACHES )
{ {
error = FTC_Err_Too_Many_Caches; error = FTC_Err_Too_Many_Caches;
FT_ERROR(( "%s: too many registered caches\n", FT_ERROR(( "FTC_Manager_RegisterCache:"
"FTC_Manager_Register_Cache" )); " too many registered caches\n" ));
goto Exit; goto Exit;
} }
@ -661,7 +669,9 @@
/* this will remove all FTC_SizeNode that correspond to /* this will remove all FTC_SizeNode that correspond to
* the face_id as well * the face_id as well
*/ */
FTC_MruList_RemoveSelection( &manager->faces, NULL, face_id ); FTC_MruList_RemoveSelection( &manager->faces,
(FTC_MruNode_CompareFunc)NULL,
face_id );
for ( nn = 0; nn < manager->num_caches; nn++ ) for ( nn = 0; nn < manager->num_caches; nn++ )
FTC_Cache_RemoveFaceID( manager->caches[nn], face_id ); FTC_Cache_RemoveFaceID( manager->caches[nn], face_id );

View File

@ -4,7 +4,7 @@
/* */ /* */
/* FreeType MRU support (body). */ /* FreeType MRU support (body). */
/* */ /* */
/* Copyright 2003, 2004, 2006 by */ /* Copyright 2003, 2004, 2006, 2009 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */ /* */
/* This file is part of the FreeType project, and may only be used, */ /* This file is part of the FreeType project, and may only be used, */
@ -46,7 +46,7 @@
{ {
if ( cnode == node ) if ( cnode == node )
{ {
fprintf( stderr, "FTC_MruNode_Prepend: invalid action!\n" ); fprintf( stderr, "FTC_MruNode_Prepend: invalid action\n" );
exit( 2 ); exit( 2 );
} }
cnode = cnode->next; cnode = cnode->next;
@ -94,7 +94,7 @@
} while ( cnode != first ); } while ( cnode != first );
fprintf( stderr, "FTC_MruNode_Up: invalid action!\n" ); fprintf( stderr, "FTC_MruNode_Up: invalid action\n" );
exit( 2 ); exit( 2 );
Ok: Ok:
} }
@ -141,7 +141,7 @@
} while ( cnode != first ); } while ( cnode != first );
fprintf( stderr, "FTC_MruNode_Remove: invalid action!\n" ); fprintf( stderr, "FTC_MruNode_Remove: invalid action\n" );
exit( 2 ); exit( 2 );
Ok: Ok:
} }

View File

@ -107,7 +107,7 @@ FT_BEGIN_HEADER
typedef struct FTC_MruListClassRec_ typedef struct FTC_MruListClassRec_
{ {
FT_UInt node_size; FT_Offset node_size;
FTC_MruNode_CompareFunc node_compare; FTC_MruNode_CompareFunc node_compare;
FTC_MruNode_InitFunc node_init; FTC_MruNode_InitFunc node_init;
FTC_MruNode_ResetFunc node_reset; FTC_MruNode_ResetFunc node_reset;
@ -163,7 +163,7 @@ FT_BEGIN_HEADER
FT_BEGIN_STMNT \ FT_BEGIN_STMNT \
FTC_MruNode* _pfirst = &(list)->nodes; \ FTC_MruNode* _pfirst = &(list)->nodes; \
FTC_MruNode_CompareFunc _compare = (FTC_MruNode_CompareFunc)(compare); \ FTC_MruNode_CompareFunc _compare = (FTC_MruNode_CompareFunc)(compare); \
FTC_MruNode _first, _node, *_pnode; \ FTC_MruNode _first, _node; \
\ \
\ \
error = 0; \ error = 0; \
@ -180,8 +180,7 @@ FT_BEGIN_HEADER
if ( _node != _first ) \ if ( _node != _first ) \
FTC_MruNode_Up( _pfirst, _node ); \ FTC_MruNode_Up( _pfirst, _node ); \
\ \
_pnode = (FTC_MruNode*)(void*)&(node); \ node = _node; \
*_pnode = _node; \
goto _MruOk; \ goto _MruOk; \
} \ } \
_node = _node->next; \ _node = _node->next; \

View File

@ -4,7 +4,7 @@
/* */ /* */
/* FreeType sbits manager (body). */ /* FreeType sbits manager (body). */
/* */ /* */
/* Copyright 2000-2001, 2002, 2003, 2004, 2005, 2006 by */ /* Copyright 2000-2001, 2002, 2003, 2004, 2005, 2006, 2009 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */ /* */
/* This file is part of the FreeType project, and may only be used, */ /* This file is part of the FreeType project, and may only be used, */
@ -26,6 +26,9 @@
#include "ftccback.h" #include "ftccback.h"
#include "ftcerror.h" #include "ftcerror.h"
#undef FT_COMPONENT
#define FT_COMPONENT trace_cache
/*************************************************************************/ /*************************************************************************/
/*************************************************************************/ /*************************************************************************/
@ -129,13 +132,13 @@
FT_Int temp; FT_Int temp;
FT_GlyphSlot slot = face->glyph; FT_GlyphSlot slot = face->glyph;
FT_Bitmap* bitmap = &slot->bitmap; FT_Bitmap* bitmap = &slot->bitmap;
FT_Int xadvance, yadvance; FT_Pos xadvance, yadvance; /* FT_GlyphSlot->advance.{x|y} */
if ( slot->format != FT_GLYPH_FORMAT_BITMAP ) if ( slot->format != FT_GLYPH_FORMAT_BITMAP )
{ {
FT_ERROR(( "%s: glyph loaded didn't return a bitmap!\n", FT_TRACE0(( "ftc_snode_load:"
"ftc_snode_load" )); " glyph loaded didn't return a bitmap\n" ));
goto BadGlyph; goto BadGlyph;
} }
@ -263,7 +266,7 @@
} }
FT_LOCAL_DEF( FT_ULong ) FT_LOCAL_DEF( FT_Offset )
ftc_snode_weight( FTC_Node ftcsnode, ftc_snode_weight( FTC_Node ftcsnode,
FTC_Cache cache ) FTC_Cache cache )
{ {
@ -271,7 +274,7 @@
FT_UInt count = snode->count; FT_UInt count = snode->count;
FTC_SBit sbit = snode->sbits; FTC_SBit sbit = snode->sbits;
FT_Int pitch; FT_Int pitch;
FT_ULong size; FT_Offset size;
FT_UNUSED( cache ); FT_UNUSED( cache );
@ -300,7 +303,7 @@
#if 0 #if 0
FT_LOCAL_DEF( FT_ULong ) FT_LOCAL_DEF( FT_Offset )
FTC_SNode_Weight( FTC_SNode snode ) FTC_SNode_Weight( FTC_SNode snode )
{ {
return ftc_snode_weight( FTC_NODE( snode ), NULL ); return ftc_snode_weight( FTC_NODE( snode ), NULL );

View File

@ -19,6 +19,7 @@
#define FT_MAKE_OPTION_SINGLE_OBJECT #define FT_MAKE_OPTION_SINGLE_OBJECT
#include <ft2build.h> #include <ft2build.h>
#include "cffpic.c"
#include "cffdrivr.c" #include "cffdrivr.c"
#include "cffparse.c" #include "cffparse.c"
#include "cffload.c" #include "cffload.c"

View File

@ -65,7 +65,7 @@
} }
FT_CALLBACK_DEF( FT_UInt ) FT_CALLBACK_DEF( FT_UInt32 )
cff_cmap_encoding_char_next( CFF_CMapStd cmap, cff_cmap_encoding_char_next( CFF_CMapStd cmap,
FT_UInt32 *pchar_code ) FT_UInt32 *pchar_code )
{ {
@ -99,9 +99,7 @@
} }
FT_CALLBACK_TABLE_DEF const FT_CMap_ClassRec FT_DEFINE_CMAP_CLASS(cff_cmap_encoding_class_rec,
cff_cmap_encoding_class_rec =
{
sizeof ( CFF_CMapStdRec ), sizeof ( CFF_CMapStdRec ),
(FT_CMap_InitFunc) cff_cmap_encoding_init, (FT_CMap_InitFunc) cff_cmap_encoding_init,
@ -110,7 +108,7 @@
(FT_CMap_CharNextFunc) cff_cmap_encoding_char_next, (FT_CMap_CharNextFunc) cff_cmap_encoding_char_next,
NULL, NULL, NULL, NULL, NULL NULL, NULL, NULL, NULL, NULL
}; )
/*************************************************************************/ /*************************************************************************/
@ -194,7 +192,7 @@
} }
FT_CALLBACK_DEF( FT_UInt ) FT_CALLBACK_DEF( FT_UInt32 )
cff_cmap_unicode_char_next( PS_Unicodes unicodes, cff_cmap_unicode_char_next( PS_Unicodes unicodes,
FT_UInt32 *pchar_code ) FT_UInt32 *pchar_code )
{ {
@ -207,9 +205,7 @@
} }
FT_CALLBACK_TABLE_DEF const FT_CMap_ClassRec FT_DEFINE_CMAP_CLASS(cff_cmap_unicode_class_rec,
cff_cmap_unicode_class_rec =
{
sizeof ( PS_UnicodesRec ), sizeof ( PS_UnicodesRec ),
(FT_CMap_InitFunc) cff_cmap_unicode_init, (FT_CMap_InitFunc) cff_cmap_unicode_init,
@ -218,7 +214,6 @@
(FT_CMap_CharNextFunc) cff_cmap_unicode_char_next, (FT_CMap_CharNextFunc) cff_cmap_unicode_char_next,
NULL, NULL, NULL, NULL, NULL NULL, NULL, NULL, NULL, NULL
}; )
/* END */ /* END */

View File

@ -43,8 +43,7 @@ FT_BEGIN_HEADER
} CFF_CMapStdRec; } CFF_CMapStdRec;
FT_CALLBACK_TABLE const FT_CMap_ClassRec FT_DECLARE_CMAP_CLASS(cff_cmap_encoding_class_rec)
cff_cmap_encoding_class_rec;
/*************************************************************************/ /*************************************************************************/
@ -57,8 +56,7 @@ FT_BEGIN_HEADER
/* unicode (synthetic) cmaps */ /* unicode (synthetic) cmaps */
FT_CALLBACK_TABLE const FT_CMap_ClassRec FT_DECLARE_CMAP_CLASS(cff_cmap_unicode_class_rec)
cff_cmap_unicode_class_rec;
FT_END_HEADER FT_END_HEADER

View File

@ -21,7 +21,6 @@
#include FT_INTERNAL_DEBUG_H #include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_STREAM_H #include FT_INTERNAL_STREAM_H
#include FT_INTERNAL_SFNT_H #include FT_INTERNAL_SFNT_H
#include FT_TRUETYPE_IDS_H
#include FT_SERVICE_CID_H #include FT_SERVICE_CID_H
#include FT_SERVICE_POSTSCRIPT_CMAPS_H #include FT_SERVICE_POSTSCRIPT_CMAPS_H
#include FT_SERVICE_POSTSCRIPT_INFO_H #include FT_SERVICE_POSTSCRIPT_INFO_H
@ -32,8 +31,10 @@
#include "cffgload.h" #include "cffgload.h"
#include "cffload.h" #include "cffload.h"
#include "cffcmap.h" #include "cffcmap.h"
#include "cffparse.h"
#include "cfferrs.h" #include "cfferrs.h"
#include "cffpic.h"
#include FT_SERVICE_XFREE86_NAME_H #include FT_SERVICE_XFREE86_NAME_H
#include FT_SERVICE_GLYPH_DICT_H #include FT_SERVICE_GLYPH_DICT_H
@ -199,7 +200,7 @@
FT_GlyphSlot slot = face->glyph; FT_GlyphSlot slot = face->glyph;
flags |= FT_LOAD_ADVANCE_ONLY; flags |= (FT_UInt32)FT_LOAD_ADVANCE_ONLY;
for ( nn = 0; nn < count; nn++ ) for ( nn = 0; nn < count; nn++ )
{ {
@ -238,10 +239,10 @@
FT_FACE_FIND_GLOBAL_SERVICE( face, psnames, POSTSCRIPT_CMAPS ); FT_FACE_FIND_GLOBAL_SERVICE( face, psnames, POSTSCRIPT_CMAPS );
if ( !psnames ) if ( !psnames )
{ {
FT_ERROR(( "cff_get_glyph_name:" )); FT_ERROR(( "cff_get_glyph_name:"
FT_ERROR(( " cannot get glyph name from CFF & CEF fonts\n" )); " cannot get glyph name from CFF & CEF fonts\n"
FT_ERROR(( " " )); " "
FT_ERROR(( " without the `PSNames' module\n" )); " without the `PSNames' module\n" ));
error = CFF_Err_Unknown_File_Format; error = CFF_Err_Unknown_File_Format;
goto Exit; goto Exit;
} }
@ -309,11 +310,10 @@
} }
static const FT_Service_GlyphDictRec cff_service_glyph_dict = FT_DEFINE_SERVICE_GLYPHDICTREC(cff_service_glyph_dict,
{
(FT_GlyphDict_GetNameFunc) cff_get_glyph_name, (FT_GlyphDict_GetNameFunc) cff_get_glyph_name,
(FT_GlyphDict_NameIndexFunc)cff_get_name_index, (FT_GlyphDict_NameIndexFunc)cff_get_name_index
}; )
/* /*
@ -378,13 +378,12 @@
} }
static const FT_Service_PsInfoRec cff_service_ps_info = FT_DEFINE_SERVICE_PSINFOREC(cff_service_ps_info,
{
(PS_GetFontInfoFunc) cff_ps_get_font_info, (PS_GetFontInfoFunc) cff_ps_get_font_info,
(PS_GetFontExtraFunc) NULL, (PS_GetFontExtraFunc) NULL,
(PS_HasGlyphNamesFunc) cff_ps_has_glyph_names, (PS_HasGlyphNamesFunc) cff_ps_has_glyph_names,
(PS_GetFontPrivateFunc)NULL /* unsupported with CFF fonts */ (PS_GetFontPrivateFunc)NULL /* unsupported with CFF fonts */
}; )
/* /*
@ -402,10 +401,9 @@
} }
static const FT_Service_PsFontNameRec cff_service_ps_name = FT_DEFINE_SERVICE_PSFONTNAMEREC(cff_service_ps_name,
{
(FT_PsName_GetFunc)cff_get_ps_name (FT_PsName_GetFunc)cff_get_ps_name
}; )
/* /*
@ -424,16 +422,16 @@
{ {
FT_CMap cmap = FT_CMAP( charmap ); FT_CMap cmap = FT_CMAP( charmap );
FT_Error error = CFF_Err_Ok; FT_Error error = CFF_Err_Ok;
FT_Face face = FT_CMAP_FACE( cmap );
FT_Library library = FT_FACE_LIBRARY( face );
cmap_info->language = 0; cmap_info->language = 0;
cmap_info->format = 0; cmap_info->format = 0;
if ( cmap->clazz != &cff_cmap_encoding_class_rec && if ( cmap->clazz != &FT_CFF_CMAP_ENCODING_CLASS_REC_GET &&
cmap->clazz != &cff_cmap_unicode_class_rec ) cmap->clazz != &FT_CFF_CMAP_UNICODE_CLASS_REC_GET )
{ {
FT_Face face = FT_CMAP_FACE( cmap );
FT_Library library = FT_FACE_LIBRARY( face );
FT_Module sfnt = FT_Get_Module( library, "sfnt" ); FT_Module sfnt = FT_Get_Module( library, "sfnt" );
FT_Service_TTCMaps service = FT_Service_TTCMaps service =
(FT_Service_TTCMaps)ft_module_get_service( sfnt, (FT_Service_TTCMaps)ft_module_get_service( sfnt,
@ -448,10 +446,9 @@
} }
static const FT_Service_TTCMapsRec cff_service_get_cmap_info = FT_DEFINE_SERVICE_TTCMAPSREC(cff_service_get_cmap_info,
{
(TT_CMap_Info_GetFunc)cff_get_cmap_info (TT_CMap_Info_GetFunc)cff_get_cmap_info
}; )
/* /*
@ -498,8 +495,19 @@
*ordering = cff->ordering; *ordering = cff->ordering;
} }
/*
* XXX: According to Adobe TechNote #5176, the supplement in CFF
* can be a real number. We truncate it to fit public API
* since freetype-2.3.6.
*/
if ( supplement ) if ( supplement )
*supplement = dict->cid_supplement; {
if ( dict->cid_supplement < FT_INT_MIN ||
dict->cid_supplement > FT_INT_MAX )
FT_TRACE1(( "cff_get_ros: too large supplement %d is truncated\n",
dict->cid_supplement ));
*supplement = (FT_Int)dict->cid_supplement;
}
} }
Fail: Fail:
@ -570,12 +578,11 @@
} }
static const FT_Service_CIDRec cff_service_cid_info = FT_DEFINE_SERVICE_CIDREC(cff_service_cid_info,
{
(FT_CID_GetRegistryOrderingSupplementFunc)cff_get_ros, (FT_CID_GetRegistryOrderingSupplementFunc)cff_get_ros,
(FT_CID_GetIsInternallyCIDKeyedFunc) cff_get_is_cid, (FT_CID_GetIsInternallyCIDKeyedFunc) cff_get_is_cid,
(FT_CID_GetCIDFromGlyphIndexFunc) cff_get_cid_from_glyph_index (FT_CID_GetCIDFromGlyphIndexFunc) cff_get_cid_from_glyph_index
}; )
/*************************************************************************/ /*************************************************************************/
@ -589,20 +596,24 @@
/*************************************************************************/ /*************************************************************************/
/*************************************************************************/ /*************************************************************************/
/*************************************************************************/ /*************************************************************************/
static const FT_ServiceDescRec cff_services[] =
{
{ FT_SERVICE_ID_XF86_NAME, FT_XF86_FORMAT_CFF },
{ FT_SERVICE_ID_POSTSCRIPT_INFO, &cff_service_ps_info },
{ FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &cff_service_ps_name },
#ifndef FT_CONFIG_OPTION_NO_GLYPH_NAMES #ifndef FT_CONFIG_OPTION_NO_GLYPH_NAMES
{ FT_SERVICE_ID_GLYPH_DICT, &cff_service_glyph_dict }, FT_DEFINE_SERVICEDESCREC6(cff_services,
FT_SERVICE_ID_XF86_NAME, FT_XF86_FORMAT_CFF,
FT_SERVICE_ID_POSTSCRIPT_INFO, &FT_CFF_SERVICE_PS_INFO_GET,
FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &FT_CFF_SERVICE_PS_NAME_GET,
FT_SERVICE_ID_GLYPH_DICT, &FT_CFF_SERVICE_GLYPH_DICT_GET,
FT_SERVICE_ID_TT_CMAP, &FT_CFF_SERVICE_GET_CMAP_INFO_GET,
FT_SERVICE_ID_CID, &FT_CFF_SERVICE_CID_INFO_GET
)
#else
FT_DEFINE_SERVICEDESCREC5(cff_services,
FT_SERVICE_ID_XF86_NAME, FT_XF86_FORMAT_CFF,
FT_SERVICE_ID_POSTSCRIPT_INFO, &FT_CFF_SERVICE_PS_INFO_GET,
FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &FT_CFF_SERVICE_PS_NAME_GET,
FT_SERVICE_ID_TT_CMAP, &FT_CFF_SERVICE_GET_CMAP_INFO_GET,
FT_SERVICE_ID_CID, &FT_CFF_SERVICE_CID_INFO_GET
)
#endif #endif
{ FT_SERVICE_ID_TT_CMAP, &cff_service_get_cmap_info },
{ FT_SERVICE_ID_CID, &cff_service_cid_info },
{ NULL, NULL }
};
FT_CALLBACK_DEF( FT_Module_Interface ) FT_CALLBACK_DEF( FT_Module_Interface )
cff_get_interface( FT_Module driver, /* CFF_Driver */ cff_get_interface( FT_Module driver, /* CFF_Driver */
@ -610,9 +621,11 @@
{ {
FT_Module sfnt; FT_Module sfnt;
FT_Module_Interface result; FT_Module_Interface result;
FT_Library library = driver->library;
FT_UNUSED(library);
result = ft_service_list_lookup( cff_services, module_interface ); result = ft_service_list_lookup( FT_CFF_SERVICES_GET, module_interface );
if ( result != NULL ) if ( result != NULL )
return result; return result;
@ -625,11 +638,13 @@
/* The FT_DriverInterface structure is defined in ftdriver.h. */ /* The FT_DriverInterface structure is defined in ftdriver.h. */
FT_CALLBACK_TABLE_DEF #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
const FT_Driver_ClassRec cff_driver_class = #define CFF_SIZE_SELECT cff_size_select
{ #else
/* begin with the FT_Module_Class fields */ #define CFF_SIZE_SELECT 0
{ #endif
FT_DEFINE_DRIVER(cff_driver_class,
FT_MODULE_FONT_DRIVER | FT_MODULE_FONT_DRIVER |
FT_MODULE_DRIVER_SCALABLE | FT_MODULE_DRIVER_SCALABLE |
FT_MODULE_DRIVER_HAS_HINTER, FT_MODULE_DRIVER_HAS_HINTER,
@ -644,7 +659,6 @@
cff_driver_init, cff_driver_init,
cff_driver_done, cff_driver_done,
cff_get_interface, cff_get_interface,
},
/* now the specific driver fields */ /* now the specific driver fields */
sizeof( TT_FaceRec ), sizeof( TT_FaceRec ),
@ -658,10 +672,8 @@
cff_slot_init, cff_slot_init,
cff_slot_done, cff_slot_done,
#ifdef FT_CONFIG_OPTION_OLD_INTERNALS ft_stub_set_char_sizes, /* FT_CONFIG_OPTION_OLD_INTERNALS */
ft_stub_set_char_sizes, ft_stub_set_pixel_sizes, /* FT_CONFIG_OPTION_OLD_INTERNALS */
ft_stub_set_pixel_sizes,
#endif
Load_Glyph, Load_Glyph,
@ -671,12 +683,8 @@
cff_size_request, cff_size_request,
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS CFF_SIZE_SELECT
cff_size_select )
#else
0 /* FT_Size_SelectFunc */
#endif
};
/* END */ /* END */

View File

@ -27,8 +27,7 @@
FT_BEGIN_HEADER FT_BEGIN_HEADER
FT_CALLBACK_TABLE FT_DECLARE_DRIVER( cff_driver_class )
const FT_Driver_ClassRec cff_driver_class;
FT_END_HEADER FT_END_HEADER

View File

@ -18,11 +18,9 @@
#include <ft2build.h> #include <ft2build.h>
#include FT_INTERNAL_DEBUG_H #include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_CALC_H
#include FT_INTERNAL_STREAM_H #include FT_INTERNAL_STREAM_H
#include FT_INTERNAL_SFNT_H #include FT_INTERNAL_SFNT_H
#include FT_OUTLINE_H #include FT_OUTLINE_H
#include FT_TRUETYPE_TAGS_H
#include FT_INTERNAL_POSTSCRIPT_HINTS_H #include FT_INTERNAL_POSTSCRIPT_HINTS_H
#include "cffobjs.h" #include "cffobjs.h"
@ -474,8 +472,6 @@
point->x = x >> 16; point->x = x >> 16;
point->y = y >> 16; point->y = y >> 16;
*control = (FT_Byte)( flag ? FT_CURVE_TAG_ON : FT_CURVE_TAG_CUBIC ); *control = (FT_Byte)( flag ? FT_CURVE_TAG_ON : FT_CURVE_TAG_CUBIC );
builder->last = *point;
} }
outline->n_points++; outline->n_points++;
@ -554,27 +550,24 @@
cff_builder_close_contour( CFF_Builder* builder ) cff_builder_close_contour( CFF_Builder* builder )
{ {
FT_Outline* outline = builder->current; FT_Outline* outline = builder->current;
FT_Int first;
if ( !outline ) if ( !outline )
return; return;
/* XXXX: We must not include the last point in the path if it */ first = outline->n_contours <= 1
? 0 : outline->contours[outline->n_contours - 2] + 1;
/* We must not include the last point in the path if it */
/* is located on the first point. */ /* is located on the first point. */
if ( outline->n_points > 1 ) if ( outline->n_points > 1 )
{ {
FT_Int first = 0;
FT_Vector* p1 = outline->points + first; FT_Vector* p1 = outline->points + first;
FT_Vector* p2 = outline->points + outline->n_points - 1; FT_Vector* p2 = outline->points + outline->n_points - 1;
FT_Byte* control = (FT_Byte*)outline->tags + outline->n_points - 1; FT_Byte* control = (FT_Byte*)outline->tags + outline->n_points - 1;
if ( outline->n_contours > 1 )
{
first = outline->contours[outline->n_contours - 2] + 1;
p1 = outline->points + first;
}
/* `delete' last point only if it coincides with the first */ /* `delete' last point only if it coincides with the first */
/* point and if it is not a control point (which can happen). */ /* point and if it is not a control point (which can happen). */
if ( p1->x == p2->x && p1->y == p2->y ) if ( p1->x == p2->x && p1->y == p2->y )
@ -583,9 +576,19 @@
} }
if ( outline->n_contours > 0 ) if ( outline->n_contours > 0 )
{
/* Don't add contours only consisting of one point, i.e., */
/* check whether begin point and last point are the same. */
if ( first == outline->n_points - 1 )
{
outline->n_contours--;
outline->n_points--;
}
else
outline->contours[outline->n_contours - 1] = outline->contours[outline->n_contours - 1] =
(short)( outline->n_points - 1 ); (short)( outline->n_points - 1 );
} }
}
static FT_Int static FT_Int
@ -704,6 +707,12 @@
FT_ULong charstring_len; FT_ULong charstring_len;
if ( decoder->seac )
{
FT_ERROR(( "cff_operator_seac: invalid nested seac\n" ));
return CFF_Err_Syntax_Error;
}
#ifdef FT_CONFIG_OPTION_INCREMENTAL #ifdef FT_CONFIG_OPTION_INCREMENTAL
/* Incremental fonts don't necessarily have valid charsets. */ /* Incremental fonts don't necessarily have valid charsets. */
/* They use the character code, not the glyph index, in this case. */ /* They use the character code, not the glyph index, in this case. */
@ -724,8 +733,8 @@
if ( bchar_index < 0 || achar_index < 0 ) if ( bchar_index < 0 || achar_index < 0 )
{ {
FT_ERROR(( "cff_operator_seac:" )); FT_ERROR(( "cff_operator_seac:"
FT_ERROR(( " invalid seac character code arguments\n" )); " invalid seac character code arguments\n" ));
return CFF_Err_Syntax_Error; return CFF_Err_Syntax_Error;
} }
@ -774,8 +783,11 @@
&charstring, &charstring_len ); &charstring, &charstring_len );
if ( !error ) if ( !error )
{ {
/* the seac operator must not be nested */
decoder->seac = TRUE;
error = cff_decoder_parse_charstrings( decoder, charstring, error = cff_decoder_parse_charstrings( decoder, charstring,
charstring_len ); charstring_len );
decoder->seac = FALSE;
if ( error ) if ( error )
goto Exit; goto Exit;
@ -800,8 +812,11 @@
&charstring, &charstring_len ); &charstring, &charstring_len );
if ( !error ) if ( !error )
{ {
/* the seac operator must not be nested */
decoder->seac = TRUE;
error = cff_decoder_parse_charstrings( decoder, charstring, error = cff_decoder_parse_charstrings( decoder, charstring,
charstring_len ); charstring_len );
decoder->seac = FALSE;
if ( error ) if ( error )
goto Exit; goto Exit;
@ -863,9 +878,10 @@
decoder->read_width = 1; decoder->read_width = 1;
/* compute random seed from stack address of parameter */ /* compute random seed from stack address of parameter */
seed = (FT_Fixed)(char*)&seed ^ seed = (FT_Fixed)( ( (FT_PtrDist)(char*)&seed ^
(FT_Fixed)(char*)&decoder ^ (FT_PtrDist)(char*)&decoder ^
(FT_Fixed)(char*)&charstring_base; (FT_PtrDist)(char*)&charstring_base ) &
FT_ULONG_MAX ) ;
seed = ( seed ^ ( seed >> 10 ) ^ ( seed >> 20 ) ) & 0xFFFFL; seed = ( seed ^ ( seed >> 10 ) ^ ( seed >> 20 ) ) & 0xFFFFL;
if ( seed == 0 ) if ( seed == 0 )
seed = 0x7384; seed = 0x7384;
@ -920,18 +936,18 @@
ip += 2; ip += 2;
} }
else if ( v < 247 ) else if ( v < 247 )
val = (FT_Long)v - 139; val = (FT_Int32)v - 139;
else if ( v < 251 ) else if ( v < 251 )
{ {
if ( ip >= limit ) if ( ip >= limit )
goto Syntax_Error; goto Syntax_Error;
val = ( (FT_Long)v - 247 ) * 256 + *ip++ + 108; val = ( (FT_Int32)v - 247 ) * 256 + *ip++ + 108;
} }
else if ( v < 255 ) else if ( v < 255 )
{ {
if ( ip >= limit ) if ( ip >= limit )
goto Syntax_Error; goto Syntax_Error;
val = -( (FT_Long)v - 251 ) * 256 - *ip++ - 108; val = -( (FT_Int32)v - 251 ) * 256 - *ip++ - 108;
} }
else else
{ {
@ -2241,8 +2257,8 @@
if ( idx >= decoder->num_locals ) if ( idx >= decoder->num_locals )
{ {
FT_ERROR(( "cff_decoder_parse_charstrings:" )); FT_ERROR(( "cff_decoder_parse_charstrings:"
FT_ERROR(( " invalid local subr index\n" )); " invalid local subr index\n" ));
goto Syntax_Error; goto Syntax_Error;
} }
@ -2263,7 +2279,7 @@
if ( !zone->base || zone->limit == zone->base ) if ( !zone->base || zone->limit == zone->base )
{ {
FT_ERROR(( "cff_decoder_parse_charstrings:" FT_ERROR(( "cff_decoder_parse_charstrings:"
" invoking empty subrs!\n" )); " invoking empty subrs\n" ));
goto Syntax_Error; goto Syntax_Error;
} }
@ -2283,8 +2299,8 @@
if ( idx >= decoder->num_globals ) if ( idx >= decoder->num_globals )
{ {
FT_ERROR(( "cff_decoder_parse_charstrings:" )); FT_ERROR(( "cff_decoder_parse_charstrings:"
FT_ERROR(( " invalid global subr index\n" )); " invalid global subr index\n" ));
goto Syntax_Error; goto Syntax_Error;
} }
@ -2305,7 +2321,7 @@
if ( !zone->base || zone->limit == zone->base ) if ( !zone->base || zone->limit == zone->base )
{ {
FT_ERROR(( "cff_decoder_parse_charstrings:" FT_ERROR(( "cff_decoder_parse_charstrings:"
" invoking empty subrs!\n" )); " invoking empty subrs\n" ));
goto Syntax_Error; goto Syntax_Error;
} }
@ -2354,15 +2370,15 @@
return error; return error;
Syntax_Error: Syntax_Error:
FT_TRACE4(( "cff_decoder_parse_charstrings: syntax error!\n" )); FT_TRACE4(( "cff_decoder_parse_charstrings: syntax error\n" ));
return CFF_Err_Invalid_File_Format; return CFF_Err_Invalid_File_Format;
Stack_Underflow: Stack_Underflow:
FT_TRACE4(( "cff_decoder_parse_charstrings: stack underflow!\n" )); FT_TRACE4(( "cff_decoder_parse_charstrings: stack underflow\n" ));
return CFF_Err_Too_Few_Arguments; return CFF_Err_Too_Few_Arguments;
Stack_Overflow: Stack_Overflow:
FT_TRACE4(( "cff_decoder_parse_charstrings: stack overflow!\n" )); FT_TRACE4(( "cff_decoder_parse_charstrings: stack overflow\n" ));
return CFF_Err_Stack_Overflow; return CFF_Err_Stack_Overflow;
} }
@ -2565,8 +2581,8 @@
FT_Byte fd_index = cff_fd_select_get( &cff->fd_select, FT_Byte fd_index = cff_fd_select_get( &cff->fd_select,
glyph_index ); glyph_index );
FT_Int top_upm = cff->top_font.font_dict.units_per_em; FT_ULong top_upm = cff->top_font.font_dict.units_per_em;
FT_Int sub_upm = cff->subfonts[fd_index]->font_dict.units_per_em; FT_ULong sub_upm = cff->subfonts[fd_index]->font_dict.units_per_em;
font_matrix = cff->subfonts[fd_index]->font_dict.font_matrix; font_matrix = cff->subfonts[fd_index]->font_dict.font_matrix;
@ -2711,9 +2727,14 @@
glyph->root.linearHoriAdvance = decoder.glyph_width; glyph->root.linearHoriAdvance = decoder.glyph_width;
glyph->root.internal->glyph_transformed = 0; glyph->root.internal->glyph_transformed = 0;
#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
has_vertical_info = FT_BOOL( face->vertical_info && has_vertical_info = FT_BOOL( face->vertical_info &&
face->vertical.number_Of_VMetrics > 0 && face->vertical.number_Of_VMetrics > 0 &&
face->vertical.long_metrics ); face->vertical.long_metrics );
#else
has_vertical_info = FT_BOOL( face->vertical_info &&
face->vertical.number_Of_VMetrics > 0 );
#endif
/* get the vertical metrics from the vtmx table if we have one */ /* get the vertical metrics from the vtmx table if we have one */
if ( has_vertical_info ) if ( has_vertical_info )
@ -2750,8 +2771,8 @@
glyph->root.outline.flags |= FT_OUTLINE_REVERSE_FILL; glyph->root.outline.flags |= FT_OUTLINE_REVERSE_FILL;
/* apply the font matrix -- `xx' has already been normalized */ if ( !( font_matrix.xx == 0x10000L &&
if ( !( font_matrix.yy == 0x10000L && font_matrix.yy == 0x10000L &&
font_matrix.xy == 0 && font_matrix.xy == 0 &&
font_matrix.yx == 0 ) ) font_matrix.yx == 0 ) )
FT_Outline_Transform( &glyph->root.outline, &font_matrix ); FT_Outline_Transform( &glyph->root.outline, &font_matrix );
@ -2804,7 +2825,8 @@
metrics->horiBearingY = cbox.yMax; metrics->horiBearingY = cbox.yMax;
if ( has_vertical_info ) if ( has_vertical_info )
metrics->vertBearingX = -metrics->width / 2; metrics->vertBearingX = metrics->horiBearingX -
metrics->horiAdvance / 2;
else else
ft_synthesize_vertical_metrics( metrics, ft_synthesize_vertical_metrics( metrics,
metrics->vertAdvance ); metrics->vertAdvance );

View File

@ -4,7 +4,7 @@
/* */ /* */
/* OpenType Glyph Loader (specification). */ /* OpenType Glyph Loader (specification). */
/* */ /* */
/* 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. */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */ /* */
/* This file is part of the FreeType project, and may only be used, */ /* This file is part of the FreeType project, and may only be used, */
@ -53,8 +53,6 @@ FT_BEGIN_HEADER
/* */ /* */
/* current :: The current glyph outline. */ /* current :: The current glyph outline. */
/* */ /* */
/* last :: The last point position. */
/* */
/* pos_x :: The horizontal translation (if composite glyph). */ /* pos_x :: The horizontal translation (if composite glyph). */
/* */ /* */
/* pos_y :: The vertical translation (if composite glyph). */ /* pos_y :: The vertical translation (if composite glyph). */
@ -88,8 +86,6 @@ FT_BEGIN_HEADER
FT_Outline* base; FT_Outline* base;
FT_Outline* current; FT_Outline* current;
FT_Vector last;
FT_Pos pos_x; FT_Pos pos_x;
FT_Pos pos_y; FT_Pos pos_y;
@ -158,6 +154,8 @@ FT_BEGIN_HEADER
FT_Render_Mode hint_mode; FT_Render_Mode hint_mode;
FT_Bool seac;
} CFF_Decoder; } CFF_Decoder;

View File

@ -736,6 +736,7 @@
{ {
FT_Error error = FT_Err_Ok; FT_Error error = FT_Err_Ok;
FT_UInt i; FT_UInt i;
FT_Long j;
FT_UShort max_cid = 0; FT_UShort max_cid = 0;
@ -750,8 +751,11 @@
if ( FT_NEW_ARRAY( charset->cids, max_cid ) ) if ( FT_NEW_ARRAY( charset->cids, max_cid ) )
goto Exit; goto Exit;
for ( i = 0; i < num_glyphs; i++ ) /* When multiple GIDs map to the same CID, we choose the lowest */
charset->cids[charset->sids[i]] = (FT_UShort)i; /* GID. This is not described in any spec, but it matches the */
/* behaviour of recent Acroread versions. */
for ( j = num_glyphs - 1; j >= 0 ; j-- )
charset->cids[charset->sids[j]] = (FT_UShort)j;
charset->max_cid = max_cid; charset->max_cid = max_cid;
charset->num_glyphs = num_glyphs; charset->num_glyphs = num_glyphs;
@ -842,7 +846,20 @@
goto Exit; goto Exit;
for ( j = 1; j < num_glyphs; j++ ) for ( j = 1; j < num_glyphs; j++ )
charset->sids[j] = FT_GET_USHORT(); {
FT_UShort sid = FT_GET_USHORT();
/* this constant is given in the CFF specification */
if ( sid < 65000L )
charset->sids[j] = sid;
else
{
FT_TRACE0(( "cff_charset_load:"
" invalid SID value %d set to zero\n", sid ));
charset->sids[j] = 0;
}
}
FT_FRAME_EXIT(); FT_FRAME_EXIT();
} }
@ -875,6 +892,20 @@
goto Exit; goto Exit;
} }
/* check whether the range contains at least one valid glyph; */
/* the constant is given in the CFF specification */
if ( glyph_sid >= 65000L ) {
FT_ERROR(( "cff_charset_load: invalid SID range\n" ));
error = CFF_Err_Invalid_File_Format;
goto Exit;
}
/* try to rescue some of the SIDs if `nleft' is too large */
if ( nleft > 65000L - 1L || glyph_sid >= 65000L - nleft ) {
FT_ERROR(( "cff_charset_load: invalid SID range trimmed\n" ));
nleft = ( FT_UInt )( 65000L - 1L - glyph_sid );
}
/* Fill in the range of sids -- `nleft + 1' glyphs. */ /* Fill in the range of sids -- `nleft + 1' glyphs. */
for ( i = 0; j < num_glyphs && i <= nleft; i++, j++, glyph_sid++ ) for ( i = 0; j < num_glyphs && i <= nleft; i++, j++, glyph_sid++ )
charset->sids[j] = glyph_sid; charset->sids[j] = glyph_sid;
@ -883,7 +914,7 @@
break; break;
default: default:
FT_ERROR(( "cff_charset_load: invalid table format!\n" )); FT_ERROR(( "cff_charset_load: invalid table format\n" ));
error = CFF_Err_Invalid_File_Format; error = CFF_Err_Invalid_File_Format;
goto Exit; goto Exit;
} }
@ -906,7 +937,7 @@
if ( num_glyphs > 229 ) if ( num_glyphs > 229 )
{ {
FT_ERROR(( "cff_charset_load: implicit charset larger than\n" FT_ERROR(( "cff_charset_load: implicit charset larger than\n"
"predefined charset (Adobe ISO-Latin)!\n" )); "predefined charset (Adobe ISO-Latin)\n" ));
error = CFF_Err_Invalid_File_Format; error = CFF_Err_Invalid_File_Format;
goto Exit; goto Exit;
} }
@ -924,7 +955,7 @@
if ( num_glyphs > 166 ) if ( num_glyphs > 166 )
{ {
FT_ERROR(( "cff_charset_load: implicit charset larger than\n" FT_ERROR(( "cff_charset_load: implicit charset larger than\n"
"predefined charset (Adobe Expert)!\n" )); "predefined charset (Adobe Expert)\n" ));
error = CFF_Err_Invalid_File_Format; error = CFF_Err_Invalid_File_Format;
goto Exit; goto Exit;
} }
@ -942,7 +973,7 @@
if ( num_glyphs > 87 ) if ( num_glyphs > 87 )
{ {
FT_ERROR(( "cff_charset_load: implicit charset larger than\n" FT_ERROR(( "cff_charset_load: implicit charset larger than\n"
"predefined charset (Adobe Expert Subset)!\n" )); "predefined charset (Adobe Expert Subset)\n" ));
error = CFF_Err_Invalid_File_Format; error = CFF_Err_Invalid_File_Format;
goto Exit; goto Exit;
} }
@ -1127,7 +1158,7 @@
break; break;
default: default:
FT_ERROR(( "cff_encoding_load: invalid table format!\n" )); FT_ERROR(( "cff_encoding_load: invalid table format\n" ));
error = CFF_Err_Invalid_File_Format; error = CFF_Err_Invalid_File_Format;
goto Exit; goto Exit;
} }
@ -1222,7 +1253,7 @@
break; break;
default: default:
FT_ERROR(( "cff_encoding_load: invalid table format!\n" )); FT_ERROR(( "cff_encoding_load: invalid table format\n" ));
error = CFF_Err_Invalid_File_Format; error = CFF_Err_Invalid_File_Format;
goto Exit; goto Exit;
} }
@ -1240,7 +1271,8 @@
CFF_Index idx, CFF_Index idx,
FT_UInt font_index, FT_UInt font_index,
FT_Stream stream, FT_Stream stream,
FT_ULong base_offset ) FT_ULong base_offset,
FT_Library library )
{ {
FT_Error error; FT_Error error;
CFF_ParserRec parser; CFF_ParserRec parser;
@ -1250,7 +1282,7 @@
CFF_Private priv = &font->private_dict; CFF_Private priv = &font->private_dict;
cff_parser_init( &parser, CFF_CODE_TOPDICT, &font->font_dict ); cff_parser_init( &parser, CFF_CODE_TOPDICT, &font->font_dict, library );
/* set defaults */ /* set defaults */
FT_MEM_ZERO( top, sizeof ( *top ) ); FT_MEM_ZERO( top, sizeof ( *top ) );
@ -1301,7 +1333,7 @@
priv->expansion_factor = (FT_Fixed)( 0.06 * 0x10000L ); priv->expansion_factor = (FT_Fixed)( 0.06 * 0x10000L );
priv->blue_scale = (FT_Fixed)( 0.039625 * 0x10000L * 1000 ); priv->blue_scale = (FT_Fixed)( 0.039625 * 0x10000L * 1000 );
cff_parser_init( &parser, CFF_CODE_PRIVATE, priv ); cff_parser_init( &parser, CFF_CODE_PRIVATE, priv, library );
if ( FT_STREAM_SEEK( base_offset + font->font_dict.private_offset ) || if ( FT_STREAM_SEEK( base_offset + font->font_dict.private_offset ) ||
FT_FRAME_ENTER( font->font_dict.private_size ) ) FT_FRAME_ENTER( font->font_dict.private_size ) )
@ -1354,7 +1386,8 @@
FT_LOCAL_DEF( FT_Error ) FT_LOCAL_DEF( FT_Error )
cff_font_load( FT_Stream stream, cff_font_load( FT_Library library,
FT_Stream stream,
FT_Int face_index, FT_Int face_index,
CFF_Font font, CFF_Font font,
FT_Bool pure_cff ) FT_Bool pure_cff )
@ -1394,7 +1427,7 @@
font->header_size < 4 || font->header_size < 4 ||
font->absolute_offsize > 4 ) font->absolute_offsize > 4 )
{ {
FT_TRACE2(( "[not a CFF font header!]\n" )); FT_TRACE2(( "[not a CFF font header]\n" ));
error = CFF_Err_Unknown_File_Format; error = CFF_Err_Unknown_File_Format;
goto Exit; goto Exit;
} }
@ -1432,7 +1465,8 @@
&font->font_dict_index, &font->font_dict_index,
face_index, face_index,
stream, stream,
base_offset ); base_offset,
library );
if ( error ) if ( error )
goto Exit; goto Exit;
@ -1462,7 +1496,7 @@
if ( fd_index.count > CFF_MAX_CID_FONTS ) if ( fd_index.count > CFF_MAX_CID_FONTS )
{ {
FT_ERROR(( "cff_font_load: FD array too large in CID font\n" )); FT_TRACE0(( "cff_font_load: FD array too large in CID font\n" ));
goto Fail_CID; goto Fail_CID;
} }
@ -1480,7 +1514,7 @@
{ {
sub = font->subfonts[idx]; sub = font->subfonts[idx];
error = cff_subfont_load( sub, &fd_index, idx, error = cff_subfont_load( sub, &fd_index, idx,
stream, base_offset ); stream, base_offset, library );
if ( error ) if ( error )
goto Fail_CID; goto Fail_CID;
} }
@ -1503,7 +1537,7 @@
/* read the charstrings index now */ /* read the charstrings index now */
if ( dict->charstrings_offset == 0 ) if ( dict->charstrings_offset == 0 )
{ {
FT_ERROR(( "cff_font_load: no charstrings offset!\n" )); FT_ERROR(( "cff_font_load: no charstrings offset\n" ));
error = CFF_Err_Unknown_File_Format; error = CFF_Err_Unknown_File_Format;
goto Exit; goto Exit;
} }

View File

@ -58,7 +58,8 @@ FT_BEGIN_HEADER
FT_LOCAL( FT_Error ) FT_LOCAL( FT_Error )
cff_font_load( FT_Stream stream, cff_font_load( FT_Library library,
FT_Stream stream,
FT_Int face_index, FT_Int face_index,
CFF_Font font, CFF_Font font,
FT_Bool pure_cff ); FT_Bool pure_cff );

Some files were not shown because too many files have changed in this diff Show More