Is there a way I can use an OTF file with libGDX.

The following throws an exception:

gameFont = new BitmapFont(Gdx.files.internal("data/font.otf"));

Caused by: com.badlogic.gdx.utils.GdxRuntimeException: Invalid padding.

This is the same error thrown if I were to try to use a non font file type as well. (i.e. .png .mp3 etc). I have been able to use .fnt files in the past. Is there anyway around this? Thanks.


Not directly, but you could create a font for libgdx from a .otf using the Hiero tool to convert your font, or create one at runtime but (like the author of this site says), it's something that you should try to avoid.

An example of how to load an .otf font can be found here

  • \$\begingroup\$ Thank you. I managed to use the Hiero Tool and it worked fine. I appreciate the help. \$\endgroup\$ – Ayman Elmubark Jun 23 '15 at 21:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.