Sign in to follow this  

Load font from file, and draw text with that font

This topic is 3722 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
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

This topic is 3722 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this