MonoGame / MonoGame.Dependencies

The MonoGame binary dependencies submodule.
38 stars 51 forks source link

Give windows its own copy of SharpFont #109

Closed dellis1972 closed 7 years ago

dellis1972 commented 7 years ago

Looking at the SharpFont docs there is a problem with the way it interfaces with free type.

The biggest currently known issue is the Windows 64-bit incompatibility. This is a three part issue:

Windows uses the LLP64 data model while most other operating systems (including Linux and OSX) use the LP64 data model. This means that on Windows, only long longs and pointers are 64 bits long and everything else remains 32 bits long. On LP64 systems, longs are also 64 bits long. This creates a discrepancy between the length of the long type on different operating systems. FreeType makes heavy use of the long type, specifically their FT_Long, FT_ULong, FT_Fixed, FT_Pos, and FT_F26Dot6 typedefs. This makes the size of FreeType structs different on Windows 64-bit systems and other 64-bit systems. The C# long type is always 64 bits long, which doesn't always match the length of the native long type. For all LP64 systems, the IntPtr type works because it's length matches the length of a pointer on that system. For LLP64 systems, this doesn't work because long is 32 bits long while a pointer is 64 bits long. The simplest solution is to compile your project as x86 because all systems will default on the 32 bit FreeType binary. However, this can be restrictive to some applications. The best solution is to compile a version of FreeType with 64-bit longs, which I will look into and test in the near future.

After a ton of testing I found that we cannot use the same assembly for Windows as we do for Mac\Linux in a 64 bit environment. Because of the above issues. So we end up with crashes in the Pipeline tool on Mac because mono is now defaulting to a 64bit environment. We used to get away with it because we ran in 32bit mode. So we need to let Mac and Linux have their own assembly which will work in both 32 and 64 bit, and windows can have its own 64bit only version.

KonajuGames commented 7 years ago

Makes sense. It's crap that we have to deal with this, but deal with it we shall.

vpenades commented 7 years ago

that's the kind of stuff that made me move away from C/C++

It's still in Alpha, but at some point it might be interesting to take a look at ImageSharp library which is an image processing library that includes font rendering, 100% c#