D3DXCreateFont function

Creates a font object for a device and font.

Syntax

HRESULT D3DXCreateFont(
  _In_  LPDIRECT3DDEVICE9 pDevice,
  _In_  INT               Height,
  _In_  UINT              Width,
  _In_  UINT              Weight,
  _In_  UINT              MipLevels,
  _In_  BOOL              Italic,
  _In_  DWORD             CharSet,
  _In_  DWORD             OutputPrecision,
  _In_  DWORD             Quality,
  _In_  DWORD             PitchAndFamily,
  _In_  LPCTSTR           pFacename,
  _Out_ LPD3DXFONT        *ppFont
);

Parameters

pDevice [in]

Type: LPDIRECT3DDEVICE9

Pointer to an IDirect3DDevice9 interface, the device to be associated with the font object.

Height [in]

Type: INT

The height of the characters in logical units.

Width [in]

Type: UINT

The width of the characters in logical units.

Weight [in]

Type: UINT

Typeface weight. One example is bold.

MipLevels [in]

Type: UINT

The number of mipmap levels.

Italic [in]

Type: BOOL

True for italic font, false otherwise.

CharSet [in]

Type: DWORD

The character set of the font.

OutputPrecision [in]

Type: DWORD

Specifies how Windows should attempt to match the desired font sizes and characteristics with actual fonts. Use OUT_TT_ONLY_PRECIS for instance, to ensure that you always get a TrueType font.

Quality [in]

Type: DWORD

Specifies how Windows should match the desired font with a real font. It applies to raster fonts only and should not affect TrueType fonts.

PitchAndFamily [in]

Type: DWORD

Pitch and family index.

pFacename [in]

Type: LPCTSTR

String containing the typeface name. If the compiler settings require Unicode, the data type LPCTSTR resolves to LPCWSTR. Otherwise, the string data type resolves to LPCSTR. See Remarks.

ppFont [out]

Type: LPD3DXFONT*

Returns a pointer to an ID3DXFont interface, representing the created font object.

Return value

Type: HRESULT

If the function succeeds, the return value is S_OK. If the function fails, the return value can be one of the following: D3DERR_INVALIDCALL, D3DXERR_INVALIDDATA, E_OUTOFMEMORY.

Remarks

The creation of an ID3DXFont object requires that the device supports 32-bit color.

The compiler setting also determines the function version. If Unicode is defined, the function call resolves to D3DXCreateFontW. Otherwise, the function call resolves to D3DXCreateFontA because ANSI strings are being used.

If you want more information about font parameters, see The Logical Font.

Requirements

Requirement Value
Header
D3dx9core.h
Library
D3dx9.lib

See also

General Purpose Functions