My Project
SpriteFontEntity.h
1 #pragma once
2 #include "AssetEntity.h"
3 
4 #ifndef DT_TOP
5 
6 #define DT_TOP 0x00000000
7 #define DT_LEFT 0x00000000
8 #define DT_CENTER 0x00000001
9 #define DT_RIGHT 0x00000002
10 #define DT_VCENTER 0x00000004
11 #define DT_BOTTOM 0x00000008
12 #define DT_WORDBREAK 0x00000010
13 #define DT_SINGLELINE 0x00000020
14 #define DT_EXPANDTABS 0x00000040
15 #define DT_TABSTOP 0x00000080
16 #define DT_NOCLIP 0x00000100
17 #define DT_EXTERNALLEADING 0x00000200
18 #define DT_CALCRECT 0x00000400
19 #define DT_NOPREFIX 0x00000800
20 #define DT_INTERNAL 0x00001000
21 #endif
22 
23 namespace ParaEngine
24 {
25  class CSpriteRenderer;
26  struct SpriteFontEntity : public AssetEntity
27  {
28  public:
29  string m_sFontName;
30  int m_nFontSize;
31  int m_nWeight;
32 
33  // a mapping from a logical font name to the real font name(type face name)
34  static map<string, string> g_mapFontNames;
35  public:
36  virtual AssetEntity::AssetType GetType(){ return AssetEntity::font; };
37  public:
38  SpriteFontEntity(const AssetKey& key);
40 
41  virtual ~SpriteFontEntity();
42 
43  virtual HRESULT DrawTextA(CSpriteRenderer* pSprite, const char* strText, int nCount, RECT* rect, DWORD dwTextFormat, DWORD textColor){ return S_OK; };
44  virtual HRESULT DrawTextW(CSpriteRenderer* pSprite, const char16_t* strText, int nCount, RECT* rect, DWORD dwTextFormat, DWORD textColor){ return S_OK; };
45 
46  const std::string& GetFontName() const;
47  int GetFontSize() const;
48 
57  static void AddFontName(const string& sLocalName, const string& sTypeFaceName);
58 
63  static const string& TranslateFontName(const string& sLocalName);
64  };
65 }
66 
67 // chose an implementation as Texture Manager
68 #ifdef USE_DIRECTX_RENDERER
69 #include "SpriteFontEntityDirectX.h"
70 namespace ParaEngine{
72 }
73 #elif defined(USE_OPENGL_RENDERER)
74 #include "SpriteFontEntityOpenGL.h"
75 namespace ParaEngine{
77 }
78 #else
79 namespace ParaEngine{
81 }
82 #endif
static void AddFontName(const string &sLocalName, const string &sTypeFaceName)
give an alias name to a given font name.
Definition: SpriteFontEntity.cpp:44
AssetType
each asset type has a unique asset type number
Definition: AssetEntity.h:82
different physics engine has different winding order.
Definition: EventBinding.h:32
Definition: ManagedDef.h:18
static const string & TranslateFontName(const string &sLocalName)
we will secretly translate the font name, according to font name mapping.
Definition: SpriteFontEntity.cpp:54
AssetManager manages a set of asset entities of a certain type.
Definition: AssetManager.h:13
std::string AssetKey
the unique key object for asset entity.
Definition: AssetEntity.h:13
Base class for managed asset entity in ParaEngine.
Definition: AssetEntity.h:25
base class for sprite renderer
Definition: SpriteRenderer.h:55
Definition: SpriteFontEntity.h:26