FileNotFoundException when loading a font file

Forum for the Android Game Development Workshop. See http://code.google.com/p/agd-101/

FileNotFoundException when loading a font file

Postby Walla » Wed Jul 15, 2015 6:58 am

Hello everyone here in the LibGDX community,

first-poster here :)

I have a problem running the android project of my game, i explained everything in this question here http://gamedev.stackexchange.com/questions/103470/libgdx-cant-read-ttf-file-when-running-android-configuration

The problem started when i wanted to change my whole project name (in order to change the app's name too). Not finding solutions on how to do that online, i proceeded to do it by myself :roll:
I created a new project in another folder by using the project-creator GUI from LibGDX website. Then, with both Android Studio windows opened, i moved all the classes from one project to the other.
I resolved few errors in the imports sections and voilà, no errors when making/building the project.
Desktop version runs flawlessy but when i launch android version on my phone, it gives error when loading the .ttf font for the FreeTypeFontGenerator (i don't use FreeTypeFontGenerator itself but this "extended version" https://github.com/jrenner/gdx-smart-font).

The logcat error is this:
Code: Select all
com.badlogic.gdx.utils.GdxRuntimeException: Error reading file: data/fonts/myFont.ttf (Internal)


and the cause is this:
Code: Select all
Caused by: java.io.FileNotFoundException: data/fonts/myFont.ttf at android.content.res.AssetManager.openAsset(Native Method) at android.content.res.AssetManager.open(AssetManager.java:359) at com.badlogic.gdx.backends.android.AndroidFileHandle.read(AndroidFileHandle.java:‌​75)


So it seems that it couldn't find the file.. :|
My file handle is this:
Code: Select all
FileHandle fontFile = Gdx.files.internal("data/fonts/myFont.ttf");


I'm sure the file is in the correct folder (..assets/data/fonts/myFont.ttf), because when running desktop i have no problem at all.

If anyone could help me, i will really appreciate that! :oops: :oops:
Walla
 
Posts: 8
Joined: Wed Jul 15, 2015 6:33 am

Re: FileNotFoundException when loading a font file

Postby MrBojangles » Sat Aug 06, 2016 2:37 am

Have you tried other fonts?
MrBojangles
 
Posts: 1
Joined: Sat Aug 06, 2016 2:34 am

Re: FileNotFoundException when loading a font file

Postby Darcy357 » Wed Jan 02, 2019 11:55 am

Hi,

Try to use another ttf file instead to test your code. It must be something wrong with the file.

Or you can include a ttf file directly from a file:

privateFontCollection.AddFontFile("D:\\systemroot\\Fonts\\Arial.ttf");

Thanks
Darcy357
 
Posts: 1
Joined: Mon Oct 29, 2018 7:48 am


Return to Android Game Development Workshop

Who is online

Users browsing this forum: No registered users and 1 guest