A class to parse graphical fonts

A class to parse graphical fonts

Introduction

Add graphical fonts to your applications and games. If the user who is using your game doesn't have the fonts needed, Windows tries to calculate the best match, but why? You can use graphical fonts.
A free font image builder is located here.
This is a VB.NET class that will parse those fonts and return a string (actually a bitmap representation or your string). It has other methods such as getCell but mostly what it will be used for is building strings.

Sample Font File (shrunk)

Initializing cGraphicFont

Here is how to create the object:
dim fntFromBmp = New cGraphicFont(Me, fontFile, Color.Black, 16, 16, " ")
  • The first parameter is a form object and should be left as me.
  • The second parameter is a bitmap object. This will be the bitmap of your font file.
  • The third parameter is background transparency of the bitmap.
  • The fourth and fifth parameters are the number of cells across and the number down.
  • The sixth parameter is the first letter in your font file.

Using cGraphicFont

dim fntFromBmp = New cGraphicFont(Me, fontFile, Color.Black, 16, 16, " ")
picturebox1.image = fntFromBmp.getString("CodeProject", Brushes.Transparent)
fntFromBmp.dispose()
  • getString's first parameter is the text you want to display.
  • getString's second parameter is the background of the resulting image.

 

Smiley face

Enregistrer un commentaire

0 Commentaires