FreeType library can't be loaded


#1

Hey, I tried to put a custom font in my project but I got an error that says it couldn’t load the FreeType library even if I placed it in the project folder.


#2

You need to place the FreeType DLL file in the same directory as EXE file. (This is typically the same directory as your root project folder, but I mention this for completeness.)

And you need to make sure to use the correct architecture. Under https://github.com/castle-engine/castle-engine/tree/master/tools/build-tool/data/external_libraries , there’s a version for 32-bit Windows, and for 64-bit Windows. You need to use the version matching your EXE architecture. If you use FPC that creates 32-bit executables, you need to use FreeType DLL for 32-bit even if you are using 64-bit Windows. If unsure, just try one, delete, and then try the other :slight_smile:


#3

I tried both but still not working.


#4

It definitely works for me, in many applications with CGE tested on Windows :slight_smile: Please double-check whether you placed correct FreeType DLL in the correct place.

If you still have errors, you can send the zip file of your application (with EXE, DLL, data) here. (e.g. upload it somewhere and post a link)


#5

Just a small addition to @michalis post: As far as I remember, FreeType DLL also requires ZLIB dll. Try using them both (or all of the DLLs in that download link - it won’t hurt :))


#6

FreeType DLL also requires ZLIB dll.

That’s true, good point, thank you!

Our build tool implements this logic too – when packaging a game that has TTF, add FreeType, and add Zlib because FreeType depends on Zlib. ( https://github.com/castle-engine/castle-engine/blob/master/tools/build-tool/code/toolproject.pas#L732 )


#7

Yes, that was the problem. Thanks.