Fonts in Resource File using SDK 1.2.1 how do I add fonts?

Former Member
Former Member
Hi

Before SDK 1.2.1 I used to load my bitmaps and fonts from the resource.xml file. With a simple line:

<font id="id_font_mex" filename="fonts/mex.fnt" />

Now I'm creating a new watch face based on the Simple with Settings template included in the new SDK 1.2.1 the resource.xml is not there anymore I solved some issues moving some assets to the drawables folder/xml file.
I want to add a new font so I thought that creating a resource.xml will solve the issue but It's not working Eclipse is not reading the file.

Question:

In what file should I add the font I want to use? I'm lost, I did not find anything in the documentation so far.

When using the template with Settings new files are created like: drawables.xml, layout.xml,properties.xml, settings.xml, strings.xml I tried adding the font id in the drawables.xml, layout.xml and resources.xml (created by me)

As always your help is greatly appreciated.

JMX
  • Former Member
    Former Member over 9 years ago
    The Eclipse plug-in looks for XML files who's base folder starts with "resource". If you want to add a font resource it can be added to any XML file that meets this condition (you could put a font definition in resources/strings/strings.xml). I personally would recommend creating a fonts.xml file at resources/fonts/fonts.xml. You could then include all of the necessary font files within the resources/fonts folder.
    resources
    fonts
    fonts.xml
    mex.fnt
    ...
  • Former Member
    Former Member over 9 years ago
    Hi Ken

    Thank you for your reply. I did try to create a resources.xml file under the resources folder and Eclipse ignore it. I will try your suggestion, I will create a fonts.xml file under the path resources>fonts>fonts.xml

    I will test it once I return from work :)
  • Former Member
    Former Member over 9 years ago
    Hi Ken

    I just tried your suggestion but is not working, do I'm missing something, the path of the file is resources\fonts\fonts.xml:

    The fonts.xml file only have this info, I tried with and without the <font> </font> brakets

    <resources>
    <font>
    <font id="id_font_mex" filename="fonts/mex.fnt" />
    </font>
    </resources>


    The error output is the following:

    Connecting to device...
    Device Version 0.1.0
    Device id 1 name "A garmin device"
    Shell Version 0.1.0
    Could not find symbol id_font_mex.
    Symbol Not Found Error
    in onLayout (C:\Users\Akira\workspace\Mexico\source\MexicoView.mc:25)
    Failed invoking <symbol>
    Symbol Not Found Error


    So I'm still experiencing the same problem, I don't know how to force eclipse to search for the resources.xml or fonts.xml, should be automatic but why is not working? Any ideas?

    Thanks!
  • Are you loading the font with Ui.loadResource(Rez.Fonts.id_font_mex)?
  • Load the font is not working at the moment when the font need more than one PNG file. I thing that is error in SDK 1.2.1
  • <resources>
    <font id="id_font_mex" filename="fonts/mex.fnt" />
    </resources>

    In my opinion your file should look like this above. You placed font element into another font element what isn't good idea.
  • Former Member
    Former Member over 9 years ago
    Are you able to compile your app in the first place?

    <resources>
    <font>
    <font id="id_font_mex" filename="fonts/mex.fnt" />
    </font>
    </resources>



    This code implies that you have another folder named fonts alongside your XML file with mex.fnt inside of it. The filename attribute should contain a path to your font file in relation to your XML file. That means you're implying this:

    resources
    fonts
    fonts.xml <-- this file contains filename="fonts/mex.fnt"
    fonts <-- which implies this folder exists
    mex.fnt <-- and this file exists within that folder