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
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.
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.
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.
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
5
Convert the Font
When you have finished selecting the fonts to import, select Project then Convert from the GRC.
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
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.