Android and Freetype
Todd Cope

I am having a problem with the TTF add-on on the Android port. Any time I try to load a TTF font I get this error:

Reading data/fonts/my_font.ttf failed. Freetype error code 85

I looked up the error code to see if I could figure out what went wrong. It is defined as Invalid_Stream_Operation but I have no idea what that means. Google doesn't return any useful discussion of this error. Has anyone else successfully used the TTF add-on on Android?

Trent Gamblin

I have. It works with git head for me. Are you loading it from the filesystem or from the apk? Any more details?

Todd Cope

I am loading from APK. I just downloaded the latest stable Freetype. Image files load just fine.

How did you build Freetype. Here is what I used:

./configure --host=arm-linux-androideabi --prefix=$TC --without-zlib \
   --enable-shared=no CFLAGS="-std=gnu99 -fPIC -mthumb -Wno-psabi \
   -march=armv7-a -mfloat-abi=softfp"
make install

I copied this from some random site on the Internet so it may be wrong.


Did you disable compression on the .apk? There's still a (somewhat serious) bug in Allegro's file routines which makes it not work on files inside a compressed .apk.

Trent Gamblin

I'd call it an Android bug myself. :P

But that's correct, apks must be uncompressed for the time being. There's one way around that and that's to use physfs directly on the APK (it's just a zip file). That's what I do in my latest game, and I find it's much better.

Thomas Fjellstrom

At some point I want to try out the file stream interface to the APK's contents. One would hope that they decompress on the fly via that interface.

Todd Cope
Elias said:

Did you disable compression on the .apk?

No. I just followed the instructions in README_android.txt. Didn't see anything in there about the compression. How exactly would I go about disabling it? I wouldn't mind having an uncompressed APK since most of my data already use compressed file types.

Trent Gamblin

You can find instructions on how to do it by Googling. Basically you add some lines of text to an XML file.

[I could Google it, but there is an old way and a new way, I'm not sure which is which anymore... and it depends on which SDK you're using.]

Todd Cope

Cool! I ended up modifying sdk-root/ant/build.xml. Just had to add a <nocompress/> to the package-resources target. Most of my game is working now! Thanks everyone!

Thread #611155. Printed from