This page shows how to use the Graphics Resource Converter (GRC) to import fonts into a Graphics project based on the Microchip Libraries for Applications (MLA). This tutorial places the imported font into program memory.
Starting the Graphics Resource Converter utility
The GRC is located in the MLA Installation directory:
Linux and Apple OSX users launch the resource converter by executing grc.jar, and Microsoft Windows users invoke it by executing launch_grc.bat
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"
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 may be licensed. It is not uncommon for fonts to be copyrighted.
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.
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
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.
Include the 3 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 left shows the files for the Miriam_Fixed_Bold font from step 3 included in a project which were saved in files with the names of MyNewFont.s, MyNewFont.h, and MyNewFont_reference.c
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.