Reputation: 33
Hi I'm currently stuck on trying to load a .ttf
font, I'm getting a GdxRuntimeException with the message: Couldn't load dependencies of asset: coastershadowfont
FileHandleResolver resolver = new InternalFileHandleResolver();
assetManager.setLoader(FreeTypeFontGenerator.class, new FreeTypeFontGeneratorLoader(resolver));
assetManager.setLoader(BitmapFont.class, ".ttf", new FreetypeFontLoader(resolver));
FreetypeFontLoader.FreeTypeFontLoaderParameter params = new FreetypeFontLoader.FreeTypeFontLoaderParameter();
params.fontFileName = "fonts/coastershadow.ttf";
params.fontParameters.size = 30;
assetManager.load("coastershadowfont", BitmapFont.class, params);
try {
assetManager.finishLoadingAssets();
} catch (Exception exception) {
System.out.println(exception.toString());
}
Upvotes: 2
Views: 737
Reputation: 20140
Pass fileName with extension, when you call load(...)
method on AssetManager
. FileName should be anything with extension.
assetManager.load("coastershadowfont.ttf", BitmapFont.class, params); //Adds the given asset to the loading queue of the AssetManager.
assetManager.finishLoading(); // triggered to execute task
And get BitmapFont
with fileName that you specified at loading time.
font= assetManager.get("coastershadowfont.ttf",BitmapFont.class);
Upvotes: 2