Load font from file, and draw text with that font

Started by
1 comment, last by leidegren 16 years, 6 months ago
Well, how do I do this? I know it can be done, but I'm not sure what approach to take. To this point I've seen some articles including sprites/textures and drawing the outline to a buffer, is this a good approach? I'm currently able to draw text without trouble, but i'm currently just creating an font arial which is pre-installed. And using that to draw. Anyone with some experience here? How do I go about working with fonts and text in directx/direct3d which are not pre-installed, basically from a file (TrueType, OpenType or Raster)...
Advertisement
Quote:Original post by leidegren
How do I go about working with fonts and text in directx/direct3d which are not pre-installed, basically from a file (TrueType, OpenType or Raster)...


Why don't you just install the font with your game instead of going through all the business of parsing font files?

You can temporarily install a font with GDI via AddFontResource or AddFontResourceEx.

My free book on Direct3D: "The Direct3D Graphics Pipeline"
My blog on programming, vintage computing, music, politics, etc.: Legalize Adulthood!

Didn't know such a function existed until now, so many great thanks. However, a similar function found on MSDN AddFontMemResourceEx is more close to what I want.

Remarks:
A font that is added by AddFontMemResourceEx is always private to the process that made the call and is not enumerable.

When the function succeeds, the caller of this function can free the memory pointed to by pbFont because the system has made its own copy of the memory. To remove the fonts that were installed, call RemoveFontMemResourceEx. However, when the process goes away, the system will unload the fonts even if the process did not call RemoveFontMemResource.

Best Regards,

This topic is closed to new replies.

Advertisement