MicroStrategy ONE

Use Custom Fonts in Android

You can add a custom font that MicroStrategy Mobile does not support out-of-the-box and use it in a document viewed on an Android mobile device. You do this by adding the font file to the MicroStrategy Mobile project in Android Studio, and mapping the custom font name to its font file in the font mapping configuration file for the project. In addition, you need to add a plug-in to make the font available in MicroStrategy Web.

  • To add a custom font and use it in a document viewed on an Android device, you must add the necessary font file to your Android Studio project, configure the FontsMapping.xml configuration file, and recompile the MicroStrategy Mobile project. To be able to apply the font to a document, you also need to add a plug-in that makes the font available in MicroStrategy Web.
  • To change the default font used by a document viewed on an Android device, you must add the font file to your Android Studio project, configure the FontsMapping.xml to map the font name to the font file, and recompile the MicroStrategy Mobile project. Because MicroStrategy Mobile for Android uses the default font automatically when it cannot find another font file, there is no need for a plug-in to make it available in MicroStrategy Web.  

Android supports two fonts by default:

  • Roboto-Regular.ttf
    When you apply the Normal, Serif, or San-Serif font to a document, the Roboto-Regular font file is used when you view the document on an Android device.
  • DroidSansMono.ttf
    When you apply the Monospace font to a document, the DroidSanMono font file is used when you view the document on an Android device.

The default font for MicroStrategy Mobile for Android is Sans-Serif. If you use a font that Android does not support in a document and try to view it on an Android device, the Sans-Serif font is used unless you have changed the default font. In order for a font to be supported, a .ttf file for the font must exist in the Android project and the font mapping configuration file must map the font name to the .ttf file for the font. Support can be out-of-the-box or the result of a custom font being added.

Add a custom font

The steps below illustrate how to add a custom font and use it in a document viewed on an Android device.

  1. Copy FontPlugin_GaugeRegular to the plugins folder in your MicroStrategy Web installation directory. This plug-in adds Gauge to the list of fonts available in MicroStrategy Web. 
  2. Expand FontPlugin_GaugeRegular and navigate to WEB-INF/xml/config and open fontNamesPicker.xml. The contents of the file are shown below:

    Copy
    <shortcut-list name="fontPicker">
      <shortcut desc="Gauge" name="pkrpkrGauge">
        <attributes>
          <attribute name="style" source="const" value="font-family:Gauge"/>
          <attribute name="value" source="const" value="Gauge-Regular"/>
        </attributes>
      </shortcut>
    </shortcut-list>
  3. Restart the web server. 
  4. In MicroStrategy Web, create a document, add a label called "Test Gauge Font", and set the label font to Gauge. This is the font you added with the plug-in.
  5. On the machine where Android Studio is installed, download the font file for Gauge-Regular and save it.
  6. In Android Studio, navigate to MicroStrategy Mobile -> app -> src -> main -> assets -> fonts.

    1. Drag and drop Gauge-Regular.ttf, the font file you downloaded, into the fonts folder.

    2. Open FontsMapping.xml and add the <font> node shown below as a child of the <fonts> node

      Copy
      <font>
        <custFontName>Gauge</custFontName>
        <custFontFile>Gauge-Regular.ttf</custFontFile>
      </font
  7. Open MicroStrategy Mobile on your mobile device and view the document you created. The "Test Gauge Font" label is displayed using the Gauge-Regular font.

Change the default font

The steps below illustrate how to change the default font used by MicroStrategy Mobile for Android and use it in a document viewed on an Android device. 

  1. In MicroStrategy Web, create a document and add a label called "Test Default Font". There is no need to modify the font applied to the label since the default font will be used. Whenever Android cannot find a specified font file, it automatically uses the default font defined in the font mapping configuration file. This example assumes that the font used for the label does not have a font file or font mapping in MicroStrategy Mobile.

  2. On the machine where Android Studio is installed, download the font file for Times New Roman and save it. This is the font which will be used as the default font.

  3. In Android Studio, navigate to MicroStrategy Mobile -> app -> src -> main -> assets -> fonts.

    1. Drag and drop Times New Roman.ttf, the font file you downloaded, into the fonts folder.

    2. Open FontsMapping.xml and add the <defaultFont> node shown below as a child of the <fonts> node:

      Copy
      <defaultFont>
        <defaultFontName>Times New Roman</custFontName>
        <defaultFontFile>Times New Roman.ttf</custFontFile>
      </defaultFont>
  4. Compile the MicroStrategy Mobile project. 
  5. Open MicroStrategy Mobile on your mobile device and view the document you created. The "Test Default Font" label is displayed using the Times New Roman font.