Jump to content
  • Advertisement
Sign in to follow this  
leidegren

Load font from file, and draw text with that font

This topic is 3885 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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)...

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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,

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!