Need help as far as implementing custom font ..

Former Member
Former Member
I am trying to implement a custom font design .. and need to know SPECIFICS as to what I need to add.

I have looked at the samples .. and cannot get it to work. I always get an error message .. "cannot find source id_font_c64" or something similar.

I have something like this in my source:

using Toybox.WatchUi as Ui;
var font;

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

and in the xml file:

<fonts>
<font id="id_font_c64" filename="fonts/commodore.fnt" filter="READY0123456789:." />
</fonts>

I have the xxxxxx.fnt file and xxxxxxx.png files in my fonts folder.

What am I missing ?
  • Are you using Bmfont? When you generate your font you get a .fnt file and one or more .png files.. The .fnt is a text file. Where are you putting these files, and how are you defining them in your resources?

    It looks like "xxxxxx.fnt" should replace the font you have in your resources....
  • Former Member
    Former Member over 9 years ago
    When I build ..

    Device Version 0.1.0
    Device id 1 name "A garmin device"
    Shell Version 0.1.0
    Could not find symbol id_font_c64.
    Symbol Not Found Error
    in initialize (C:\Users\Kevin.Win8\Desktop\Garmin Dev\My Projects\DigitalVivo\source\DigitalVivoView.mc:40)
    in getInitialView (C:\Users\Kevin.Win8\Desktop\Garmin Dev\My Projects\DigitalVivo\source\DigitalVivoApp.mc:20)
    Failed invoking <symbol>
    Connection Finished
    Closing shell and port

    I have a folder fonts (path = "C:\Users\Kevin.Win8\Desktop\Garmin Dev\My Projects\DigitalVivo\resources\fonts" including the files from the sample .. I just copied them over as a test.

    Directory of C:\Users\Kevin.Win8\Desktop\Garmin Dev\My Projects\DigitalVivo\resources\fonts

    2016-04-24 09:40 PM <DIR> .
    2016-04-24 09:40 PM <DIR> ..
    2016-01-06 01:23 PM 11,586 commodore.fnt
    2016-01-06 01:23 PM 2,524 commodore_0.png
    2016-01-06 01:23 PM 1,382 commodore_1.png
    2016-01-06 01:23 PM 1,530 commodore_2.png
    2016-01-06 01:23 PM 834 commodore_3.png
    5 File(s) 17,856 bytes
    2 Dir(s) 58,286,096,384 bytes free

    I have a resources.xml file (Path =C:\Users\Kevin.Win8\Desktop\Garmin Dev\My Projects\DigitalVivo\resources) containing ...

    <resources>
    <fonts>
    <font id="id_font_c64" filename="fonts/commodore.fnt" filter="READY0123456789:." />
    </fonts>
    </resources>

    In the source ..

    using Toybox.WatchUi as Ui;
    using Toybox.Graphics as Gfx;
    using Toybox.System as Sys;
    using Toybox.Lang as Lang;
    using Toybox.Application as App;
    using Toybox.Time as Time;
    using Toybox.Time.Gregorian as Calendar;
    using Toybox.ActivityMonitor as Act;

    class DigitalVivoView extends Ui.WatchFace {

    hidden var mBattery1; // Battery Graphics 1-8
    hidden var mBattery2;
    hidden var mBattery3;
    hidden var mBattery4;
    hidden var mBattery5;
    hidden var mBattery6;
    hidden var mBattery7;
    hidden var mBattery8;

    hidden var mSteps; // Steps Graphic

    var font;

    function initialize()
    {
    WatchFace.initialize();

    mBattery1 = Ui.loadResource(Rez.Drawables.battery1); // Battery Graphics
    mBattery2 = Ui.loadResource(Rez.Drawables.battery2);
    mBattery3 = Ui.loadResource(Rez.Drawables.battery3);
    mBattery4 = Ui.loadResource(Rez.Drawables.battery4);
    mBattery5 = Ui.loadResource(Rez.Drawables.battery5);
    mBattery6 = Ui.loadResource(Rez.Drawables.battery6);
    mBattery7 = Ui.loadResource(Rez.Drawables.battery7);
    mBattery8 = Ui.loadResource(Rez.Drawables.battery8);

    mSteps = Ui.loadResource(Rez.Drawables.steps); // Steps Graphic

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

    Let me know if you need more information. I obviously did not build my own font files .. though I will once I get it working. I just used the ones from the sample for now.
    Kevin
  • Former Member
    Former Member over 9 years ago
    There used to be a problem with spaces in the path name. If this has not been addressed then your folders "Garmin Dev" & "My Projects" will be causing problems. I've been away for a while so not sure if this still relevant.
  • Former Member
    Former Member over 9 years ago
    Ok thank you .. I will give that a try.

    The other thing .. I do have a drawables.xml file in the drawables folder. It is as below .. and I have no issues with it.
    I just have issues when I am trying to add a font.

    <drawables>
    <bitmap id="LauncherIcon" filename="launcher_icon.png" />
    <bitmap id="battery1" filename="battery1.png" />
    <bitmap id="battery2" filename="battery2.png" />
    <bitmap id="battery3" filename="battery3.png" />
    <bitmap id="battery4" filename="battery4.png" />
    <bitmap id="battery5" filename="battery5.png" />
    <bitmap id="battery6" filename="battery6.png" />
    <bitmap id="battery7" filename="battery7.png" />
    <bitmap id="battery8" filename="battery8.png" />
    <bitmap id="steps" filename="steps.png" />
    </drawables>


    I was thinking it was an issue cause there are 2 xml files .. but I tried everything I could think of and no resolution.
  • Former Member
    Former Member over 9 years ago
    I don't believe there are any rules you have to follow with regards the XML files other than well formed xml. I think the file names are just for clarity. For example you could probably put all your resources in a file called myres.xml like this
    <resources>
    <drawables>
    <bitmap />
    </drawables>
    <settings>
    <setting />
    </settings>
    <properties>
    <property />
    </properties>
    <strings>
    <string />
    </strings>
    </resources>
  • Former Member
    Former Member over 9 years ago
    I don't know what it was .. but I reinstalled my Eclipse enviroment and it is working correctly now. I can now use fonts. Smiles. :cool::cool: