Click here to Skip to main content
13,150,178 members (58,067 online)
Click here to Skip to main content
Add your own
alternative version


19 bookmarked
Posted 3 Jan 2004

A class to parse graphical fonts

, 3 Jan 2004
Rate this:
Please Sign up or sign in to vote.
How to use graphical fonts in your games

Sample Image - graphicFont_picture.gif


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)

Sample screenshot

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)
  • getString's first parameter is the text you want to display.
  • getString's second parameter is the background of the resulting image.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Matthew Hazlett
Web Developer
United States United States
I started programming for fun when I was about 10 on an Franklin Ace 1000.

I still do it just for fun but it has gotten me a few jobs over the years. More then I can say for my Microsoft Certifications. Smile | :)

The way I learned was by example, now its time to give back to the next generation of coders.

You may also be interested in...

Comments and Discussions

GeneralThere's a bug in getCell() Pin
nobuyuki_nyuu29-Jan-07 15:50
membernobuyuki_nyuu29-Jan-07 15:50 
QuestionKerning? Pin
Joel Holdsworth5-Jan-04 3:16
memberJoel Holdsworth5-Jan-04 3:16 
AnswerRe: Kerning? Pin
dog_spawn5-Jan-04 4:28
memberdog_spawn5-Jan-04 4:28 
AnswerRe: Kerning? Pin
hazlema9-Jan-04 6:45
memberhazlema9-Jan-04 6:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170924.2 | Last Updated 4 Jan 2004
Article Copyright 2004 by Matthew Hazlett
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid