Importing Fonts Into an MLA Graphics Project

This page contains information for the Graphics Library found in Microchip Libraries for Applications (MLA). It is not relevant for the MPLAB® Harmony Graphics Library.

 Summary

This page shows how to use the Graphics Resource Converter (GRC) to import fonts into a Graphics project based on the MLA. This tutorial places the imported font into program memory.

Starting the GRC Utility

GRC_directory.png

The GRC is located in the MLA Installation directory:
…microchip/mla/vYYYY_MM_DD/framework/gfx/utilities/grc

Linux and Apple OS X® users launch the resource converter by executing grc.jar, and Microsoft® Windows users invoke it by executing launch_grc.bat.

1

Configuring the GRC

  • From the GRC user interface, select Project then Settings.
  • For this example, configure the GRC to import fonts into internal program memory (internal Flash).
  • If you are importing a bitmap image, you have an option of several formats to store the image. Selecting the Bits Per Pixel (bpp) has no effect on the imported font. For importing fonts, it is acceptable to allow the default setting of 16 bpp image.
  • After configuring the GRC, select OK.
GRC_setup.png
GRC_settings.png

2

Select Font to Import

The GRC will allow you to import either a font that is already installed on your machine or to import a font from a font file. To import a font, select File then either Add Fonts or Add installed Fonts.

Selecting Add Fonts allows you to import a file from either a TTF or FNT file. FNT files were once the preferred font file format but are now considered to be outdated. Currently, OpenFile and TrueType Font (TTF) file formats have become the standard.

Selecting Add Installed Fonts allows you to use a font already installed on your computer.

Fonts are created with font editors and may be considered works of art. Pre-created fonts are available from many sources but those may be licensed. It is not uncommon for fonts to be copyrighted.

font_source.png
Click image to enlarge.

3

Using an Already Installed Font

After selecting Add Installed Font, the Font Chooser will appear showing you all the installed fonts on your computer. You will be able to:

  • Select font and size
  • Preview the pixel size of the font
  • Filter the font to remove unused characters

In this example, we have chosen the previously installed Miriam_Fixed font with a size of 18 and the attribute of bold.

This example does not attempt to filter the font image.

Select OK when done.

font_chooser_installed.png
Click image to enlarge.

4

Using a Font Imported From a File

When Add Fonts has been selected you will be prompted to browse to find either a .ttf or .fnt font file. Once you have located and selected a font file, the GRC's Style Chooser will appear. The Style Chooser gives you the the option of selecting the size, bold, and italics attributes. You are also given the option of filtering to reduce the size of the font image.
The example here shows the selection of size 12, bold, of the font found in the file DoulosSILR.ttf

font_style_chooser.png
Click image to enlarge.

5

Convert the Font

When you have finished selecting the fonts to import, select Project then Convert from the GRC.

convert_font.png
Click image to enlarge.

Before converting the font, the GRC will ask you to select a file name and location to store the converted font.

The conversion process will create an assembly (.s), c source code (.c), and a header file (.h) using the base name selected.

6

Include the three fonts files in the MPLAB X Project

The conversion process creates a C (.c), an assembly (.s), and a header file (.h) for each font. The base names are derived from the name specified when the files were converted. These files need to be included in the MLA Graphics project in the same manner as all other source and header files.

The image on the right shows the files for the Miriam_Fixed_Bold font from step three included in a project which were saved in files with the names of MyNewFont.s, MyNewFont.h, and MyNewFont_reference.c

font_files_include.png
Click image to enlarge.

7

Build the Project

Re-building the project after the font's header and source files have been added makes the new font available to use.

© 2024 Microchip Technology, Inc.
Notice: ARM and Cortex are the registered trademarks of ARM Limited in the EU and other countries.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.