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

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

## 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 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  )?  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 ;-)

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 11
• 20
• 36
• 9
• 16