Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to get the pixels (or other data) for any character of the available fonts and copy/build them into a D3D texture so I could make some cache of text rendering by mapping only the character coords in the d3d texture and other stuff I need to solve (and using ID3DXFont is not an option).

How is this normally achieved? Should I render the GDI font to a GDI bitmap and then copy the opaque bits from the bitmap?

I thought about GDI because I can use the fonts installed in the system that way, but I would also like to know which formats should I consider for storing my own fonts and how these formats work.

share|improve this question
up vote 3 down vote accepted

You can use GetGlyphOutLine() with a format of GGO_GRAY8_BITMAP to extract individual character images, along with the metrics that tell you about placement and spacing. Without using those metrics, rendering the bitmaps in the correct position is much more difficult.

Ideally you'd also use data from GetKerningPairs() to improve spacing between characters when rendering.

share|improve this answer
I think I'm going for this one, thanks! – Pablo Ariel Sep 16 '11 at 18:15

Vector font formats are super-complicated. Either you're using libfreetype, using WinGDI, or making a simple bitmap font.

I don't know if this is the common solution, but libfreetype is reasonably easy to install and use, and you can then package your font of choice along with your program.

I wouldn't rely on system fonts - you never know when some smartaleck is going to have uninstalled Arial.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.