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

Started by
1 comment, last by jollyjeffers 18 years, 3 months ago
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!
Advertisement
google cache: form posting

bam done.

If you have any futher questions kick them out! =)
^sf.
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

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

This topic is closed to new replies.

Advertisement