Jump to content
  • Advertisement
Sign in to follow this  

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

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_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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Advertisement

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!