// Font.h: interface for the Font class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_FONT_H__A12FAE35_B9E9_4628_9960_AA6E6C1908B7__INCLUDED_)
#define AFX_FONT_H__A12FAE35_B9E9_4628_9960_AA6E6C1908B7__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <tchar.h>
#include <D3D9.h>

// Font creation flags
#define D3DFONT_BOLD        0x0001
#define D3DFONT_ITALIC      0x0002

// Font rendering flags
#define D3DFONT_CENTERED    0x0001
#define D3DFONT_TWOSIDED    0x0002
#define D3DFONT_FILTERED    0x0004

class Font  
{
private:
    TCHAR   m_strFontName[80];            // Font properties
    DWORD   m_dwFontHeight;
    DWORD   m_dwFontFlags;

    LPDIRECT3DDEVICE9       m_pd3dDevice; // A D3DDevice used for rendering
    LPDIRECT3DTEXTURE9      m_pTexture;   // The d3d texture for this font
    LPDIRECT3DVERTEXBUFFER9 m_pVB;        // VertexBuffer for rendering text
    DWORD   m_dwTexWidth;                 // Texture dimensions
    DWORD   m_dwTexHeight;
    FLOAT   m_fTextScale;
    FLOAT   m_fTexCoords[128-32][4];

public:
    // 2D and 3D text drawing functions
    HRESULT DrawText( FLOAT x, FLOAT y, DWORD dwColor, 
                      TCHAR* strText, DWORD dwFlags=0L );
    HRESULT DrawTextScaled( FLOAT x, FLOAT y, FLOAT z, 
                            FLOAT fXScale, FLOAT fYScale, DWORD dwColor, 
                            TCHAR* strText, DWORD dwFlags=0L );
    HRESULT Render3DText( TCHAR* strText, DWORD dwFlags=0L );
    
    // Function to get extent of text
    HRESULT GetTextExtent( TCHAR* strText, SIZE* pSize );

	HRESULT InvalidateDeviceObjects();
	HRESULT RestoreDeviceObjects( LPDIRECT3DDEVICE9 pd3dDevice );
	HRESULT InitDeviceObjects( LPDIRECT3DDEVICE9 pd3dDevice );

	int getCharacterHeight(){return m_dwFontHeight;}

	// Constructor / destructor
	Font( TCHAR* strFontName, DWORD dwHeight, DWORD dwFlags=0L );
	virtual ~Font();
	void Cleanup();

};

#endif // !defined(AFX_FONT_H__A12FAE35_B9E9_4628_9960_AA6E6C1908B7__INCLUDED_)
