Jump to content
  • Advertisement
Sign in to follow this  
sergamer1

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

This topic is 403 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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 ;-)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!