Importing Fonts Into an MLA Graphics Project

 Summary

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

GRC_directory.png

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

Linux and Apple OSX 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 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.

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.

convert_font.png
Click image to enlarge.

6

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

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.

20th Annual
Microchip MASTERs Conference 2016
Register now - Deadline: July 29

JW Marriott Desert Ridge Resort-Phoenix, AZ

© 2016 Microchip Technology, Inc.
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.