[Date Prev][Date Next][Thread Prev][Thread Next][Thread Index]

RE: [XaraXtreme-dev] Compile error with freetype-2.2.1



In message <5056CBC646CB4047BB26120F4377DB7179A7BF@xxxxxxxxxxxxxxxxxxx 
>
          "Luke Hart" <LukeH@xxxxxxxx> wrote:

>> This is very sad because it means there is no way to write code that
>> works for both FreeType 2.1 and 2.2 - I will have to introduce nasty
>> #ifdefs to accomodate the two conflicting interfaces. Even worse, we
>> do not even know yet in which precise version the change was made. :-(
>
> The change happened between v1.46 and v1.47 of ftimage.h (see
> http://cvs.savannah.nongnu.org/viewcvs/freetype2/include/freetype/ftim
> age.h?root=freetype&r1=1.46&r2=1.47). 1.47 is the version include with
> all the release candidates of FT2.2, so basically anything after that
> point will be broken.

OK, so hopefully all these release candidates declare themselves as 
FreeType 2.2, which will trigger the fix attached below. I have tested 
it by compiling against both 2.1 and 2.2 but I will remain on 2.2 for 
future development.

Martin
Index: wxOil/ftfonts.cpp
===================================================================
--- wxOil/ftfonts.cpp	(Revision 1169)
+++ wxOil/ftfonts.cpp	(Arbeitskopie)
@@ -523,7 +523,7 @@
 		// first of all, add the font to our cache list - we do that even with fonts that
 		// we cannot use, so we can easily see when the available font set has changed
 		FTFontMan::AddFontToCache(OurEnumLogFont);
-		TRACEUSER("wuerthne", _T("%s added to font list cache"), (TCHAR*)OurFontName);
+		// TRACEUSER("wuerthne", _T("%s added to font list cache"), (TCHAR*)OurFontName);
 	}
 	else if (m_action == UpdateCache)
 	{
@@ -1013,12 +1013,25 @@
 	FT_Vector CurrentPoint;  // we need to keep track of the current point for quadratic curve conversion
 } DecompState;
 
-// callback functions for FreeType outline decomposition - we need to use return type "INT32"
+// callback functions for FreeType outline decomposition - we need to use return type "int"   // TYPENOTE: Correct
 // rather than any of our types to conform to the FreeType interface
 
+// Unfortunately, the FreeType interface was changed for version 2.2 - the FT_Vector parameters
+// are now const.
+#if FREETYPE_MAJOR >= 2
+#if FREETYPE_MINOR >= 2
+/* new interface, make parameters const */
+#define FREETYPE_CALLBACK_CONST const
+#else
+#define FREETYPE_CALLBACK_CONST
+#endif
+#else
+#error "XaraLX requires FreeType 2"
+#endif
+
 /********************************************************************************************
 
->	static INT32 AddMoveTo(FT_Vector* to, void* user)
+>	static int AddMoveTo(FREETYPE_CALLBACK_CONST FT_Vector* to, void* user)  // TYPENOTE: Correct
 
 	Author:		Martin Wuerthner <xara@xxxxxxxxxxxxxxx>
 	Created:	28/03/06
@@ -1030,7 +1043,7 @@
 
 ********************************************************************************************/
 
-static int AddMoveTo(FT_Vector* to, void* user)  // TYPENOTE: Correct - FreeType callback interface
+static int AddMoveTo(FREETYPE_CALLBACK_CONST FT_Vector* to, void* user)  // TYPENOTE: Correct - FreeType callback interface
 {
 	DecompState* state = (DecompState*)user;
 	if (!state->IsFirstMove) {
@@ -1051,7 +1064,7 @@
 
 /********************************************************************************************
 
->	static INT32 AddLineTo(FT_Vector* to, void* user)
+>	static int AddLineTo(FREETYPE_CALLBACK_CONST FT_Vector* to, void* user)   // TYPENOTE: Correct
 
 	Author:		Martin Wuerthner <xara@xxxxxxxxxxxxxxx>
 	Created:	28/03/06
@@ -1063,7 +1076,7 @@
 
 ********************************************************************************************/
 
-static INT32 AddLineTo(FT_Vector* to, void* user)
+static int AddLineTo(FREETYPE_CALLBACK_CONST FT_Vector* to, void* user)       // TYPENOTE: Correct - FreeType callback interface
 {
 	DecompState* state = (DecompState*)user;
 	POINT p;
@@ -1077,7 +1090,8 @@
 
 /********************************************************************************************
 
->	static INT32 AddConicTo(FT_Vector* control, FT_Vector* to, void* user)
+>	static int AddConicTo(FREETYPE_CALLBACK_CONST FT_Vector* control,         // TYPENOTE: Correct
+						  FREETYPE_CALLBACK_CONST FT_Vector* to, void* user)
 
 	Author:		Martin Wuerthner <xara@xxxxxxxxxxxxxxx>
 	Created:	28/03/06
@@ -1090,7 +1104,8 @@
 
 ********************************************************************************************/
 
-static INT32 AddConicTo(FT_Vector* control, FT_Vector* to, void* user)
+static int AddConicTo(FREETYPE_CALLBACK_CONST FT_Vector* control,             // TYPENOTE: Correct - FreeType callback interface
+					  FREETYPE_CALLBACK_CONST FT_Vector* to, void* user)
 {
 	DecompState* state = (DecompState*)user;
 
@@ -1129,7 +1144,9 @@
 
 /********************************************************************************************
 
->	static INT32 AddCubicTo(FT_Vector* control1, FT_Vector* control2, FT_Vector* to, void* user)
+>	static int AddCubicTo(FREETYPE_CALLBACK_CONST FT_Vector* control1,     // TYPENOTE: Correct
+						  FREETYPE_CALLBACK_CONST FT_Vector* control2,
+						  FREETYPE_CALLBACK_CONST FT_Vector* to, void* user)
 
 	Author:		Martin Wuerthner <xara@xxxxxxxxxxxxxxx>
 	Created:	28/03/06
@@ -1142,7 +1159,9 @@
 
 ********************************************************************************************/
 
-static INT32 AddCubicTo(FT_Vector *control1, FT_Vector *control2, FT_Vector* to, void* user)
+static int AddCubicTo(FREETYPE_CALLBACK_CONST FT_Vector *control1,          // TYPENOTE: Correct
+					  FREETYPE_CALLBACK_CONST FT_Vector *control2,
+					  FREETYPE_CALLBACK_CONST FT_Vector* to, void* user)
 {
 	DecompState* state = (DecompState*)user;
 	POINT p1;