0
\$\begingroup\$

I tried to load a ttf font using an AssetManager like this:

FreetypeFontLoader.FreeTypeFontLoaderParameter freeTypeFontLoaderParameter = new FreetypeFontLoader.FreeTypeFontLoaderParameter();
freeTypeFontLoaderParameter.fontFileName = "fonts/zrnic.tff";

FreeTypeFontGenerator.FreeTypeFontParameter freeTypeFontParameter = new FreeTypeFontGenerator.FreeTypeFontParameter();
freeTypeFontParameter.minFilter = Texture.TextureFilter.Linear;
freeTypeFontParameter.magFilter = Texture.TextureFilter.Linear;
freeTypeFontParameter.flip = false;
freeTypeFontParameter.size = 62;

freeTypeFontLoaderParameter.fontParameters = freeTypeFontParameter;

game.assetManager.load("myFont62.ttf", BitmapFont.class, freeTypeFontLoaderParameter);

But I get

Couldn't load dependencies of asset: myFont62.ttf

\$\endgroup\$
1
  • \$\begingroup\$ Put your zrnic.ttf in Assets folder (without any subfolders). Rename Assets folder to Assets2 and rename back to Assets (you have to close the IDE (And Studio/Eclipse/Intellij) before renaming). Change your fonts/zrnic.ttf to just "zrnic.ttf" and check if this works. If yes - post an answer here. \$\endgroup\$
    – Jacob
    Nov 7, 2016 at 19:29

1 Answer 1

1
\$\begingroup\$

I updated the LibGDX wiki to specifically address this issue. The old example code used there was just too confusing for anyone to take a quick glance at and figure out what they were doing. Take a look when you get a chance.

Anyway, you're loading myFont62.ttf which is a string identifier of the resource fonts/zrnic.ttf. Instead of using a different name, you might try making the string identifier the same as the font resource. This makes it so that you aren't using two names for the same thing, and so that your string identifiers match your filenames.

Your problem is coming from a filesystem issue. It looks like your assets/ folder is not recognizing the location fonts/zrnic.ttf. In your filesystem, you should have your font accessible as yourgamefolder/android/assets/fonts/zrnic.ttf

If it's anywhere else, you're going to get that error. As far as closing and re-opening the IDE, I've never ran into that problem, before. Just put your fonts/ folder inside your assets/ folder, and it should work just fine.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .