Adding Fonts To Your Application
This section provides an overview of the steps required to reference and use fonts in a .NET Micro Framework application.
Adding the Font Resource to Your Application
Once a .tinyfnt
file has been generated, add the font resource to your application using the following procedure.
- Open the Resource Designer by double-clicking on
Resources.resx
in Solution Explorer. - On the Resource Designer toolbar, point to Add Resource, click the arrow, then click Add Existing File.
- In the Add existing file to resources dialog box, browse to the
.tinyfnt
file, and then click Open. The file will be added to the Resources directory, and the Resource Designer will open the Files pane.
Using Fonts In Your Application
Once the .tinyfnt
font file has been added to your application's Resources, you can use the font in your application's code. Visual Studio automatically generates the Resources.FontResources enumerated type to contain members that identifies each font. Each member has the same name as its corresponding .tinyfnt
file. For instance, the member Resources.FontResources.miramonte
would identify the font in the miramonte.tinyfnt
file. To retrieve a Font object, call the Resources.GetFont method, passing the Resources.FontResources enumerated type member that identifies the font. For example, the following code creates a text control and sets its font to the font contained in the miramonte.tinyfnt
file.
// Create a single text control. Text text = new Text(); // Set Font text.Font = Resources.GetFont(Resources.FontResources.miramonte);