mMyBMFont.toString() Error!

Such code crashes simulator:

myFont = Ui.loadResource(Rez.Fonts.SomeFont);
var str = mFont.toString();


In console window I have this:

Device Version 0.1.0
Device id 1 name "A garmin device"
Shell Version 0.1.0
Socket Error in packet header 0
Connection Finished
Closing shell and port


I expected something not null but maybe I shouldn't?

Peter
  • You want to convert a font to string? Don't know what you expect.
    If you'll specify a font for a text you can make it in drawText function while writing that text on the screen.
  • I have no idea what "toString()" should return here (I double anything worthwhile, actually), but this call shouldn't crash the simulator, and to me that's a bug in the simulator. If the font wasn't available, you'd get a compile error, IIRC.

    What are you expecting to get back with toString()? There might be another way to do that, or it could be something that's simply not available.
  • I was hoping to get resource ID number or at least memory pointer. Font works fine but I did it only out of curiosity because I have to use code like this:
    class MyDrawable extends Ui.Drawable
    {
    hidden var m_Font;
    hidden const c_LastFont = 8;

    function initialize(params)
    {
    var mx = params.get(:x);
    var my = params.get(:y);

    m_Font = params.get(:font);

    if (m_Font > c_LastFont)
    {
    m_Font = Ui.loadResource(m_Font);
    }
    Ui.Drawable.initialize({:locX=>mx, :locY=>my});
    }


    to get working font.

    Peter