Xamarin Studio 4.0.10 (build 7), Xcode 4.6.3 (2068), Xamarin.iOS 6.4.0.2 (Business Edition)
Has anybody created bindings for FreeType? I've been trying everything I can think of for the last couple of days with no success. I'm at the point where I can build and link a FreeType static library, but calling into it fails on both the simulator and the device, but in different ways. On the simulator it finds the entry points, but crashes Xamarin when I call anything other than FT_Init_FreeType. On the device I can't get it to see any of the library's entry points, I get System.EntryPointNotFoundException no matter what I try.
Here's what I've done:
1) Downloaded FreeType (tried 2.4.10, 2.4.12 and 2.5.0) and built a combined i386/armv7 static library using the following script:
mkdir lib
rm lib/*
./configure '--without-bzip2' CFLAGS="-arch i386"
make clean
make
cp objs/.libs/libfreetype.a lib/libfreetype-i386.a
./configure --without-bzip2 --host=arm-apple-darwin --enable-static=yes --enable-shared=no CC="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc" LD="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ld" AR="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ar" CFLAGS="-arch armv7 -marm -fpascal-strings -O2 -fmessage-length=0 -fvisibility=hidden -pipe -std=c99 -Wno-trigraphs -Wreturn-type -Wunused-variable -miphoneos-version-min=5.0 -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk/usr/include/libxml2/ -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk/" LDFLAGS="-arch armv7 -miphoneos-version-min=5.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk/"
make clean
make
cp objs/.libs/libfreetype.a lib/libfreetype-armv7.a
lipo -create -output lib/libfreetype.a lib/libfreetype-i386.a lib/libfreetype-armv7.a
2) Copied the combined static library to the root of my test project and added the following line to the Additional mtouch arguments for the project's IOS Build settings:
-gcc_flags "-L${ProjectDir} -lfreetype -force_load ${ProjectDir}/libfreetype.a"
3) Added the following declarations to my test program:
private const string FreeTypeDll = "__Internal";
private const CallingConvention FreeTyeCallingConvention = CallingConvention.Cdecl;
[DllImport(FreeTypeDll, CallingConvention = FreeTyeCallingConvention)]
public static extern int FT_Init_FreeType(out IntPtr alibrary);
[DllImport(FreeTypeDll, CallingConvention = FreeTyeCallingConvention)]
public static extern void FT_Done_FreeType(IntPtr library);
[DllImport(FreeTypeDll, CallingConvention = FreeTyeCallingConvention)]
public static extern int FT_New_Face(IntPtr library, string fname, int index, out IntPtr face);
[DllImport(FreeTypeDll, CallingConvention = FreeTyeCallingConvention)]
public static extern void FT_Done_Face(IntPtr face);
4) Called into the FreeType library with this code:
IntPtr lib, face;
int result = FT_Init_FreeType(out lib);
Console.WriteLine("FT_Init_FreeType = " + result + " " + lib.ToInt32());
string fileName = NSBundle.MainBundle.PathForResource("Fonts/Vera.ttf", null);
result = FT_New_Face(lib, fileName, 0, out face);
Console.WriteLine("FT_New_Face = " + result + " " + face.ToInt32());
FT_Done_Face(face);
FT_Done_FreeType(lib);
Any help at all would be hugely appreciated!