Hello!
I am trying to get a font by name (e.g. "BigRedFont").
The usual way in the engine to do this is to use the
getFont(id)
function, but that takes the font ID, not its name and that's not very helpful.
I saw this post (
http://community.stencyl.com/index.php?topic=45647.0) about this topic which says to use the following code:
for (res in Data.get().resources)
{
if (Std.is(res, Font) && res.name == "Font Name Here")
{
return cast (res, Font);
}
}
return null;
However, this does not work for me. It returns null.
So I went and printed (traced) the whole Data.get().resources object and I noticed that multiple of my fonts are missing from there.
My guess is that the fonts are not loaded yet in the scene, but I was out of luck browsing the Stencyl Haxe API for a solution.
Does anyone know a foolproof method to get a Font by its resource name?
Thanks a lot!