🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

FreeType fonts with Android-NDK : Not loading ttf file!

Started by
1 comment, last by sergamer1 6 years, 10 months ago

Hi guys,

So I've been having some trouble with loading fonts in Android (using the NDK).  I've successfully (I believe) compiled the FreeType library as a shared-object library next to some other libraries I am using plus my game/framework code.  I am using the following commands to get things initialised.


FT_Library ft;
FT_Face face;
FT_Init_FreeType(&ft);
FT_New_Face(ft, filename.c_str(), 0, &face);

This is what the FreeType tutorials (plus other various online pages) suggest using to get things going.  When I run this code on my Linux laptop, it runs fine but if I run it on Android, it fails on the fourth line loading in the font.  So I know the library is probably compiled and linked correctly or it would fail on the first or third line right?

The other issue is where to put the ttf file.  I've put it in the assets subdirectory, which is again where (almost) everyone online suggests putting it.  Some suggest putting it in assets/fonts sub-directory which I tried (and didn't work) and also res/font (which ndk-build complained about while compiling so definitely doesn't work).  I'm a little stuck now since I feel like I've exhausted all the obvious options so if someone with experience using FreeType on the NDK can tell me the magic formula for getting this to work, I'll be very grateful :-)  .  Thanks

Advertisement

ok, so I circumvented the problem by using SDL2_ttf instead (which I was thinking about in the first place).  I'm guessing the issue is locating the assets folder.  SDL probably calls the relevant Android functions to find this out but you have to do this yourself with FreeType I'm guessing (which I obviously don't know how to do :P )?  Anyway, I'll probably stick with this solution since I'm using SDL for other things anyway so makes sense to stay with the same library family.  Even though nobody answered, thanks if you thought about it a little ;-)

This topic is closed to new replies.

Advertisement