Custom Fonts SDK 1.2.5 Questions

Former Member
Former Member
Hello All

I have a general question about the custom fonts, in the first SDK releases the custom fonts are declared in the folder resources in the resources.xml file like this:

<resources>
<string id="AppName">Crafty</string>
<bitmaps>
<bitmap id="LauncherIcon" filename="images/launcher_icon.png" />
<bitmap id="fondo" filename="images/blackbkg.png" />
</bitmaps>
<fonts>
<font id="id_font_craft" filename="fonts/Onlynumjmx.fnt" />
</fonts>
</resources>


Later on I called the font in the main code like this:

font = Ui.loadResource(Rez.Fonts.id_font_craft);

Now when I create a new project in SDK 1.2.5 with settings the resources.xml file is no longer created.

Question: Where should I put the font id now? In the same resources.xml file by creating a new one? The documentation is not clear about it and the examples included in the SDK are from the first SDK releases.

Can someone please let me know what is the right way to load the custom font? Is still using the resources.xml file?

Thank you!
  • You can put it in any resource file you want. The file should be in one of the resource folders (you may have multiple, one for device and language specific resource definitions). I believe there is an entire section on this in the programmers guide.

    Travis
  • Former Member
    Former Member over 9 years ago
    You can put it in any resource file you want. The file should be in one of the resource folders (you may have multiple, one for device and language specific resource definitions). I believe there is an entire section on this in the programmers guide.

    Travis


    Hi Travis, thanks for the reply.

    Can you be more specific please? I created a resources.xml file and put in the resources folder of my project, the RESOURCES folder have 3 folders: drawables, layouts and strings plus the font folder I created, I tried to add the following code in the layout.xml and drawables.xml file, this is the code I add:

    <font id="id_font_rum" filename="fonts/chunkfive.fnt" />

    If I put this line in the layout.xml/drawables.xml I get the message that the compiler is expecting something different than font id If I put the line mentioned above in the resources.xml file I created I get this error:

    Device id 1 name "A garmin device"
    Shell Version 0.1.0
    Could not find symbol id_font_rum.
    Symbol Not Found Error
    in onLayout (C:\Users\JMX\workspace\SOF\source\SOFView.mc:22)
    Failed invoking <symbol>
    Connection Finished


    Line 22 in my code invoke the font from the resources.xml file:

    font = Ui.loadResource(Rez.Fonts.id_font_rum);

    In older projects made with the first SDK this works with no issue but is not working in new projects. Any ideas?

    Thanks!

    JM
  • Most likely the problem is that you now need to put the font element inside a fonts element, and that fonts element should be within a resources element.

    <resources>

    <fonts>
    <font id="id_font_rum" filename="fonts/chunkfive.fnt" />
    </fonts>

    </resources>



    The old resource file parser wasn't very good about doing validation, so you were allowed to get away with this, and the old sample programs did it as well. When the parser was updated, all of the sample programs were updated as well. You should be able to look to them to see the right way to do things like this.

    Travis
  • Former Member
    Former Member over 9 years ago
    Most likely the problem is that you now need to put the font element inside a fonts element, and that fonts element should be within a resources element.

    <resources>

    <fonts>
    <font id="id_font_rum" filename="fonts/chunkfive.fnt" />
    </fonts>

    </resources>



    The old resource file parser wasn't very good about doing validation, so you were allowed to get away with this, and the old sample programs did it as well. When the parser was updated, all of the sample programs were updated as well. You should be able to look to them to see the right way to do things like this.

    Travis


    Travis, Thanks!

    In fact I forgot to mention but I'm using the <fonts> and </fonts> in the resource.xml file I have tried few combinations too in the resource.xml file to no avail, what I'm doing wrong??

    http://www.jmsnetwork.org/font.PNG -->>Capture of the error with resources.xml

    I also tried with:

    <resources>
    <string id="AppName">Sof</string>
    <fonts>
    <font id="id_font_craft" filename="fonts/Onlynumjmx.fnt" />
    </fonts>
    </resources>



    Thanks for your help!
  • I'd put the string element inside a <strings> element. If that doesn't work, I'd go back to one of the sample programs. Verify it works, then copy the source.

    Travis