[tlbuild] build failure: texk/dvisvgm/dvisvgm-0.8.7/src/FontEngine.cpp has some type mismatches when calling freetype API

Karl Berry karl at freefriends.org
Mon May 31 20:40:03 CEST 2010


    "../../../texk/dvisvgm/dvisvgm-0.8.7/src/FontEngine.cpp", line
    115.59: 1540-0256 (S) A parameter of type "unsigned int *" cannot be
    initialized with an expression of type "int *".

    "../../../texk/dvisvgm/dvisvgm-0.8.7/src/FontEngine.cpp", line
    115.59: 1540-1205 (I) The error occurred while converting to
    parameter 2 of "FT_Get_First_Char(FT_Face, FT_UInt *)".

It seems crazy for the compiler to consider such pointers incompatible.
Anyway, the code in FontEngine.cpp is just this:

    114 UInt32 glyphIndex;
    115 UInt32 charcode = FT_Get_First_Char(_currentFace, &glyphIndex);

And UInt32 is defined in dvisvgm's src/types.h file:
typedef int_t<4, false>::T UInt32;

cf. its companion signed-integer definition:
typedef int_t<4, true>::T  Int32;

I don't know enough about C++ to know whether the compiler or the source
code is wrong.  I can't find any good information on C++'s int_t
instantation.  It's obvious that the first argument is supposed to be
the number of bytes and the second argument whether it is signed, but
evidently the AIX compiler is not doing this, for whatever reason.

FreeType simply declares it as
typedef unsigned int    FT_UInt32;
or unsigned long, depending.

Anyway, since we're not going to solve any compiler problems, I went
ahead and installed the changes (below).  Whether the svisvgm maintainer
will accept this kludge, I don't know.

Thanks,
karl

--- FontEngine.cpp	(revision 18651)
+++ FontEngine.cpp	(working copy)
@@ -59,11 +59,15 @@
  * @param[out] reverseMap the resulting map */
 static void build_reverse_map (FT_Face face, map<UInt32, UInt32> &reverseMap) {
 	UInt32 glyphIndex;
-	UInt32 charcode = FT_Get_First_Char(face, &glyphIndex);
+	/* The explicit cast is necessary with the AIX compiler,
+	   which considers the dvisvgm definition signed,
+	   and incompatible with the freetype definition.  */
+	UInt32 charcode = FT_Get_First_Char(face, (FT_UInt *) &glyphIndex);
 	while (glyphIndex) {
 //		if (reverseMap.find(glyphIndex) == reverseMap.end())
 		reverseMap[glyphIndex] = charcode;
-		charcode = FT_Get_Next_Char(face, charcode, &glyphIndex);
+		charcode = FT_Get_Next_Char(face, charcode,
+                                            (FT_UInt *) &glyphIndex);
 	}
 }
 
@@ -112,10 +116,12 @@
 
 	FT_Set_Charmap(_currentFace, unicodeMap);
 	UInt32 glyphIndex;
-	UInt32 charcode = FT_Get_First_Char(_currentFace, &glyphIndex);
+	UInt32 charcode = FT_Get_First_Char(_currentFace,
+                                            (FT_UInt *) &glyphIndex);
 	while (glyphIndex) {
 		translationMap[reverseMap[glyphIndex]] = charcode;
-		charcode = FT_Get_Next_Char(_currentFace, charcode, &glyphIndex);
+		charcode = FT_Get_Next_Char(_currentFace, charcode,
+                                            (FT_UInt *) &glyphIndex);
 	}
 	FT_Set_Charmap(_currentFace, customMap);
 }


More information about the tlbuild mailing list