diff --git a/ChangeLog b/ChangeLog index fc8f0dcb0..58647874c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,41 @@ +2003-12-23 David Turner + + * include/freetype/fttypes.h + src/autofit/afangles.c + src/autofit/aflatin.c + src/autohint/ahglyph.c + src/autohint/ahhint.c + src/base/ftcalc.c + src/base/ftgloadr.c + src/base/ftglyph.c + src/base/ftobjs.c + src/base/ftsynth.c + src/base/fttrigon.c + src/cff/cffgload.c + src/cid/cidgload.c + src/cid/cidload.c + src/pfr/pfrgload.c + src/pfr/pfrload.c + src/pfr/pfrsbit.c + src/psaux/psobjs.c + src/pshinter/pshalgo.c + src/pshinter/pshglob.c + src/pshinter/pshrec.c + src/raster/ftrend1.c + src/sfnt/ttcmap0.c + src/smooth/ftsmooth.c + src/truetype/ttdriver.c + src/truetype/ttgload.c + src/truetype/ttinterp.c + src/truetype/ttobjs.c + src/type1/t1gload.c + src/winfonts/winfnt.c: + + use of the FT_PAD_XXX and FT_PIX_XXX macros to avoid compiler + warnings with very pedantic compilers. Hints: (x) & -64 will + warn if (x) is not signed.. use (x) & ~63 instead ! + + 2003-12-22 Werner Lemberg * include/freetype/ftwinfnt.h (FT_WinFNT_ID_*): New definitions diff --git a/include/freetype/fttypes.h b/include/freetype/fttypes.h index 2782f74d5..50e078f5e 100644 --- a/include/freetype/fttypes.h +++ b/include/freetype/fttypes.h @@ -1,558 +1,558 @@ -/***************************************************************************/ -/* */ -/* fttypes.h */ -/* */ -/* FreeType simple types definitions (specification only). */ -/* */ -/* Copyright 1996-2001 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. */ -/* */ -/***************************************************************************/ - - -#ifndef __FTTYPES_H__ -#define __FTTYPES_H__ - - -#include -#include FT_CONFIG_CONFIG_H -#include FT_SYSTEM_H -#include FT_IMAGE_H - -#include - - -FT_BEGIN_HEADER - - - /*************************************************************************/ - /* */ - /*
*/ - /* basic_types */ - /* */ - /* */ - /* Basic Data Types */ - /* */ - /* <Abstract> */ - /* The basic data types defined by the library. */ - /* */ - /* <Description> */ - /* This section contains the basic data types defined by FreeType 2, */ - /* ranging from simple scalar types to bitmap descriptors. More */ - /* font-specific structures are defined in a different section. */ - /* */ - /* <Order> */ - /* FT_Byte */ - /* FT_Char */ - /* FT_Int */ - /* FT_UInt */ - /* FT_Short */ - /* FT_UShort */ - /* FT_Long */ - /* FT_ULong */ - /* FT_Bool */ - /* FT_Offset */ - /* FT_PtrDist */ - /* FT_String */ - /* FT_Error */ - /* FT_Fixed */ - /* FT_Pointer */ - /* FT_Pos */ - /* FT_Vector */ - /* FT_BBox */ - /* FT_Matrix */ - /* FT_FWord */ - /* FT_UFWord */ - /* FT_F2Dot14 */ - /* FT_UnitVector */ - /* FT_F26Dot6 */ - /* */ - /* */ - /* FT_Generic */ - /* FT_Generic_Finalizer */ - /* */ - /* FT_Bitmap */ - /* FT_Pixel_Mode */ - /* FT_Palette_Mode */ - /* FT_Glyph_Format */ - /* FT_IMAGE_TAG */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Bool */ - /* */ - /* <Description> */ - /* A typedef of unsigned char, used for simple booleans. */ - /* */ - typedef unsigned char FT_Bool; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_FWord */ - /* */ - /* <Description> */ - /* A signed 16-bit integer used to store a distance in original font */ - /* units. */ - /* */ - typedef signed short FT_FWord; /* distance in FUnits */ - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_UFWord */ - /* */ - /* <Description> */ - /* An unsigned 16-bit integer used to store a distance in original */ - /* font units. */ - /* */ - typedef unsigned short FT_UFWord; /* unsigned distance */ - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Char */ - /* */ - /* <Description> */ - /* A simple typedef for the _signed_ char type. */ - /* */ - typedef signed char FT_Char; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Byte */ - /* */ - /* <Description> */ - /* A simple typedef for the _unsigned_ char type. */ - /* */ - typedef unsigned char FT_Byte; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_String */ - /* */ - /* <Description> */ - /* A simple typedef for the char type, usually used for strings. */ - /* */ - typedef char FT_String; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Short */ - /* */ - /* <Description> */ - /* A typedef for signed short. */ - /* */ - typedef signed short FT_Short; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_UShort */ - /* */ - /* <Description> */ - /* A typedef for unsigned short. */ - /* */ - typedef unsigned short FT_UShort; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Int */ - /* */ - /* <Description> */ - /* A typedef for the int type. */ - /* */ - typedef int FT_Int; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_UInt */ - /* */ - /* <Description> */ - /* A typedef for the unsigned int type. */ - /* */ - typedef unsigned int FT_UInt; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Long */ - /* */ - /* <Description> */ - /* A typedef for signed long. */ - /* */ - typedef signed long FT_Long; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_ULong */ - /* */ - /* <Description> */ - /* A typedef for unsigned long. */ - /* */ - typedef unsigned long FT_ULong; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_F2Dot14 */ - /* */ - /* <Description> */ - /* A signed 2.14 fixed float type used for unit vectors. */ - /* */ - typedef signed short FT_F2Dot14; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_F26Dot6 */ - /* */ - /* <Description> */ - /* A signed 26.6 fixed float type used for vectorial pixel */ - /* coordinates. */ - /* */ - typedef signed long FT_F26Dot6; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Fixed */ - /* */ - /* <Description> */ - /* This type is used to store 16.16 fixed float values, like scales */ - /* or matrix coefficients. */ - /* */ - typedef signed long FT_Fixed; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Error */ - /* */ - /* <Description> */ - /* The FreeType error code type. A value of 0 is always interpreted */ - /* as a successful operation. */ - /* */ - typedef int FT_Error; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Pointer */ - /* */ - /* <Description> */ - /* A simple typedef for a typeless pointer. */ - /* */ - typedef void* FT_Pointer; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Offset */ - /* */ - /* <Description> */ - /* This is equivalent to the ANSI C `size_t' type, i.e. the largest */ - /* _unsigned_ integer type used to express a file size or position, */ - /* or a memory block size. */ - /* */ - typedef size_t FT_Offset; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_PtrDist */ - /* */ - /* <Description> */ - /* This is equivalent to the ANSI C `ptrdiff_t' type, i.e. the */ - /* largest _signed_ integer type used to express the distance */ - /* between two pointers. */ - /* */ - typedef size_t FT_PtrDist; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_UnitVector */ - /* */ - /* <Description> */ - /* A simple structure used to store a 2D vector unit vector. Uses */ - /* FT_F2Dot14 types. */ - /* */ - /* <Fields> */ - /* x :: Horizontal coordinate. */ - /* */ - /* y :: Vertical coordinate. */ - /* */ - typedef struct FT_UnitVector_ - { - FT_F2Dot14 x; - FT_F2Dot14 y; - - } FT_UnitVector; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Matrix */ - /* */ - /* <Description> */ - /* A simple structure used to store a 2x2 matrix. Coefficients are */ - /* in 16.16 fixed float format. The computation performed is: */ - /* */ - /* { */ - /* x' = x*xx + y*xy */ - /* y' = x*yx + y*yy */ - /* } */ - /* */ - /* <Fields> */ - /* xx :: Matrix coefficient. */ - /* */ - /* xy :: Matrix coefficient. */ - /* */ - /* yx :: Matrix coefficient. */ - /* */ - /* yy :: Matrix coefficient. */ - /* */ - typedef struct FT_Matrix_ - { - FT_Fixed xx, xy; - FT_Fixed yx, yy; - - } FT_Matrix; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Data */ - /* */ - /* <Description> */ - /* Read-only binary data represented as a pointer and a length. */ - /* */ - /* <Fields> */ - /* pointer :: The data. */ - /* */ - /* length :: The length of the data in bytes. */ - /* */ - typedef struct FT_Data_ - { - const FT_Byte* pointer; - FT_Int length; - - } FT_Data; - - - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_Generic_Finalizer */ - /* */ - /* <Description> */ - /* Describes a function used to destroy the `client' data of any */ - /* FreeType object. See the description of the FT_Generic type for */ - /* details of usage. */ - /* */ - /* <Input> */ - /* The address of the FreeType object which is under finalization. */ - /* Its client data is accessed through its `generic' field. */ - /* */ - typedef void (*FT_Generic_Finalizer)(void* object); - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Generic */ - /* */ - /* <Description> */ - /* Client applications often need to associate their own data to a */ - /* variety of FreeType core objects. For example, a text layout API */ - /* might want to associate a glyph cache to a given size object. */ - /* */ - /* Most FreeType object contains a `generic' field, of type */ - /* FT_Generic, which usage is left to client applications and font */ - /* servers. */ - /* */ - /* It can be used to store a pointer to client-specific data, as well */ - /* as the address of a `finalizer' function, which will be called by */ - /* FreeType when the object is destroyed (for example, the previous */ - /* client example would put the address of the glyph cache destructor */ - /* in the `finalizer' field). */ - /* */ - /* <Fields> */ - /* data :: A typeless pointer to any client-specified data. This */ - /* field is completely ignored by the FreeType library. */ - /* */ - /* finalizer :: A pointer to a `generic finalizer' function, which */ - /* will be called when the object is destroyed. If this */ - /* field is set to NULL, no code will be called. */ - /* */ - typedef struct FT_Generic_ - { - void* data; - FT_Generic_Finalizer finalizer; - - } FT_Generic; - - - /*************************************************************************/ - /* */ - /* <Macro> */ - /* FT_MAKE_TAG */ - /* */ - /* <Description> */ - /* This macro converts four letter tags which are used to label */ - /* TrueType tables into an unsigned long to be used within FreeType. */ - /* */ - /* <Note> */ - /* The produced values *must* be 32bit integers. Don't redefine this */ - /* macro. */ - /* */ -#define FT_MAKE_TAG( _x1, _x2, _x3, _x4 ) \ - ( ( (FT_ULong)_x1 << 24 ) | \ - ( (FT_ULong)_x2 << 16 ) | \ - ( (FT_ULong)_x3 << 8 ) | \ - (FT_ULong)_x4 ) - - - /*************************************************************************/ - /*************************************************************************/ - /* */ - /* L I S T M A N A G E M E N T */ - /* */ - /*************************************************************************/ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* list_processing */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_ListNode */ - /* */ - /* <Description> */ - /* Many elements and objects in FreeType are listed through a */ - /* FT_List record (see FT_ListRec). As its name suggests, a */ - /* FT_ListNode is a handle to a single list element. */ - /* */ - typedef struct FT_ListNodeRec_* FT_ListNode; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_List */ - /* */ - /* <Description> */ - /* A handle to a list record (see FT_ListRec). */ - /* */ - typedef struct FT_ListRec_* FT_List; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_ListNodeRec */ - /* */ - /* <Description> */ - /* A structure used to hold a single list element. */ - /* */ - /* <Fields> */ - /* prev :: The previous element in the list. NULL if first. */ - /* */ - /* next :: The next element in the list. NULL if last. */ - /* */ - /* data :: A typeless pointer to the listed object. */ - /* */ - typedef struct FT_ListNodeRec_ - { - FT_ListNode prev; - FT_ListNode next; - void* data; - - } FT_ListNodeRec; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_ListRec */ - /* */ - /* <Description> */ - /* A structure used to hold a simple doubly-linked list. These are */ - /* used in many parts of FreeType. */ - /* */ - /* <Fields> */ - /* head :: The head (first element) of doubly-linked list. */ - /* */ - /* tail :: The tail (last element) of doubly-linked list. */ - /* */ - typedef struct FT_ListRec_ - { - FT_ListNode head; - FT_ListNode tail; - - } FT_ListRec; - - - /* */ - -#define FT_IS_EMPTY( list ) ( (list).head == 0 ) - - /* return base error code (without module-specific prefix) */ -#define FT_ERROR_BASE( x ) ( (x) & 0xFF ) - - /* return module error code */ -#define FT_ERROR_MODULE( x ) ( (x) & 0xFF00U ) - -#define FT_BOOL( x ) ( (FT_Bool)( x ) ) - -FT_END_HEADER - -#endif /* __FTTYPES_H__ */ - - -/* END */ +/***************************************************************************/ +/* */ +/* fttypes.h */ +/* */ +/* FreeType simple types definitions (specification only). */ +/* */ +/* Copyright 1996-2001 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. */ +/* */ +/***************************************************************************/ + + +#ifndef __FTTYPES_H__ +#define __FTTYPES_H__ + + +#include <ft2build.h> +#include FT_CONFIG_CONFIG_H +#include FT_SYSTEM_H +#include FT_IMAGE_H + +#include <stddef.h> + + +FT_BEGIN_HEADER + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* basic_types */ + /* */ + /* <Title> */ + /* Basic Data Types */ + /* */ + /* <Abstract> */ + /* The basic data types defined by the library. */ + /* */ + /* <Description> */ + /* This section contains the basic data types defined by FreeType 2, */ + /* ranging from simple scalar types to bitmap descriptors. More */ + /* font-specific structures are defined in a different section. */ + /* */ + /* <Order> */ + /* FT_Byte */ + /* FT_Char */ + /* FT_Int */ + /* FT_UInt */ + /* FT_Short */ + /* FT_UShort */ + /* FT_Long */ + /* FT_ULong */ + /* FT_Bool */ + /* FT_Offset */ + /* FT_PtrDist */ + /* FT_String */ + /* FT_Error */ + /* FT_Fixed */ + /* FT_Pointer */ + /* FT_Pos */ + /* FT_Vector */ + /* FT_BBox */ + /* FT_Matrix */ + /* FT_FWord */ + /* FT_UFWord */ + /* FT_F2Dot14 */ + /* FT_UnitVector */ + /* FT_F26Dot6 */ + /* */ + /* */ + /* FT_Generic */ + /* FT_Generic_Finalizer */ + /* */ + /* FT_Bitmap */ + /* FT_Pixel_Mode */ + /* FT_Palette_Mode */ + /* FT_Glyph_Format */ + /* FT_IMAGE_TAG */ + /* */ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_Bool */ + /* */ + /* <Description> */ + /* A typedef of unsigned char, used for simple booleans. */ + /* */ + typedef unsigned char FT_Bool; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_FWord */ + /* */ + /* <Description> */ + /* A signed 16-bit integer used to store a distance in original font */ + /* units. */ + /* */ + typedef signed short FT_FWord; /* distance in FUnits */ + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_UFWord */ + /* */ + /* <Description> */ + /* An unsigned 16-bit integer used to store a distance in original */ + /* font units. */ + /* */ + typedef unsigned short FT_UFWord; /* unsigned distance */ + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_Char */ + /* */ + /* <Description> */ + /* A simple typedef for the _signed_ char type. */ + /* */ + typedef signed char FT_Char; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_Byte */ + /* */ + /* <Description> */ + /* A simple typedef for the _unsigned_ char type. */ + /* */ + typedef unsigned char FT_Byte; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_String */ + /* */ + /* <Description> */ + /* A simple typedef for the char type, usually used for strings. */ + /* */ + typedef char FT_String; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_Short */ + /* */ + /* <Description> */ + /* A typedef for signed short. */ + /* */ + typedef signed short FT_Short; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_UShort */ + /* */ + /* <Description> */ + /* A typedef for unsigned short. */ + /* */ + typedef unsigned short FT_UShort; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_Int */ + /* */ + /* <Description> */ + /* A typedef for the int type. */ + /* */ + typedef int FT_Int; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_UInt */ + /* */ + /* <Description> */ + /* A typedef for the unsigned int type. */ + /* */ + typedef unsigned int FT_UInt; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_Long */ + /* */ + /* <Description> */ + /* A typedef for signed long. */ + /* */ + typedef signed long FT_Long; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_ULong */ + /* */ + /* <Description> */ + /* A typedef for unsigned long. */ + /* */ + typedef unsigned long FT_ULong; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_F2Dot14 */ + /* */ + /* <Description> */ + /* A signed 2.14 fixed float type used for unit vectors. */ + /* */ + typedef signed short FT_F2Dot14; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_F26Dot6 */ + /* */ + /* <Description> */ + /* A signed 26.6 fixed float type used for vectorial pixel */ + /* coordinates. */ + /* */ + typedef signed long FT_F26Dot6; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_Fixed */ + /* */ + /* <Description> */ + /* This type is used to store 16.16 fixed float values, like scales */ + /* or matrix coefficients. */ + /* */ + typedef signed long FT_Fixed; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_Error */ + /* */ + /* <Description> */ + /* The FreeType error code type. A value of 0 is always interpreted */ + /* as a successful operation. */ + /* */ + typedef int FT_Error; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_Pointer */ + /* */ + /* <Description> */ + /* A simple typedef for a typeless pointer. */ + /* */ + typedef void* FT_Pointer; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_Offset */ + /* */ + /* <Description> */ + /* This is equivalent to the ANSI C `size_t' type, i.e. the largest */ + /* _unsigned_ integer type used to express a file size or position, */ + /* or a memory block size. */ + /* */ + typedef size_t FT_Offset; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_PtrDist */ + /* */ + /* <Description> */ + /* This is equivalent to the ANSI C `ptrdiff_t' type, i.e. the */ + /* largest _signed_ integer type used to express the distance */ + /* between two pointers. */ + /* */ + typedef size_t FT_PtrDist; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_UnitVector */ + /* */ + /* <Description> */ + /* A simple structure used to store a 2D vector unit vector. Uses */ + /* FT_F2Dot14 types. */ + /* */ + /* <Fields> */ + /* x :: Horizontal coordinate. */ + /* */ + /* y :: Vertical coordinate. */ + /* */ + typedef struct FT_UnitVector_ + { + FT_F2Dot14 x; + FT_F2Dot14 y; + + } FT_UnitVector; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_Matrix */ + /* */ + /* <Description> */ + /* A simple structure used to store a 2x2 matrix. Coefficients are */ + /* in 16.16 fixed float format. The computation performed is: */ + /* */ + /* { */ + /* x' = x*xx + y*xy */ + /* y' = x*yx + y*yy */ + /* } */ + /* */ + /* <Fields> */ + /* xx :: Matrix coefficient. */ + /* */ + /* xy :: Matrix coefficient. */ + /* */ + /* yx :: Matrix coefficient. */ + /* */ + /* yy :: Matrix coefficient. */ + /* */ + typedef struct FT_Matrix_ + { + FT_Fixed xx, xy; + FT_Fixed yx, yy; + + } FT_Matrix; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_Data */ + /* */ + /* <Description> */ + /* Read-only binary data represented as a pointer and a length. */ + /* */ + /* <Fields> */ + /* pointer :: The data. */ + /* */ + /* length :: The length of the data in bytes. */ + /* */ + typedef struct FT_Data_ + { + const FT_Byte* pointer; + FT_Int length; + + } FT_Data; + + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* FT_Generic_Finalizer */ + /* */ + /* <Description> */ + /* Describes a function used to destroy the `client' data of any */ + /* FreeType object. See the description of the FT_Generic type for */ + /* details of usage. */ + /* */ + /* <Input> */ + /* The address of the FreeType object which is under finalization. */ + /* Its client data is accessed through its `generic' field. */ + /* */ + typedef void (*FT_Generic_Finalizer)(void* object); + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_Generic */ + /* */ + /* <Description> */ + /* Client applications often need to associate their own data to a */ + /* variety of FreeType core objects. For example, a text layout API */ + /* might want to associate a glyph cache to a given size object. */ + /* */ + /* Most FreeType object contains a `generic' field, of type */ + /* FT_Generic, which usage is left to client applications and font */ + /* servers. */ + /* */ + /* It can be used to store a pointer to client-specific data, as well */ + /* as the address of a `finalizer' function, which will be called by */ + /* FreeType when the object is destroyed (for example, the previous */ + /* client example would put the address of the glyph cache destructor */ + /* in the `finalizer' field). */ + /* */ + /* <Fields> */ + /* data :: A typeless pointer to any client-specified data. This */ + /* field is completely ignored by the FreeType library. */ + /* */ + /* finalizer :: A pointer to a `generic finalizer' function, which */ + /* will be called when the object is destroyed. If this */ + /* field is set to NULL, no code will be called. */ + /* */ + typedef struct FT_Generic_ + { + void* data; + FT_Generic_Finalizer finalizer; + + } FT_Generic; + + + /*************************************************************************/ + /* */ + /* <Macro> */ + /* FT_MAKE_TAG */ + /* */ + /* <Description> */ + /* This macro converts four letter tags which are used to label */ + /* TrueType tables into an unsigned long to be used within FreeType. */ + /* */ + /* <Note> */ + /* The produced values *must* be 32bit integers. Don't redefine this */ + /* macro. */ + /* */ +#define FT_MAKE_TAG( _x1, _x2, _x3, _x4 ) \ + ( ( (FT_ULong)_x1 << 24 ) | \ + ( (FT_ULong)_x2 << 16 ) | \ + ( (FT_ULong)_x3 << 8 ) | \ + (FT_ULong)_x4 ) + + + /*************************************************************************/ + /*************************************************************************/ + /* */ + /* L I S T M A N A G E M E N T */ + /* */ + /*************************************************************************/ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* list_processing */ + /* */ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_ListNode */ + /* */ + /* <Description> */ + /* Many elements and objects in FreeType are listed through a */ + /* FT_List record (see FT_ListRec). As its name suggests, a */ + /* FT_ListNode is a handle to a single list element. */ + /* */ + typedef struct FT_ListNodeRec_* FT_ListNode; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_List */ + /* */ + /* <Description> */ + /* A handle to a list record (see FT_ListRec). */ + /* */ + typedef struct FT_ListRec_* FT_List; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_ListNodeRec */ + /* */ + /* <Description> */ + /* A structure used to hold a single list element. */ + /* */ + /* <Fields> */ + /* prev :: The previous element in the list. NULL if first. */ + /* */ + /* next :: The next element in the list. NULL if last. */ + /* */ + /* data :: A typeless pointer to the listed object. */ + /* */ + typedef struct FT_ListNodeRec_ + { + FT_ListNode prev; + FT_ListNode next; + void* data; + + } FT_ListNodeRec; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_ListRec */ + /* */ + /* <Description> */ + /* A structure used to hold a simple doubly-linked list. These are */ + /* used in many parts of FreeType. */ + /* */ + /* <Fields> */ + /* head :: The head (first element) of doubly-linked list. */ + /* */ + /* tail :: The tail (last element) of doubly-linked list. */ + /* */ + typedef struct FT_ListRec_ + { + FT_ListNode head; + FT_ListNode tail; + + } FT_ListRec; + + + /* */ + +#define FT_IS_EMPTY( list ) ( (list).head == 0 ) + + /* return base error code (without module-specific prefix) */ +#define FT_ERROR_BASE( x ) ( (x) & 0xFF ) + + /* return module error code */ +#define FT_ERROR_MODULE( x ) ( (x) & 0xFF00U ) + +#define FT_BOOL( x ) ( (FT_Bool)( x ) ) + +FT_END_HEADER + +#endif /* __FTTYPES_H__ */ + + +/* END */ diff --git a/include/freetype/internal/ftobjs.h b/include/freetype/internal/ftobjs.h index fa1b29f67..5c13a5872 100644 --- a/include/freetype/internal/ftobjs.h +++ b/include/freetype/internal/ftobjs.h @@ -78,6 +78,13 @@ FT_BEGIN_HEADER #define ABS( a ) ( (a) < 0 ? -(a) : (a) ) #endif +#define FT_PAD_FLOOR( x, n ) ( (x) & ~((n)-1) ) +#define FT_PAD_ROUND( x, n ) FT_PAD_FLOOR( (x)+((n)/2), n ) +#define FT_PAD_CEIL( x, n ) FT_PAD_FLOOR( (x)+((n)-1), n ) + +#define FT_PIX_FLOOR( x ) ( (x) & ~63 ) +#define FT_PIX_ROUND( x ) FT_PIX_FLOOR( (x)+32 ) +#define FT_PIX_CEIL( x ) FT_PIX_FLOOR( (x)+63 ) /*************************************************************************/ /*************************************************************************/ diff --git a/src/autofit/afangles.c b/src/autofit/afangles.c index eb0a0425e..83729e5d1 100644 --- a/src/autofit/afangles.c +++ b/src/autofit/afangles.c @@ -6,7 +6,7 @@ static const FT_Fixed af_angle_arctan_table[9] = { - 90, 64, 38, 20, 10, 5, 3, 1, 1 + 90, 64, 38, 20, 10, 5, 3, 1, 1 }; @@ -116,9 +116,9 @@ /* round theta */ if ( theta >= 0 ) - theta = ( theta + 2 ) & -4; + theta = FT_PAD_ROUND( theta, 4 ); else - theta = - (( -theta + 2 ) & -4); + theta = - FT_PAD_ROUND( -theta, 4 ); vec->x = x; vec->y = theta; @@ -152,18 +152,18 @@ AF_Angle angle2 ) { AF_Angle delta = angle2 - angle1; - + delta %= AF_ANGLE_2PI; if ( delta < 0 ) delta += AF_ANGLE_2PI; - + if ( delta > AF_ANGLE_PI ) delta -= AF_ANGLE_2PI; - - return delta; - } - + return delta; + } + + /* well, this needs to be somewhere, right :-) */ @@ -187,5 +187,5 @@ table[j - 1] = swap; } } - } + } \ No newline at end of file diff --git a/src/autofit/aflatin.c b/src/autofit/aflatin.c index 70c563aa5..de727c05f 100644 --- a/src/autofit/aflatin.c +++ b/src/autofit/aflatin.c @@ -1173,7 +1173,7 @@ } } - scaled = ( reference + 32 ) & -64; + scaled = FT_PIX_ROUND( reference ); if ( width >= reference ) { @@ -1268,7 +1268,7 @@ dist += delta; } else - dist = ( dist + 32 ) & -64; + dist = ( dist + 32 ) & ~63; } } else @@ -1282,7 +1282,7 @@ /* in the case of vertical hinting, always round */ /* the stem heights to integer pixels */ if ( dist >= 64 ) - dist = ( dist + 16 ) & -64; + dist = ( dist + 16 ) & ~63; else dist = 64; } @@ -1297,7 +1297,7 @@ if ( dist < 64 ) dist = 64; else - dist = ( dist + 32 ) & -64; + dist = ( dist + 32 ) & ~63; } else { @@ -1308,10 +1308,10 @@ dist = ( dist + 64 ) >> 1; else if ( dist < 128 ) - dist = ( dist + 22 ) & -64; + dist = ( dist + 22 ) & ~63; else /* XXX: round otherwise to prevent color fringes in LCD mode */ - dist = ( dist + 32 ) & -64; + dist = ( dist + 32 ) & ~63; } } } @@ -1472,7 +1472,7 @@ { org_center = edge->opos + ( org_len >> 1 ); - cur_pos1 = ( org_center + 32 ) & -64; + cur_pos1 = FT_PIX_ROUND( org_center ); error1 = org_center - ( cur_pos1 - u_off ); if ( error1 < 0 ) @@ -1492,7 +1492,7 @@ } else - edge->pos = ( edge->opos + 32 ) & -64; + edge->pos = FT_PIX_ROUND( edge->opos ); anchor = edge; @@ -1518,7 +1518,7 @@ FT_Pos u_off, d_off; - cur_pos1 = ( org_center + 32 ) & -64; + cur_pos1 = FT_PIX_ROUND( org_center ); if (cur_len <= 64 ) u_off = d_off = 32; @@ -1553,12 +1553,12 @@ cur_len = af_compute_stem_width( hinter, dimension, org_len, edge->flags, edge2->flags ); - cur_pos1 = ( org_pos + 32 ) & -64; + cur_pos1 = FT_PIX_ROUND( org_pos ); delta1 = ( cur_pos1 + ( cur_len >> 1 ) - org_center ); if ( delta1 < 0 ) delta1 = -delta1; - cur_pos2 = ( ( org_pos + org_len + 32 ) & -64 ) - cur_len; + cur_pos2 = FT_PIX_ROUND( org_pos + org_len ) - cur_len; delta2 = ( cur_pos2 + ( cur_len >> 1 ) - org_center ); if ( delta2 < 0 ) delta2 = -delta2; @@ -1651,12 +1651,12 @@ af_align_serif_edge( hinter, edge->serif, edge, dimension ); else if ( !anchor ) { - edge->pos = ( edge->opos + 32 ) & -64; + edge->pos = FT_PIX_ROUND( edge->opos ); anchor = edge; } else edge->pos = anchor->pos + - ( ( edge->opos-anchor->opos + 32 ) & -64 ); + FT_PIX_ROUND( edge->opos - anchor->opos ); edge->flags |= AF_EDGE_DONE; diff --git a/src/autohint/ahglyph.c b/src/autohint/ahglyph.c index 85c3b380e..ad2f46efe 100644 --- a/src/autohint/ahglyph.c +++ b/src/autohint/ahglyph.c @@ -418,7 +418,7 @@ /* first of all, reallocate the contours array if necessary */ if ( num_contours > outline->max_contours ) { - FT_Int new_contours = ( num_contours + 3 ) & -4; + FT_Int new_contours = FT_PAD_CEIL( num_contours, 4 ); if ( FT_RENEW_ARRAY( outline->contours, @@ -435,7 +435,7 @@ /* */ if ( num_points + 2 > outline->max_points ) { - FT_Int news = ( num_points + 2 + 7 ) & -8; + FT_Int news = FT_PAD_CEIL( num_points, 8 ); FT_Int max = outline->max_points; diff --git a/src/autohint/ahhint.c b/src/autohint/ahhint.c index aad5725fa..93bd3b64e 100644 --- a/src/autohint/ahhint.c +++ b/src/autohint/ahhint.c @@ -71,7 +71,7 @@ } } - scaled = ( reference + 32 ) & -64; + scaled = FT_PIX_ROUND( reference ); if ( width >= reference ) { @@ -167,7 +167,7 @@ dist += delta; } else - dist = ( dist + 32 ) & -64; + dist = ( dist + 32 ) & ~63; } } else @@ -181,7 +181,7 @@ /* in the case of vertical hinting, always round */ /* the stem heights to integer pixels */ if ( dist >= 64 ) - dist = ( dist + 16 ) & -64; + dist = ( dist + 16 ) & ~63; else dist = 64; } @@ -196,7 +196,7 @@ if ( dist < 64 ) dist = 64; else - dist = ( dist + 32 ) & -64; + dist = ( dist + 32 ) & ~63; } else { @@ -207,10 +207,10 @@ dist = ( dist + 64 ) >> 1; else if ( dist < 128 ) - dist = ( dist + 22 ) & -64; + dist = ( dist + 22 ) & ~63; else /* XXX: round otherwise to prevent color fringes in LCD mode */ - dist = ( dist + 32 ) & -64; + dist = ( dist + 32 ) & ~63; } } } @@ -284,7 +284,7 @@ dist += delta; } else - dist = ( dist + 32 ) & -64; + dist = ( dist + 32 ) & ~63; } } else @@ -298,7 +298,7 @@ /* in the case of vertical hinting, always round */ /* the stem heights to integer pixels */ if ( dist >= 64 ) - dist = ( dist + 16 ) & -64; + dist = ( dist + 16 ) & ~63; else dist = 64; } @@ -313,7 +313,7 @@ if ( dist < 64 ) dist = 64; else - dist = ( dist + 32 ) & -64; + dist = ( dist + 32 ) & ~63; } else { @@ -324,10 +324,10 @@ dist = ( dist + 64 ) >> 1; else if ( dist < 128 ) - dist = ( dist + 22 ) & -64; + dist = ( dist + 22 ) & ~63; else /* XXX: round otherwise to prevent color fringes in LCD mode */ - dist = ( dist + 32 ) & -64; + dist = ( dist + 32 ) & ~63; } } } @@ -396,7 +396,7 @@ if ( base->flags & AH_EDGE_DONE ) { if ( dist >= 64 ) - dist = ( dist + 8 ) & -64; + dist = ( dist + 8 ) & ~63; else if ( dist <= 32 && !vertical ) dist = ( dist + 33 ) >> 1; @@ -545,7 +545,7 @@ { org_center = edge->opos + ( org_len >> 1 ); - cur_pos1 = ( org_center + 32 ) & -64; + cur_pos1 = FT_PIX_ROUND( org_center ); error1 = org_center - ( cur_pos1 - u_off ); if ( error1 < 0 ) @@ -565,7 +565,7 @@ } else - edge->pos = ( edge->opos + 32 ) & -64; + edge->pos = FT_PIX_ROUND( edge->opos ); anchor = edge; @@ -575,7 +575,7 @@ #else /* !FT_CONFIG_CHESTER_STEM */ - edge->pos = ( edge->opos + 32 ) & -64; + edge->pos = FT_PIX_ROUND( edge->opos ); anchor = edge; edge->flags |= AH_EDGE_DONE; @@ -614,7 +614,7 @@ FT_Pos u_off, d_off; - cur_pos1 = ( org_center + 32 ) & -64; + cur_pos1 = FT_PIX_ROUND( org_center ); if (cur_len <= 64 ) u_off = d_off = 32; @@ -649,12 +649,12 @@ cur_len = ah_compute_stem_width( hinter, dimension, org_len, edge->flags, edge2->flags ); - cur_pos1 = ( org_pos + 32 ) & -64; + cur_pos1 = FT_PIX_ROUND( org_pos ); delta1 = ( cur_pos1 + ( cur_len >> 1 ) - org_center ); if ( delta1 < 0 ) delta1 = -delta1; - cur_pos2 = ( ( org_pos + org_len + 32 ) & -64 ) - cur_len; + cur_pos2 = FT_PIX_ROUND( org_pos + org_len ) - cur_len; delta2 = ( cur_pos2 + ( cur_len >> 1 ) - org_center ); if ( delta2 < 0 ) delta2 = -delta2; @@ -665,12 +665,12 @@ #else /* !FT_CONFIG_CHESTER_STEM */ - cur_pos1 = ( org_pos + 32 ) & -64; + cur_pos1 = FT_PIX_ROUND( org_pos ); delta1 = ( cur_pos1 + ( cur_len >> 1 ) - org_center ); if ( delta1 < 0 ) delta1 = -delta1; - cur_pos2 = ( ( org_pos + org_len + 32 ) & -64 ) - cur_len; + cur_pos2 = FT_PIX_ROUND( org_pos + org_len ) - cur_len; delta2 = ( cur_pos2 + ( cur_len >> 1 ) - org_center ); if ( delta2 < 0 ) delta2 = -delta2; @@ -764,12 +764,12 @@ ah_align_serif_edge( hinter, edge->serif, edge, dimension ); else if ( !anchor ) { - edge->pos = ( edge->opos + 32 ) & -64; + edge->pos = FT_PIX_ROUND( edge->opos ); anchor = edge; } else edge->pos = anchor->pos + - ( ( edge->opos-anchor->opos + 32 ) & -64 ); + FT_PIX_ROUND( edge->opos - anchor->opos ); edge->flags |= AH_EDGE_DONE; @@ -1299,15 +1299,16 @@ if ( delta2 < 32 ) delta2 = 0; else if ( delta2 < 64 ) - delta2 = 32 + ( ( ( delta2 - 32 ) + 16 ) & -32 ); + delta2 = 32 + ( ( ( delta2 - 32 ) + 16 ) & ~31 ); else - delta2 = ( delta2 + 32 ) & -64; + delta2 = FT_PIX_ROUND( delta2 ); if ( delta < 0 ) delta2 = -delta2; scaled->blue_refs[n] = - ( FT_MulFix( design->blue_refs[n], y_scale ) + 32 ) & -64; + FT_PIX_ROUND( FT_MulFix( design->blue_refs[n], y_scale ) ); + scaled->blue_shoots[n] = scaled->blue_refs[n] + delta2; } @@ -1551,8 +1552,8 @@ old_lsb = edge1->opos; new_lsb = edge1->pos; - hinter->pp1.x = ( ( new_lsb - old_lsb ) + 32 ) & -64; - hinter->pp2.x = ( ( edge2->pos + old_rsb ) + 32 ) & -64; + hinter->pp1.x = FT_PIX_ROUND( new_lsb - old_lsb ); + hinter->pp2.x = FT_PIX_ROUND( edge2->pos + old_rsb ); #if 0 /* try to fix certain bad advance computations */ @@ -1677,8 +1678,8 @@ x = FT_MulFix( subglyph->arg1, x_scale ); y = FT_MulFix( subglyph->arg2, y_scale ); - x = ( x + 32 ) & -64; - y = ( y + 32 ) & -64; + x = FT_PIX_ROUND(x); + y = FT_PIX_ROUND(y); } { @@ -1715,10 +1716,10 @@ FT_Outline_Translate( &gloader->base.outline, -hinter->pp1.x, 0 ); FT_Outline_Get_CBox( &gloader->base.outline, &bbox ); - bbox.xMin &= -64; - bbox.yMin &= -64; - bbox.xMax = ( bbox.xMax + 63 ) & -64; - bbox.yMax = ( bbox.yMax + 63 ) & -64; + bbox.xMin = FT_PIX_FLOOR( bbox.xMin ); + bbox.yMin = FT_PIX_FLOOR( bbox.yMin ); + bbox.xMax = FT_PIX_CEIL( bbox.xMax ); + bbox.yMax = FT_PIX_CEIL( bbox.yMax ); slot->metrics.width = bbox.xMax - bbox.xMin; slot->metrics.height = bbox.yMax - bbox.yMin; @@ -1733,7 +1734,7 @@ slot->metrics.horiAdvance = FT_MulFix( slot->metrics.horiAdvance, x_scale ); - slot->metrics.horiAdvance = ( slot->metrics.horiAdvance + 32 ) & -64; + slot->metrics.horiAdvance = FT_PIX_ROUND( slot->metrics.horiAdvance ); /* now copy outline into glyph slot */ ah_loader_rewind( slot->internal->loader ); @@ -1802,7 +1803,7 @@ if ( shoot > 0 ) { FT_Pos scaled = FT_MulFix( shoot, y_scale ); - FT_Pos fitted = ( scaled + 32 ) & -64; + FT_Pos fitted = FT_PIX_ROUND( scaled ); if ( scaled != fitted ) diff --git a/src/base/ftcalc.c b/src/base/ftcalc.c index f801cc438..4fb236627 100644 --- a/src/base/ftcalc.c +++ b/src/base/ftcalc.c @@ -74,8 +74,8 @@ FT_EXPORT_DEF( FT_Fixed ) FT_RoundFix( FT_Fixed a ) { - return ( a >= 0 ) ? ( a + 0x8000L ) & -0x10000L - : -((-a + 0x8000L ) & -0x10000L ); + return ( a >= 0 ) ? ( a + 0x8000L ) & ~0xFFFFL + : -((-a + 0x8000L ) & ~0xFFFFL ); } @@ -84,8 +84,8 @@ FT_EXPORT_DEF( FT_Fixed ) FT_CeilFix( FT_Fixed a ) { - return ( a >= 0 ) ? ( a + 0xFFFFL ) & -0x10000L - : -((-a + 0xFFFFL ) & -0x10000L ); + return ( a >= 0 ) ? ( a + 0xFFFFL ) & ~0xFFFFL + : -((-a + 0xFFFFL ) & ~0xFFFFL ); } @@ -94,8 +94,8 @@ FT_EXPORT_DEF( FT_Fixed ) FT_FloorFix( FT_Fixed a ) { - return ( a >= 0 ) ? a & -0x10000L - : -((-a) & -0x10000L ); + return ( a >= 0 ) ? a & ~0xFFFFL + : -((-a) & ~0xFFFFL ); } diff --git a/src/base/ftgloadr.c b/src/base/ftgloadr.c index 5a2eb5160..8c722abdb 100644 --- a/src/base/ftgloadr.c +++ b/src/base/ftgloadr.c @@ -205,7 +205,7 @@ if ( new_max > old_max ) { - new_max = ( new_max + 7 ) & -8; + new_max = FT_PAD_CEIL( new_max, 8 ); if ( FT_RENEW_ARRAY( base->points, old_max, new_max ) || FT_RENEW_ARRAY( base->tags, old_max, new_max ) ) @@ -225,7 +225,7 @@ n_contours; if ( new_max > old_max ) { - new_max = ( new_max + 3 ) & -4; + new_max = FT_PAD_CEIL( new_max, 4 ); if ( FT_RENEW_ARRAY( base->contours, old_max, new_max ) ) goto Exit; @@ -261,7 +261,7 @@ old_max = loader->max_subglyphs; if ( new_max > old_max ) { - new_max = ( new_max + 1 ) & -2; + new_max = FT_PAD_CEIL( new_max, 2 ); if ( FT_RENEW_ARRAY( base->subglyphs, old_max, new_max ) ) goto Exit; diff --git a/src/base/ftglyph.c b/src/base/ftglyph.c index 9c6269084..dd6591561 100644 --- a/src/base/ftglyph.c +++ b/src/base/ftglyph.c @@ -546,10 +546,10 @@ if ( bbox_mode == FT_GLYPH_BBOX_GRIDFIT || bbox_mode == FT_GLYPH_BBOX_PIXELS ) { - acbox->xMin &= -64; - acbox->yMin &= -64; - acbox->xMax = ( acbox->xMax + 63 ) & -64; - acbox->yMax = ( acbox->yMax + 63 ) & -64; + acbox->xMin = FT_PIX_FLOOR( acbox->xMin ); + acbox->yMin = FT_PIX_FLOOR( acbox->yMin ); + acbox->xMax = FT_PIX_CEIL( acbox->xMax ); + acbox->yMax = FT_PIX_CEIL( acbox->yMax ); } /* convert to integer pixels if needed */ diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c index b84a37123..7e040fe60 100644 --- a/src/base/ftobjs.c +++ b/src/base/ftobjs.c @@ -1977,17 +1977,17 @@ { /* Compute root ascender, descender, test height, and max_advance */ - metrics->ascender = ( FT_MulFix( face->ascender, - metrics->y_scale ) + 63 ) & -64; + metrics->ascender = FT_PIX_CEIL( FT_MulFix( face->ascender, + metrics->y_scale ) ); - metrics->descender = ( FT_MulFix( face->descender, - metrics->y_scale ) + 0 ) & -64; + metrics->descender = FT_PIX_FLOOR( FT_MulFix( face->descender, + metrics->y_scale ) ); - metrics->height = ( FT_MulFix( face->height, - metrics->y_scale ) + 32 ) & -64; + metrics->height = FT_PIX_ROUND( FT_MulFix( face->height, + metrics->y_scale ) ); - metrics->max_advance = ( FT_MulFix( face->max_advance_width, - metrics->x_scale ) + 32 ) & -64; + metrics->max_advance = FT_PIX_ROUND( FT_MulFix( face->max_advance_width, + metrics->x_scale ) ); } @@ -2153,8 +2153,8 @@ if ( kern_mode != FT_KERNING_UNFITTED ) { - akerning->x = ( akerning->x + 32 ) & -64; - akerning->y = ( akerning->y + 32 ) & -64; + akerning->x = FT_PIX_ROUND( akerning->x ); + akerning->y = FT_PIX_ROUND( akerning->y ); } } } @@ -2516,7 +2516,7 @@ FT_Face face; TT_CMapInfo cmap_info; - + if ( !charmap || !charmap->face ) return 0; diff --git a/src/base/ftsynth.c b/src/base/ftsynth.c index 72979faae..428fda4b3 100644 --- a/src/base/ftsynth.c +++ b/src/base/ftsynth.c @@ -279,7 +279,7 @@ first = last + 1; } - slot->metrics.horiAdvance = ( slot->metrics.horiAdvance + distance*4 ) & -64; + slot->metrics.horiAdvance = ( slot->metrics.horiAdvance + distance*4 ) & ~63; } diff --git a/src/base/fttrigon.c b/src/base/fttrigon.c index 82cd3b246..da17db122 100644 --- a/src/base/fttrigon.c +++ b/src/base/fttrigon.c @@ -271,9 +271,9 @@ /* round theta */ if ( theta >= 0 ) - theta = ( theta + 16 ) & -32; + theta = FT_PAD_ROUND( theta, 32 ); else - theta = - (( -theta + 16 ) & -32); + theta = - FT_PAD_ROUND( -theta, 32 ); vec->x = x; vec->y = theta; diff --git a/src/cff/cffgload.c b/src/cff/cffgload.c index 4b214c48d..a1c6d0a81 100644 --- a/src/cff/cffgload.c +++ b/src/cff/cffgload.c @@ -366,7 +366,7 @@ decoder->num_globals = cff->num_global_subrs; decoder->globals = cff->global_subrs; decoder->globals_bias = cff_compute_bias( decoder->num_globals ); - + decoder->hint_mode = hint_mode; } @@ -2488,11 +2488,11 @@ if ( hinting ) { - metrics->horiAdvance = ( metrics->horiAdvance + 32 ) & -64; - metrics->vertAdvance = ( metrics->vertAdvance + 32 ) & -64; + metrics->horiAdvance = FT_PIX_ROUND( metrics->horiAdvance ); + metrics->vertAdvance = FT_PIX_ROUND( metrics->vertAdvance ); - metrics->vertBearingX = ( metrics->vertBearingX + 32 ) & -64; - metrics->vertBearingY = ( metrics->vertBearingY + 32 ) & -64; + metrics->vertBearingX = FT_PIX_ROUND( metrics->vertBearingX ); + metrics->vertBearingY = FT_PIX_ROUND( metrics->vertBearingY ); } } diff --git a/src/cid/cidgload.c b/src/cid/cidgload.c index e07fb717c..f038ae5b4 100644 --- a/src/cid/cidgload.c +++ b/src/cid/cidgload.c @@ -412,11 +412,11 @@ if ( hinting ) { - metrics->horiAdvance = ( metrics->horiAdvance + 32 ) & -64; - metrics->vertAdvance = ( metrics->vertAdvance + 32 ) & -64; + metrics->horiAdvance = FT_PIX_ROUND( metrics->horiAdvance ); + metrics->vertAdvance = FT_PIX_ROUND( metrics->vertAdvance ); - metrics->vertBearingX = ( metrics->vertBearingX + 32 ) & -64; - metrics->vertBearingY = ( metrics->vertBearingY + 32 ) & -64; + metrics->vertBearingX = FT_PIX_ROUND( metrics->vertBearingX ); + metrics->vertBearingY = FT_PIX_ROUND( metrics->vertBearingY ); } } @@ -426,10 +426,10 @@ /* grid fit the bounding box if necessary */ if ( hinting ) { - cbox.xMin &= -64; - cbox.yMin &= -64; - cbox.xMax = ( cbox.xMax + 63 ) & -64; - cbox.yMax = ( cbox.yMax + 63 ) & -64; + cbox.xMin = FT_PIX_FLOOR( cbox.xMin ); + cbox.yMin = FT_PIX_FLOOR( cbox.yMin ); + cbox.xMax = FT_PIX_CEIL( cbox.xMax ); + cbox.yMax = FT_PIX_CEIL( cbox.yMax ); } metrics->width = cbox.xMax - cbox.xMin; diff --git a/src/cid/cidload.c b/src/cid/cidload.c index db302b279..9d2055936 100644 --- a/src/cid/cidload.c +++ b/src/cid/cidload.c @@ -388,7 +388,7 @@ /* reallocate offsets array if needed */ if ( num_subrs + 1 > max_offsets ) { - FT_UInt new_max = ( num_subrs + 1 + 3 ) & -4; + FT_UInt new_max = FT_PAD_CEIL( num_subrs + 1, 4 ); if ( FT_RENEW_ARRAY( offsets, max_offsets, new_max ) ) diff --git a/src/pfr/pfrgload.c b/src/pfr/pfrgload.c index fdaf25375..87ba6846e 100644 --- a/src/pfr/pfrgload.c +++ b/src/pfr/pfrgload.c @@ -276,7 +276,7 @@ /* re-allocate array when necessary */ if ( count > glyph->max_xy_control ) { - FT_UInt new_max = ( count + 7 ) & -8; + FT_UInt new_max = FT_PAD_CEIL( count, 8 ); if ( FT_RENEW_ARRAY( glyph->x_control, diff --git a/src/pfr/pfrload.c b/src/pfr/pfrload.c index f3cdb04c3..19ced45d1 100644 --- a/src/pfr/pfrload.c +++ b/src/pfr/pfrload.c @@ -365,7 +365,7 @@ /* re-allocate when needed */ if ( phy_font->num_strikes + count > phy_font->max_strikes ) { - FT_UInt new_max = ( phy_font->num_strikes + count + 3 ) & -4; + FT_UInt new_max = FT_PAD_CEIL( phy_font->num_strikes + count, 4 ); if ( FT_RENEW_ARRAY( phy_font->strikes, diff --git a/src/pfr/pfrsbit.c b/src/pfr/pfrsbit.c index dfc7eb2d4..da8fdba33 100644 --- a/src/pfr/pfrsbit.c +++ b/src/pfr/pfrsbit.c @@ -635,7 +635,7 @@ glyph->root.metrics.height = (FT_Long)ysize << 6; glyph->root.metrics.horiBearingX = xpos << 6; glyph->root.metrics.horiBearingY = ypos << 6; - glyph->root.metrics.horiAdvance = ( ( advance >> 2 ) + 32 ) & -64; + glyph->root.metrics.horiAdvance = FT_PIX_ROUND( ( advance >> 2 ) ); glyph->root.metrics.vertBearingX = - glyph->root.metrics.width >> 1; glyph->root.metrics.vertBearingY = 0; glyph->root.metrics.vertAdvance = size->root.metrics.height; diff --git a/src/psaux/psobjs.c b/src/psaux/psobjs.c index b24467588..5ce8721f1 100644 --- a/src/psaux/psobjs.c +++ b/src/psaux/psobjs.c @@ -181,7 +181,7 @@ /* increase size by 25% and round up to the nearest multiple of 1024 */ new_size += ( new_size >> 2 ) + 1; - new_size = ( new_size + 1023 ) & -1024; + new_size = FT_PAD_CEIL( new_size, 1024 ); } error = reallocate_t1_table( table, new_size ); diff --git a/src/pshinter/pshalgo.c b/src/pshinter/pshalgo.c index 3e76529ac..4b7a7dcc2 100644 --- a/src/pshinter/pshalgo.c +++ b/src/pshinter/pshalgo.c @@ -375,11 +375,11 @@ len += delta; } else - len = ( len + 32 ) & -64; + len = FT_PIX_ROUND( len ); } if ( do_snapping ) - len = ( len + 32 ) & -64; + len = FT_PIX_ROUND( len ); return len; } @@ -417,8 +417,8 @@ psh_hint_snap_stem_side_delta( FT_Fixed pos, FT_Fixed len ) { - FT_Fixed delta1 = ( ( pos + 32 ) & -64 ) - pos; - FT_Fixed delta2 = ( ( pos + len + 32 ) & -64 ) - pos - len; + FT_Fixed delta1 = FT_PIX_ROUND( pos ) - pos; + FT_Fixed delta2 = FT_PIX_ROUND( pos + len ) - pos - len; if ( ABS( delta1 ) <= ABS( delta2 ) ) @@ -534,10 +534,10 @@ * around the nearest pixel center */ #if 1 - pos = ( pos + ( len >> 1 ) ) & -64; + pos = FT_PIX_FLOOR( pos + ( len >> 1 ) ); #else /* this seems to be a bug! */ - pos = ( pos + ( ( len >> 1 ) & -64 ) ); + pos = pos + FT_PIX_FLOOR( len >> 1 ); #endif len = 64; } @@ -562,7 +562,7 @@ if ( len < 64 ) len = 64; else - len = ( len + 32 ) & -64; + len = FT_PIX_ROUND( len ); switch ( align.align ) { @@ -583,9 +583,9 @@ default: hint->cur_len = len; if ( len & 64 ) - pos = ( ( pos + ( len >> 1 ) ) & -64 ) + 32; + pos = FT_PIX_FLOOR( pos + ( len >> 1 ) ) + 32; else - pos = ( pos + ( len >> 1 ) + 32 ) & -64; + pos = FT_PIX_ROUND( pos + ( len >> 1 ) ); hint->cur_pos = pos - ( len >> 1 ); hint->cur_len = len; @@ -739,13 +739,13 @@ if ( ( len / 64 ) & 1 ) { - delta_a = ( center & -64 ) + 32 - center; - delta_b = ( ( center + 32 ) & - 64 ) - center; + delta_a = FT_PIX_FLOOR( center ) + 32 - center; + delta_b = FT_PIX_ROUND( center ) - center; } else { - delta_a = ( ( center + 32 ) & - 64 ) - center; - delta_b = ( center & -64 ) + 32 - center; + delta_a = FT_PIX_ROUND( center ) - center; + delta_b = FT_PIX_FLOOR( center ) + 32 - center; } /* We choose between B) and C) above based on the amount @@ -762,7 +762,6 @@ FT_Fixed side_delta = psh_hint_snap_stem_side_delta ( pos, len ); - if ( ABS( side_delta ) < ABS( delta_b ) ) pos += side_delta; else @@ -1940,7 +1939,7 @@ scaled = FT_MulFix( globals->blues.normal_top.zones->org_ref, y_scale ); - fitted = ( scaled + 32 ) & -64; + fitted = FT_PIX_ROUND( scaled ); if (scaled != fitted ) { y_scale = FT_MulDiv( y_scale, fitted, scaled ); diff --git a/src/pshinter/pshglob.c b/src/pshinter/pshglob.c index 3ae57283c..3971c5902 100644 --- a/src/pshinter/pshglob.c +++ b/src/pshinter/pshglob.c @@ -448,7 +448,7 @@ zone->cur_delta = FT_MulFix( zone->org_delta, scale ); /* round scaled reference position */ - zone->cur_ref = ( zone->cur_ref + 32 ) & -64; + zone->cur_ref = FT_PIX_ROUND( zone->cur_ref ); #if 0 if ( zone->cur_ref > zone->cur_top ) @@ -654,7 +654,7 @@ write->org = priv->standard_height[0]; - write++; + write++; read = priv->snap_heights; for ( count = priv->num_snap_heights; count > 0; count-- ) { diff --git a/src/pshinter/pshrec.c b/src/pshinter/pshrec.c index b0fee3d95..13e0795c5 100644 --- a/src/pshinter/pshrec.c +++ b/src/pshinter/pshrec.c @@ -68,7 +68,7 @@ if ( new_max > old_max ) { /* try to grow the table */ - new_max = ( new_max + 7 ) & -8; + new_max = FT_PAD_CEIL( new_max, 8 ); if ( !FT_RENEW_ARRAY( table->hints, old_max, new_max ) ) table->max_hints = new_max; } @@ -142,7 +142,7 @@ if ( new_max > old_max ) { - new_max = ( new_max + 7 ) & -8; + new_max = FT_PAD_CEIL( new_max, 8 ); if ( !FT_RENEW_ARRAY( mask->bytes, old_max, new_max ) ) mask->max_bits = new_max * 8; } @@ -239,7 +239,7 @@ if ( new_max > old_max ) { - new_max = ( new_max + 7 ) & -8; + new_max = FT_PAD_CEIL( new_max, 8 ); if ( !FT_RENEW_ARRAY( table->masks, old_max, new_max ) ) table->max_masks = new_max; } @@ -1012,7 +1012,7 @@ FT_ERROR(( "ps_hints_t2mask: " "called with invalid bitcount %d (instead of %d)\n", bit_count, count1 + count2 )); - + /* simply ignore the operator */ return; } @@ -1057,7 +1057,7 @@ FT_ERROR(( "ps_hints_t2counter: " "called with invalid bitcount %d (instead of %d)\n", bit_count, count1 + count2 )); - + /* simply ignore the operator */ return; } diff --git a/src/raster/ftrend1.c b/src/raster/ftrend1.c index b6c0f0282..a17ef9b61 100644 --- a/src/raster/ftrend1.c +++ b/src/raster/ftrend1.c @@ -140,10 +140,10 @@ /* compute the control box, and grid fit it */ FT_Outline_Get_CBox( outline, &cbox ); - cbox.xMin &= -64; - cbox.yMin &= -64; - cbox.xMax = ( cbox.xMax + 63 ) & -64; - cbox.yMax = ( cbox.yMax + 63 ) & -64; + cbox.xMin = FT_PIX_FLOOR( cbox.xMin ); + cbox.yMin = FT_PIX_FLOOR( cbox.yMin ); + cbox.xMax = FT_PIX_CEIL( cbox.xMax ); + cbox.yMax = FT_PIX_CEIL( cbox.yMax ); width = (FT_UInt)( ( cbox.xMax - cbox.xMin ) >> 6 ); height = (FT_UInt)( ( cbox.yMax - cbox.yMin ) >> 6 ); @@ -161,7 +161,7 @@ if ( !( mode & FT_RENDER_MODE_MONO ) ) { /* we pad to 32 bits, only for backwards compatibility with FT 1.x */ - pitch = ( width + 3 ) & -4; + pitch = FT_PAD_CEIL( width, 4 ); bitmap->pixel_mode = FT_PIXEL_MODE_GRAY; bitmap->num_grays = 256; } @@ -193,9 +193,9 @@ /* render outline into the bitmap */ error = render->raster_render( render->raster, ¶ms ); - + FT_Outline_Translate( outline, cbox.xMin, cbox.yMin ); - + if ( error ) goto Exit; diff --git a/src/sfnt/ttcmap0.c b/src/sfnt/ttcmap0.c index 35f653262..b3230167c 100644 --- a/src/sfnt/ttcmap0.c +++ b/src/sfnt/ttcmap0.c @@ -393,7 +393,7 @@ { /* a 16-bit character code */ p += char_hi * 2; /* jump to key entry */ - sub = subs + ( TT_PEEK_USHORT( p ) & -8 ); /* jump to sub-header */ + sub = subs + ( FT_PAD_FLOOR( TT_PEEK_USHORT( p ), 8 ) ); /* jump to sub-header */ /* check that the hi byte isn't a valid one-byte value */ if ( sub == subs ) @@ -481,7 +481,7 @@ pos = (FT_UInt)( char_lo - start ); p += offset + pos * 2; - charcode = ( charcode & -256 ) + char_lo; + charcode = FT_PAD_FLOOR( charcode, 256 ) + char_lo; for ( ; pos < count; pos++, charcode++ ) { @@ -501,7 +501,7 @@ /* jump to next sub-header, i.e. higher byte value */ Next_SubHeader: - charcode = ( charcode & -256 ) + 256; + charcode = FT_PAD_FLOOR( charcode, 256 ) + 256; } Exit: @@ -795,7 +795,7 @@ p = table + 6; - num_segs2 = TT_PEEK_USHORT( p ) & -2; /* be paranoid! */ + num_segs2 = FT_PAD_FLOOR( TT_PEEK_USHORT( p ), 2 ); /* be paranoid! */ #if 1 /* Some fonts have more than 170 segments in their charmaps! */ @@ -918,7 +918,7 @@ code = (FT_UInt)char_code + 1; p = table + 6; - num_segs2 = TT_PEEK_USHORT(p) & -2; /* ensure even-ness */ + num_segs2 = FT_PAD_FLOOR( TT_PEEK_USHORT(p), 2 ); /* ensure even-ness */ #if 1 diff --git a/src/smooth/ftsmooth.c b/src/smooth/ftsmooth.c index cc84acd04..40d5f504f 100644 --- a/src/smooth/ftsmooth.c +++ b/src/smooth/ftsmooth.c @@ -132,10 +132,10 @@ /* compute the control box, and grid fit it */ FT_Outline_Get_CBox( outline, &cbox ); - cbox.xMin &= -64; - cbox.yMin &= -64; - cbox.xMax = ( cbox.xMax + 63 ) & -64; - cbox.yMax = ( cbox.yMax + 63 ) & -64; + cbox.xMin = FT_PIX_FLOOR( cbox.xMin ); + cbox.yMin = FT_PIX_FLOOR( cbox.yMin ); + cbox.xMax = FT_PIX_CEIL( cbox.xMax ); + cbox.yMax = FT_PIX_CEIL( cbox.yMax ); width = (FT_UInt)( ( cbox.xMax - cbox.xMin ) >> 6 ); height = (FT_UInt)( ( cbox.yMax - cbox.yMin ) >> 6 ); @@ -154,7 +154,7 @@ if ( hmul ) { width = width * hmul; - pitch = ( width + 3 ) & -4; + pitch = FT_PAD_CEIL( width, 4 ); } if ( vmul ) diff --git a/src/truetype/ttdriver.c b/src/truetype/ttdriver.c index 1a8f2a23d..e23fc3515 100644 --- a/src/truetype/ttdriver.c +++ b/src/truetype/ttdriver.c @@ -208,8 +208,8 @@ /* we need to use rounding in the following computations. Otherwise, * the resulting hinted outlines will be very slightly distorted */ - dim_x = ( ( char_width * horz_resolution + (36+32*72) ) / 72 ) & -64; - dim_y = ( ( char_height * vert_resolution + (36+32*72) ) / 72 ) & -64; + dim_x = ( ( char_width * horz_resolution + (36+32*72) ) / 72 ) & ~63; + dim_y = ( ( char_height * vert_resolution + (36+32*72) ) / 72 ) & ~63; } else { diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c index a8b82eee8..78eb41a96 100644 --- a/src/truetype/ttgload.c +++ b/src/truetype/ttgload.c @@ -690,12 +690,12 @@ FT_Pos x = zone->org[n_points-2].x; - x = ( ( x + 32 ) & -64 ) - x; + x = FT_PIX_ROUND( x ) - x; translate_array( n_points, zone->org, x, 0 ); org_to_cur( n_points, zone ); - zone->cur[n_points - 1].x = ( zone->cur[n_points - 1].x + 32 ) & -64; + zone->cur[n_points - 1].x = FT_PIX_ROUND( zone->cur[n_points - 1].x ); #ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER @@ -1202,8 +1202,8 @@ if ( subglyph->flags & ROUND_XY_TO_GRID ) { - x = ( x + 32 ) & -64; - y = ( y + 32 ) & -64; + x = FT_PIX_ROUND( x ); + y = FT_PIX_ROUND( y ); } } } @@ -1296,8 +1296,8 @@ /* if hinting, round the phantom points */ if ( IS_HINTED( loader->load_flags ) ) { - pp1[0].x = ( ( loader->pp1.x + 32 ) & -64 ); - pp1[1].x = ( ( loader->pp2.x + 32 ) & -64 ); + pp1[0].x = FT_PIX_ROUND( loader->pp1.x ); + pp1[1].x = FT_PIX_ROUND( loader->pp2.x ); } { @@ -1390,10 +1390,10 @@ if ( IS_HINTED( loader->load_flags ) ) { /* grid-fit the bounding box */ - bbox.xMin &= -64; - bbox.yMin &= -64; - bbox.xMax = ( bbox.xMax + 63 ) & -64; - bbox.yMax = ( bbox.yMax + 63 ) & -64; + bbox.xMin = FT_PIX_FLOOR( bbox.xMin ); + bbox.yMin = FT_PIX_FLOOR( bbox.yMin ); + bbox.xMax = FT_PIX_CEIL( bbox.xMax ); + bbox.yMax = FT_PIX_CEIL( bbox.yMax ); } } else @@ -1425,7 +1425,7 @@ /* don't forget to hint the advance when we need to */ if ( IS_HINTED( loader->load_flags ) ) - glyph->metrics.horiAdvance = ( glyph->metrics.horiAdvance + 32 ) & -64; + glyph->metrics.horiAdvance = FT_PIX_ROUND( glyph->metrics.horiAdvance ); /* Now take care of vertical metrics. In the case where there is */ /* no vertical information within the font (relatively common), make */ @@ -1538,9 +1538,9 @@ /* grid-fit them if necessary */ if ( IS_HINTED( loader->load_flags ) ) { - left &= -64; - top = ( top + 63 ) & -64; - advance = ( advance + 32 ) & -64; + left = FT_PIX_FLOOR( left ); + top = FT_PIX_CEIL( top ); + advance = FT_PIX_ROUND( advance ); } glyph->metrics.vertBearingX = left; diff --git a/src/truetype/ttinterp.c b/src/truetype/ttinterp.c index e895bcc25..732997323 100644 --- a/src/truetype/ttinterp.c +++ b/src/truetype/ttinterp.c @@ -1781,7 +1781,7 @@ } else { - val = -( ( compensation - distance + 32 ) & -64 ); + val = -FT_PIX_ROUND( compensation - distance ); if ( val > 0 ) val = 0; } @@ -1817,13 +1817,13 @@ if ( distance >= 0 ) { - val = ( ( distance + compensation ) & -64 ) + 32; + val = FT_PIX_FLOOR( distance + compensation ) + 32; if ( distance && val < 0 ) val = 0; } else { - val = -( ( (compensation - distance) & -64 ) + 32 ); + val = -( FT_PIX_FLOOR( compensation - distance ) + 32 ); if ( val > 0 ) val = 0; } @@ -1911,7 +1911,7 @@ } else { - val = -( ( compensation - distance + 63 ) & -64 ); + val = - FT_PIX_CEIL( compensation - distance ); if ( val > 0 ) val = 0; } @@ -1955,7 +1955,7 @@ } else { - val = -( ( compensation - distance + 16 ) & -32 ); + val = -FT_PAD_ROUND( compensation - distance, 32 ); if ( val > 0 ) val = 0; } @@ -2994,11 +2994,11 @@ #define DO_FLOOR \ - args[0] &= -64; + args[0] = FT_PIX_FLOOR( args[0] ); #define DO_CEILING \ - args[0] = ( args[0] + 63 ) & -64; + args[0] = FT_PIX_CEIL( args[0] ); #define DO_RS \ @@ -5288,7 +5288,7 @@ { *x = 0; *y = d; - } + } } else #endif diff --git a/src/truetype/ttobjs.c b/src/truetype/ttobjs.c index 30da6d3b3..cd5f6a7b8 100644 --- a/src/truetype/ttobjs.c +++ b/src/truetype/ttobjs.c @@ -12,7 +12,7 @@ /* 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. */ -/* */ +/* s */ /***************************************************************************/ @@ -590,14 +590,14 @@ } /* Compute root ascender, descender, text height, and max_advance */ - metrics->ascender = ( FT_MulFix( face->root.ascender, - metrics->y_scale ) + 32 ) & -64; - metrics->descender = ( FT_MulFix( face->root.descender, - metrics->y_scale ) + 32 ) & -64; - metrics->height = ( FT_MulFix( face->root.height, - metrics->y_scale ) + 32 ) & -64; - metrics->max_advance = ( FT_MulFix( face->root.max_advance_width, - metrics->x_scale ) + 32 ) & -64; + metrics->ascender = FT_PIX_ROUND( FT_MulFix( face->root.ascender, + metrics->y_scale ) ); + metrics->descender = FT_PIX_ROUND( FT_MulFix( face->root.descender, + metrics->y_scale ) ); + metrics->height = FT_PIX_ROUND( FT_MulFix( face->root.height, + metrics->y_scale ) ); + metrics->max_advance = FT_PIX_ROUND( FT_MulFix( face->root.max_advance_width, + metrics->x_scale ) ); #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS @@ -748,7 +748,8 @@ sbit_metrics->descender = strike->hori.descender << 6; /* XXX: Is this correct? */ - sbit_metrics->height = sbit_metrics->ascender - sbit_metrics->descender; + sbit_metrics->height = sbit_metrics->ascender - + sbit_metrics->descender; /* XXX: Is this correct? */ sbit_metrics->max_advance = ( strike->hori.min_origin_SB + diff --git a/src/type1/t1gload.c b/src/type1/t1gload.c index 2d8644fe8..c8d1db79f 100644 --- a/src/type1/t1gload.c +++ b/src/type1/t1gload.c @@ -121,7 +121,7 @@ FT_UInt glyph_index ) { FT_Data glyph_data; - FT_Error error = T1_Parse_Glyph_And_Get_Char_String( + FT_Error error = T1_Parse_Glyph_And_Get_Char_String( decoder, glyph_index, &glyph_data ); @@ -187,7 +187,7 @@ error = T1_Parse_Glyph( &decoder, glyph_index ); if ( glyph_index == 0 || decoder.builder.advance.x > *max_advance ) *max_advance = decoder.builder.advance.x; - + /* ignore the error if one occurred - skip to next glyph */ } @@ -374,11 +374,11 @@ if ( hinting ) { - metrics->horiAdvance = ( metrics->horiAdvance + 32 ) & -64; - metrics->vertAdvance = ( metrics->vertAdvance + 32 ) & -64; + metrics->horiAdvance = FT_PIX_ROUND( metrics->horiAdvance ); + metrics->vertAdvance = FT_PIX_ROUND( metrics->vertAdvance ); - metrics->vertBearingX = ( metrics->vertBearingX + 32 ) & -64; - metrics->vertBearingY = ( metrics->vertBearingY + 32 ) & -64; + metrics->vertBearingX = FT_PIX_ROUND( metrics->vertBearingX ); + metrics->vertBearingY = FT_PIX_ROUND( metrics->vertBearingY ); } } @@ -388,10 +388,10 @@ /* grid fit the bounding box if necessary */ if ( hinting ) { - cbox.xMin &= -64; - cbox.yMin &= -64; - cbox.xMax = ( cbox.xMax+63 ) & -64; - cbox.yMax = ( cbox.yMax+63 ) & -64; + cbox.xMin = FT_PIX_FLOOR( cbox.xMin ); + cbox.yMin = FT_PIX_FLOOR( cbox.yMin ); + cbox.xMax = FT_PIX_CEIL( cbox.xMax ); + cbox.yMax = FT_PIX_CEIL( cbox.yMax ); } metrics->width = cbox.xMax - cbox.xMin;