2
\$\begingroup\$

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.

\$\endgroup\$

2 Answers 2

3
\$\begingroup\$

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.

\$\endgroup\$
0
0
\$\begingroup\$

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.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .