> > I'm curious why FT_F26Dot6 is a signed long and not a FT_Int32? I
> > would have expected it to be a 32 bit fixed point value.
>
> The library is quite old; at the time of its inception, `long' was
> 32bit on most platforms, and C types like `int32_t' didn't exist yet
> (or were so new that just a very small set of compilers supported it
> then).
Got it, historical.
>
> On the other hand, using a 64bit entity has the advantage of tagging
> an unsigned 32bit value as `not set', for example, by assigning
> value -1 to it.
Interesting, but on a 32bit platform, with long == 32 bits, that wouldn't work.
After getting this email I tried changing FT_F2Dot14 to FT_Int16. And FT_F26Dot6
and FT_Fixed to FT_Int32. I "fixed" of all of the compiler warnings
I'd caused and
got it compile, but my test program failed with memory corruption issues when
loading a font.
Attached is git diff of the change on top of VER-2-9-1 if you care to
look. I suspect
the problem is associated with one or more of the changes from
FT_Long* to FT_Fixed*
in the lower level code.
I did find a possible latent bug. The routine af_wraper_compute as
defined in afwrap.c
has the a_delta parameter defined as a FT_Pos:
FT_LOCAL_DEF( void )
af_warper_compute( AF_Warper warper,
AF_GlyphHints hints,
AF_Dimension dim,
FT_Fixed *a_scale,
FT_Pos *a_delta )
But in afwrap.h a_delta is a FT_Fixed:
FT_LOCAL( void )
af_warper_compute( AF_Warper warper,
AF_GlyphHints hints,
AF_Dimension dim,
FT_Fixed *a_scale,
FT_Fixed *a_delta );
So at line 298 in update-types.patch I changed afwrap.h so a_delta is a FT_Pos:
diff --git a/src/autofit/afwarp.h b/src/autofit/afwarp.h
index 520b1be90..21defce8f 100644
--- a/src/autofit/afwarp.h
+++ b/src/autofit/afwarp.h
@@ -52,7 +52,7 @@ FT_BEGIN_HEADER
AF_GlyphHints hints,
AF_Dimension dim,
FT_Fixed *a_scale,
- FT_Fixed *a_delta );
+ FT_Pos *a_delta );
Any feed back welcome.
-- Wink
diff --git a/include/freetype/config/ftconfig.h b/include/freetype/config/ftconfig.h
index eedebf408..82cde7016 100644
--- a/include/freetype/config/ftconfig.h
+++ b/include/freetype/config/ftconfig.h
@@ -42,6 +42,7 @@
#include FT_CONFIG_OPTIONS_H
#include FT_CONFIG_STANDARD_LIBRARY_H
+#include <stdint.h>
FT_BEGIN_HEADER
@@ -167,7 +168,7 @@ FT_BEGIN_HEADER
/* <Description> */
/* A typedef for a 16bit signed integer type. */
/* */
- typedef signed short FT_Int16;
+ typedef int16_t FT_Int16;
/*************************************************************************/
@@ -178,13 +179,8 @@ FT_BEGIN_HEADER
/* <Description> */
/* A typedef for a 16bit unsigned integer type. */
/* */
- typedef unsigned short FT_UInt16;
+ typedef uint16_t FT_UInt16;
- /* */
-
-
- /* this #if 0 ... #endif clause is for documentation purposes */
-#if 0
/*************************************************************************/
/* */
@@ -195,7 +191,7 @@ FT_BEGIN_HEADER
/* A typedef for a 32bit signed integer type. The size depends on */
/* the configuration. */
/* */
- typedef signed XXX FT_Int32;
+ typedef int32_t FT_Int32;
/*************************************************************************/
@@ -206,7 +202,7 @@ FT_BEGIN_HEADER
/* A typedef for a 32bit unsigned integer type. The size depends on */
/* the configuration. */
/* */
- typedef unsigned XXX FT_UInt32;
+ typedef uint32_t FT_UInt32;
/*************************************************************************/
@@ -218,7 +214,7 @@ FT_BEGIN_HEADER
/* the configuration. Only defined if there is real 64bit support; */
/* otherwise, it gets emulated with a structure (if necessary). */
/* */
- typedef signed XXX FT_Int64;
+ typedef int64_t FT_Int64;
/*************************************************************************/
@@ -230,26 +226,7 @@ FT_BEGIN_HEADER
/* the configuration. Only defined if there is real 64bit support; */
/* otherwise, it gets emulated with a structure (if necessary). */
/* */
- typedef unsigned XXX FT_UInt64;
-
- /* */
-
-#endif
-
-#if FT_SIZEOF_INT == ( 32 / FT_CHAR_BIT )
-
- typedef signed int FT_Int32;
- typedef unsigned int FT_UInt32;
-
-#elif FT_SIZEOF_LONG == ( 32 / FT_CHAR_BIT )
-
- typedef signed long FT_Int32;
- typedef unsigned long FT_UInt32;
-
-#else
-#error "no 32bit type found -- please check your configuration files"
-#endif
-
+ typedef uint64_t FT_UInt64;
/* look up an integer type that is at least 32 bits */
#if FT_SIZEOF_INT >= ( 32 / FT_CHAR_BIT )
@@ -265,74 +242,6 @@ FT_BEGIN_HEADER
#endif
- /* determine whether we have a 64-bit int type for platforms without */
- /* Autoconf */
-#if FT_SIZEOF_LONG == ( 64 / FT_CHAR_BIT )
-
- /* FT_LONG64 must be defined if a 64-bit type is available */
-#define FT_LONG64
-#define FT_INT64 long
-#define FT_UINT64 unsigned long
-
- /*************************************************************************/
- /* */
- /* A 64-bit data type may create compilation problems if you compile */
- /* in strict ANSI mode. To avoid them, we disable other 64-bit data */
- /* types if __STDC__ is defined. You can however ignore this rule */
- /* by defining the FT_CONFIG_OPTION_FORCE_INT64 configuration macro. */
- /* */
-#elif !defined( __STDC__ ) || defined( FT_CONFIG_OPTION_FORCE_INT64 )
-
-#if defined( __STDC_VERSION__ ) && __STDC_VERSION__ >= 199901L
-
-#define FT_LONG64
-#define FT_INT64 long long int
-#define FT_UINT64 unsigned long long int
-
-#elif defined( _MSC_VER ) && _MSC_VER >= 900 /* Visual C++ (and Intel C++) */
-
- /* this compiler provides the __int64 type */
-#define FT_LONG64
-#define FT_INT64 __int64
-#define FT_UINT64 unsigned __int64
-
-#elif defined( __BORLANDC__ ) /* Borland C++ */
-
- /* XXXX: We should probably check the value of __BORLANDC__ in order */
- /* to test the compiler version. */
-
- /* this compiler provides the __int64 type */
-#define FT_LONG64
-#define FT_INT64 __int64
-#define FT_UINT64 unsigned __int64
-
-#elif defined( __WATCOMC__ ) /* Watcom C++ */
-
- /* Watcom doesn't provide 64-bit data types */
-
-#elif defined( __MWERKS__ ) /* Metrowerks CodeWarrior */
-
-#define FT_LONG64
-#define FT_INT64 long long int
-#define FT_UINT64 unsigned long long int
-
-#elif defined( __GNUC__ )
-
- /* GCC provides the `long long' type */
-#define FT_LONG64
-#define FT_INT64 long long int
-#define FT_UINT64 unsigned long long int
-
-#endif /* __STDC_VERSION__ >= 199901L */
-
-#endif /* FT_SIZEOF_LONG == (64 / FT_CHAR_BIT) */
-
-#ifdef FT_LONG64
- typedef FT_INT64 FT_Int64;
- typedef FT_UINT64 FT_UInt64;
-#endif
-
-
#ifdef _WIN64
/* only 64bit Windows uses the LLP64 data model, i.e., */
/* 32bit integers, 64bit pointers */
diff --git a/include/freetype/ftmm.h b/include/freetype/ftmm.h
index 9948102c1..32d42593c 100644
--- a/include/freetype/ftmm.h
+++ b/include/freetype/ftmm.h
@@ -354,7 +354,7 @@ FT_BEGIN_HEADER
FT_EXPORT( FT_Error )
FT_Set_MM_Design_Coordinates( FT_Face face,
FT_UInt num_coords,
- FT_Long* coords );
+ FT_Fixed* coords );
/*************************************************************************/
diff --git a/include/freetype/fttypes.h b/include/freetype/fttypes.h
index f638c2e54..c5176e97e 100644
--- a/include/freetype/fttypes.h
+++ b/include/freetype/fttypes.h
@@ -27,7 +27,6 @@
#include <stddef.h>
-
FT_BEGIN_HEADER
@@ -261,7 +260,7 @@ FT_BEGIN_HEADER
/* <Description> */
/* A signed 2.14 fixed-point type used for unit vectors. */
/* */
- typedef signed short FT_F2Dot14;
+ typedef FT_Int16 FT_F2Dot14;
/*************************************************************************/
@@ -273,7 +272,7 @@ FT_BEGIN_HEADER
/* A signed 26.6 fixed-point type used for vectorial pixel */
/* coordinates. */
/* */
- typedef signed long FT_F26Dot6;
+ typedef FT_Int32 FT_F26Dot6;
/*************************************************************************/
@@ -285,7 +284,7 @@ FT_BEGIN_HEADER
/* This type is used to store 16.16 fixed-point values, like scaling */
/* values or matrix coefficients. */
/* */
- typedef signed long FT_Fixed;
+ typedef FT_Int32 FT_Fixed;
/*************************************************************************/
diff --git a/include/freetype/internal/services/svmm.h b/include/freetype/internal/services/svmm.h
index bcbb38e2c..6bcd026b2 100644
--- a/include/freetype/internal/services/svmm.h
+++ b/include/freetype/internal/services/svmm.h
@@ -46,7 +46,7 @@ FT_BEGIN_HEADER
typedef FT_Error
(*FT_Set_MM_Design_Func)( FT_Face face,
FT_UInt num_coords,
- FT_Long* coords );
+ FT_Fixed* coords );
/* use return value -1 to indicate that the new coordinates */
/* are equal to the current ones; no changes are thus needed */
@@ -60,7 +60,7 @@ FT_BEGIN_HEADER
typedef FT_Error
(*FT_Set_MM_Blend_Func)( FT_Face face,
FT_UInt num_coords,
- FT_Long* coords );
+ FT_Fixed* coords );
typedef FT_Error
(*FT_Get_Var_Design_Func)( FT_Face face,
@@ -74,7 +74,7 @@ FT_BEGIN_HEADER
typedef FT_Error
(*FT_Get_MM_Blend_Func)( FT_Face face,
FT_UInt num_coords,
- FT_Long* coords );
+ FT_Fixed* coords );
typedef FT_Error
(*FT_Get_Var_Blend_Func)( FT_Face face,
diff --git a/include/freetype/t1tables.h b/include/freetype/t1tables.h
index 3503c2616..862ec382e 100644
--- a/include/freetype/t1tables.h
+++ b/include/freetype/t1tables.h
@@ -286,7 +286,7 @@ FT_BEGIN_HEADER
typedef struct PS_DesignMap_
{
FT_Byte num_points;
- FT_Long* design_points;
+ FT_Fixed* design_points;
FT_Fixed* blend_points;
} PS_DesignMapRec, *PS_DesignMap;
diff --git a/src/autofit/afshaper.c b/src/autofit/afshaper.c
index f30828173..28f0695d1 100644
--- a/src/autofit/afshaper.c
+++ b/src/autofit/afshaper.c
@@ -544,7 +544,7 @@
af_shaper_get_elem( AF_StyleMetrics metrics,
void* buf_,
unsigned int idx,
- FT_Long* advance,
+ FT_Fixed* advance,
FT_Long* y_offset )
{
hb_buffer_t* buf = (hb_buffer_t*)buf_;
@@ -653,7 +653,7 @@
af_shaper_get_elem( AF_StyleMetrics metrics,
void* buf_,
unsigned int idx,
- FT_Long* advance,
+ FT_Fixed* advance,
FT_Long* y_offset )
{
FT_Face face = metrics->globals->face;
diff --git a/src/autofit/afshaper.h b/src/autofit/afshaper.h
index 7efd9f6a4..dec70be10 100644
--- a/src/autofit/afshaper.h
+++ b/src/autofit/afshaper.h
@@ -59,7 +59,7 @@ FT_BEGIN_HEADER
af_shaper_get_elem( AF_StyleMetrics metrics,
void* buf_,
unsigned int idx,
- FT_Long* x_advance,
+ FT_Fixed* x_advance,
FT_Long* y_offset );
/* */
diff --git a/src/autofit/afwarp.h b/src/autofit/afwarp.h
index 520b1be90..21defce8f 100644
--- a/src/autofit/afwarp.h
+++ b/src/autofit/afwarp.h
@@ -52,7 +52,7 @@ FT_BEGIN_HEADER
AF_GlyphHints hints,
AF_Dimension dim,
FT_Fixed *a_scale,
- FT_Fixed *a_delta );
+ FT_Pos *a_delta );
FT_END_HEADER
diff --git a/src/base/ftmm.c b/src/base/ftmm.c
index 800441bca..ab95cce3d 100644
--- a/src/base/ftmm.c
+++ b/src/base/ftmm.c
@@ -169,7 +169,7 @@
FT_EXPORT_DEF( FT_Error )
FT_Set_MM_Design_Coordinates( FT_Face face,
FT_UInt num_coords,
- FT_Long* coords )
+ FT_Fixed* coords )
{
FT_Error error;
FT_Service_MultiMasters service;
diff --git a/src/type1/t1load.c b/src/type1/t1load.c
index 9dfa637a6..195d920ca 100644
--- a/src/type1/t1load.c
+++ b/src/type1/t1load.c
@@ -500,7 +500,7 @@
FT_Long design;
FT_Fixed the_blend;
PS_DesignMap map = blend->design_map + n;
- FT_Long* designs = map->design_points;
+ FT_Fixed* designs = map->design_points;
FT_Fixed* blends = map->blend_points;
FT_Int before = -1, after = -1;
_______________________________________________
Freetype mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/freetype