Other language support with custom fonts

Hi,

could someone please explain what I need to do to support non English languages with custom fonts?

I use custom fonts throughout my watchface as I want the same font on all devices, fenix, 920, VA, etc, etc for a consistent look.

But not sure of what I need to do to support non English languages.

1) Do I need to include every possible character in BMPFONT, i.e. all available not just the English looking ones?
2) What actually happens when I tick the non English languages when building the watch face? What is the purpose of that?
3) Is there anything else I need to consider to support non English?

Thanks! :-)
  • Hi,

    could someone please explain what I need to do to support non English languages with custom fonts?

    I use custom fonts throughout my watchface as I want the same font on all devices, fenix, 920, VA, etc, etc for a consistent look.

    But not sure of what I need to do to support non English languages.

    1) Do I need to include every possible character in BMPFONT, i.e. all available not just the English looking ones?
    2) What actually happens when I tick the non English languages when building the watch face? What is the purpose of that?
    3) Is there anything else I need to consider to support non English?

    Thanks! :-)


    Hi Rupert,

    No, you don't need to include every possible character.
    Some fonts have way too many, and including them all quickly result in out-of-memory errors.

    What I do is to include the following sets if available: Latin, Greek, Cyrillic

    According to "Appendix B: Font Specifications" in the User Experience Guide, most fonts include Roman (Latin), Greek, Cyrillic and expanded and/or standard diacritics.

    I am also not 100% sure what to include, but have found that most Scandinavian languages do OK with the Latin/Roman set. Reduce the number of characters by excluding punctuation marks that you won't use. There is a lot of "noise" and it is hard to tell what to exclude if you are not familiar with the character set of a particular language. Take Russian for example. :eek:

    Hope this helps a bit.
  • Thanks!

    And any ideas about this?

    2) What actually happens when I tick the non English languages when building the watch face? What is the purpose of that?
  • I believe it causes the resource folders for different languages to be read similar to device folders. So you have the default folder resources which contains all your defaults and then the device folders might look like:

    resources-fenix3
    resources-fenix3_hr
    resources-fr630
    ...

    Using that model I believe when you select different languages you can have different string files defined to support them:

    resources-eng (English)
    resources-deu (German)
    resources-swe (Swedish)

    Maybe someone can chime in but I believe this is what is happening since I have just started to experiment with this myself.
  • Cyrillic support needed/ upper ANSI table handling is incorrect!

    I modified resources.xml to load only 3 cyrillic letters:
    <resources>
    <fonts>
    <font id="id_font_black_diamond" filename="fonts/blackdiamond.fnt" filter="&#1040;&#1041;&#1042;" />
    </fonts>
    </resources>

    These are #192 - #194 in ANSII table.

    Font is modified to have 192 - 194 glyphs:
    char id=192 x=108 y=0 width=17 height=26 xoffset=1 yoffset=0 xadvance=19 page=0 chnl=15
    char id=193 x=126 y=0 width=17 height=26 xoffset=1 yoffset=0 xadvance=19 page=0 chnl=15
    char id=194 x=144 y=0 width=17 height=26 xoffset=1 yoffset=0 xadvance=19 page=0 chnl=15


    >BUILD: ERROR: Problem validating a resource file: Invalid byte 1 of 1-byte UTF-8 sequence.

    When resources.xml is saved in UTF-8 with Cyrillic chars:
    I get:
    >BUILD: ERROR: Font 'Black Diamonds' does not have characters in the given filter '&#1056;&#1106;&#1056;‘&#1056;’'.

    Question: when support for upper ANSII table will be introduced correctly?
  • I can reproduce this, but only when I try to filter on characters that are not actually available in my bitmap font.

    Did you only edit the .fnt file to include the char entries, or did you re-export the font to include these cyrillic characters from a source ttf file? The Black Diamonds font that is included with our samples does not have the cyrillic characters included, so simply editing the .fnt file could result in the issue you've encountered. The compiler would attempt to resolve characters that simply aren't there.

    I used the BMFont tool and exported a small custom font based on Times New Roman to include the "&#1040;&#1041;&#1042;" characters. Incidentally, these glyphs were included as:

    char id=1040 x=0 y=0 width=19 height=18 xoffset=0 yoffset=6 xadvance=19 page=0 chnl=15
    char id=1041 x=38 y=0 width=16 height=18 xoffset=0 yoffset=6 xadvance=16 page=0 chnl=15
    char id=1042 x=20 y=0 width=17 height=18 xoffset=0 yoffset=6 xadvance=18 page=0 chnl=15


    When I used this font in an app that specifies the resources exactly as you have below, I do not receive the error.

    Cyrillic support needed/ upper ANSI table handling is incorrect!

    I modified resources.xml to load only 3 cyrillic letters:
    <resources>
    <fonts>
    <font id="id_font_black_diamond" filename="fonts/blackdiamond.fnt" filter="&#1040;&#1041;&#1042;" />
    </fonts>
    </resources>

    These are #192 - #194 in ANSII table.

    Font is modified to have 192 - 194 glyphs:
    char id=192 x=108 y=0 width=17 height=26 xoffset=1 yoffset=0 xadvance=19 page=0 chnl=15
    char id=193 x=126 y=0 width=17 height=26 xoffset=1 yoffset=0 xadvance=19 page=0 chnl=15
    char id=194 x=144 y=0 width=17 height=26 xoffset=1 yoffset=0 xadvance=19 page=0 chnl=15


    >BUILD: ERROR: Problem validating a resource file: Invalid byte 1 of 1-byte UTF-8 sequence.

    When resources.xml is saved in UTF-8 with Cyrillic chars:
    I get:
    >BUILD: ERROR: Font 'Black Diamonds' does not have characters in the given filter '&#1056;&#1106;&#1056;‘&#1056;’'.

    Question: when support for upper ANSII table will be introduced correctly?
  • Thank you, Brandon. You shared one important thing - everything must be UTF-8 encoded. Please add this to the documentation and maybe Connect IQ plugin.

    char id=1040 x=0 y=0 width=19 height=18 xoffset=0 yoffset=6 xadvance=19 page=0 chnl=15
    char id=1041 x=38 y=0 width=16 height=18 xoffset=0 yoffset=6 xadvance=16 page=0 chnl=15
    char id=1042 x=20 y=0 width=17 height=18 xoffset=0 yoffset=6 xadvance=18 page=0 chnl=15


    I tried resources.xml in UTF-8 with 1040-1042 values and it was compiled (at least). I have a lot of .bmp Cyrillic fonts specially made for Garmin long time ago, and I definitely will use manually created fonts. BMfont is useful to understand output format.
    Also the same approach to save .mc files in UTF-8 led me to successful compilation and output text in Cyrillic for default fonts. I assume drawText and other string handlers accept UTF-8 coded strings.
    Quick and dirty example how it works:
  • UTF-8 isn't strictly the requirement. I think it's that you need to be sure you're using the unicode character table, and not some other table like ASCII. :)