TCastleFont not working

Hi there,

I want to use the font oldengl.ttf and in the editor it looks ok, but when the program runs the standard font is loaded on TCastelButton and TCastleLabel.

editor:

grafik

running program:

grafik

message:

I can’t figure out what’s wrong.
Who can help?

Thanks
Didi

You need a freetype.dll file in your project root folder (and most likely zlib1.dll too). You can copy those from castle-engine\tools\build-tool\data\external_libraries\x86_64-win64

If you’re using Castle Editor, you can also do that automatically by selecting:
2023-03-31 11_53_11-Greenshot
It will properly compile your project and copy all the necessary DLLs into your project folder.

Thank you very much for the help.
You are right, the DLL was missing.
I use always the CGE editor for compiling as in your image, but freetype.dll was missing. All the other DLLs are in the project folder. Maybe it’s because I’m using an old example.

I’m happy that the issue is solved!

But, let’s investigate further, in case there’s some bug on CGE side. If our CGE build tool for some reason did not copy the freetype DLL into your project when doing “Compile”, then it’s a bug. If a project contains *.ttf file, then when doing “Compile” / “Compile And Run” from CGE editor, the freetype DLL should be automatically placed in the project.

If this doesn’t happen in this case, can you post the project or a small version of it? You can test it by cleaning the project (you can even just manually remove *.dll from the project, press “Compile”, and see which DLL appeared).

I removed now all the DLLs in the project folder. After compiling, all DLLs are there but not the freetype.dll.

Then I tried to compile your example “fonts\text_tests” and the freetype.dll is in the folder and the program looks ok.
I think the problem is the old example I use. I try to make the same with the new “third_person_camera”.

I will let you know.

1 Like

OK, I have the same “problem” with the example project \castle_game_engine\examples\third_person_navigation.

first try:

  • I added the font (oldengl.ttf)
  • font is ok in editor
  • compiling
  • standard font in running program and NO freetype.dll in project folder

second try:

  • I added the fonts from examples\fonts\text_tests
  • font is ok in editor
  • compiling
  • font in running program is ok and freetype.dll is in the folder

It works only for special fonts?

Fixed!

Looking at your initial screenshot, your font file had extension all uppercase (OLDENGL.TTF).

This got me thinking… Yeah, by accident, we have been copying freetype DLL into the project only when we found *.ttf file with lowecase letters in the extension… This was of course a bug, as on Windows filenames are case-insensitive.

Moreover, in this case, we should be case-insensitive on all platforms (to make sure we behave the same on Unix, even if you use uppercase .TTF extension).

All done. The fix is committed to GitHub, after a few (6-8) hours from this post the engine downloads on Download | Castle Game Engine should contain this fix.

1 Like