Jump to content
  • Advertisement
Sign in to follow this  
JoMasta

How does one load their own font to use with Direct3D?

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

I am looking to be able to download any font from the internet and place it in my game folder and with a few lines of code load it up and let me use it for my text. I tried using this function with no luck. It seemed to just default to Arial:
HFONT CreateFont(
  int nHeight,               // height of font
  int nWidth,                // average character width
  int nEscapement,           // angle of escapement
  int nOrientation,          // base-line orientation angle
  int fnWeight,              // font weight
  DWORD fdwItalic,           // italic attribute option
  DWORD fdwUnderline,        // underline attribute option
  DWORD fdwStrikeOut,        // strikeout attribute option
  DWORD fdwCharSet,          // character set identifier
  DWORD fdwOutputPrecision,  // output precision
  DWORD fdwClipPrecision,    // clipping precision
  DWORD fdwQuality,          // output quality
  DWORD fdwPitchAndFamily,   // pitch and family
  LPCTSTR lpszFace           // typeface name
);
I assume I am needing a different function. This is also GDI...is that what I should be using for loading it? Any help would be greatly appreciated! Thanks!

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by JoMasta
I am looking to be able to download any font from the internet and place it in my game folder and with a few lines of code load it up and let me use it for my text.

You may well wish to consider the legal implications of doing something like that. A number of fonts tend to have distribution/usage licences that restrict what you can actually do with them. Hopefully won't be a problem for you, but it's worth checking before you get burnt [wink]

You may want to look at ID3DXFont and D3DXCreateFont() or D3DXCreateFontIndirect() as ways of loading fonts and rendering text.

hth
Jack

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!