Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...


Hint: Use ARES Commander to get the correct values you want to use inside your mobile application.

...

How can I load custom fonts?

The CFxARESInstanceDelegate offers a method getFontsPath() that allows the host application to load its own fonts. Overwriting (@Override) the method will make the kernel SDK read the fonts location from the host application. The fonts path returned must point to an existing and accessible location on the device.

Code Block
languagejava
public class ARESDelegate extends CFxARESInstanceDelegate
{
...
  @Override
  public String getFontsPath()
  {
    // Returns the path with custom fonts folder.
    // The path should contain custum fonts and 'fontConfig.xml' file which tells ARES instance what fonts to load.
    // 'fontConfig.xml' supports two configuration options:
    // 1. Substitution. User defines a set of fonts which should be used instead of the missing one.
    //    In the example Arimo fonts substitute Arial font family.
    //    <family name="Arial">
    //        <style filename="Arimo-Regular.ttf" />
    //        <style filename="Arimo-Italic.ttf" />
    //        <style filename="Arimo-Bold.ttf" />
    //        <style filename="Arimo-BoldItalic.ttf" />
    //    </family>
    // 2. Direct font loading. User specifies the filename to be loaded. In this case ARES will parse the font file and load
    //    everything as is.
    //    <fontfile filename="msgothic.ttc"/>
    //    <fontfile filename="msmincho.ttc"/>
    //
    return "assets:/Fonts/";
  }
...
}


The kernel SDK also expects to read a special XML file (fontConfig.xml) from this location. This file is treated as some sort of index and specifies what fonts are loaded and which fonts are supposed to substitute missing fonts.

Hint: The sample application DWG Editor uses this concept.

...