?? font.h
字號:
//--------------------------------------------------
// Desc: Texture Font
// Date: 2006.11.03 /update
// Author: artsylee
//
// Copyright (C) 2006 artsylee
//
// 擴展: 增加簡單字體(2006_11_16)
// 簡單字體的紋理大小可變(2006_11_21)
// GFont字體的紋理可變,數量可變(2006_11_22)
// GFont::Update函數,刪除無用字體紋理(2006_11_22)
// 條件編譯紋理大小是否為2的N次方,以支持某些低端顯卡(GeforceMX440)(2007_3_7)
//
//--------------------------------------------------
#ifndef _FONT_
#define _FONT_
#include <map>
#include <Windows.h>
class CFontTexture;
class CTextureManager;
typedef std::map<DWORD, CFontTexture*> FontTextureMap;
typedef FontTextureMap::iterator FontTextureItor;
typedef FontTextureMap::value_type FontTextureValue;
#define FONTUPDATETIME 3000
#define FONTMAXEXIST 2000
class ASE_DLL GFont
{
public:
GFont();
virtual ~GFont();
void Release();
bool CreateFont(const char *szFontName, DWORD height, DWORD width = 0, DWORD weight = FW_NORMAL);
void SetLineCount(DWORD dwCount);
void SetLineHeight(DWORD dwLineHeight) { m_LineHeight = dwLineHeight; }
RECT GetStringRect(const char *pString);
RECT GetStringRectMultiLine(const char *pString);
// one line
void DrawSingleLine(int x, int y, DWORD color, bool bCenter, const char *pString, ...);
// multi lines & fomat
int DrawText(int x, int y, DWORD color, const char *pString, ...);
void Update();
protected:
DWORD GetIdleTexture();
void TextOut(int x, int y, DWORD color, const char *pString);
protected:
HFONT m_hFont;
FontTextureMap m_FontTextureMap;
DWORD m_UpdateTime;
char m_FontFamily[32];
DWORD m_FontWidth;
DWORD m_FontHeight;
DWORD m_FontWeight;
DWORD m_LineCount; //一行的文字數 中文=m_LineCount/2
DWORD m_LineHeight; //行間距
};
class ASE_DLL CSimFont
{
public:
CSimFont();
virtual ~CSimFont();
bool CreateFont(int nHeight, int nWidth, int nEscapement, int nOrientation,
int fnWeight, DWORD fdwItalic, DWORD fdwUnderline, DWORD fdwStrikeOut,
DWORD fdwOutputPrecision, DWORD fdwClipPrecision, DWORD fdwQuality,
DWORD fdwPitchAndFamily, LPCTSTR lpszFace);
bool CreateFont(char * szFontName, DWORD height, DWORD width = 0, DWORD weight = FW_NORMAL);
void DrawText(int x, int y, DWORD color, bool bCenter, char * pString, ...);
RECT GetStringRect(char * pString);
protected:
void TextOut(int x, int y, DWORD color, char * pString);
protected:
HFONT m_hFont;
CFontTexture* m_pfTexture;
DWORD m_texHandle;
};
#endif // _FONT_
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -