All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
FontRenderer.h
1 // Copyright eeGeo Ltd (2012-2014), All Rights Reserved
2 
3 #pragma once
4 
5 #include "Types.h"
6 #include "Fonts.h"
7 #include "Text.h"
8 #include "VectorMathDecl.h"
9 #include "DebugRendering.h"
10 #include "IRenderableFilter.h"
11 #include <vector>
12 
13 namespace Eegeo
14 {
15  namespace Fonts
16  {
18  {
19  public:
20 
21  FontRenderer (Eegeo::Text::IScreenTextRenderer& screenTextRenderer);
22  ~FontRenderer ();
23 
24  void SetFont(const FontInstance* pFont) { m_pFont = pFont; }
25 
26  void Print (float x, float y, float z, const char* text, Eegeo::v4* pColor, u32 alignment, float scaling = 1.0f);
27  void Print (float x, float y, float z, const char* text, u32 rgba, u32 alignment, float scalingX = 1.0f, float scalingY = 1.0f);
28 
29  void PrintMultiLine (float x, float y, float z, const char* text, u32 rgba, u32 alignment, float screenHeight, float scalingX = 1.0f, float scalingY = 1.0f);
30 
31  void PrintMultiLineClipped (float x, float y, float z, const char* text, u32 rgba, u32 alignment, float minY, float MaxY, float scalingX = 1.0f, float scalingY = 1.0f);
32 
33  void PrintML (float x, float y, float z, const char *text, Eegeo::v4* pColor, u32 alignment);
34  float PrintBox (float x, float y, float z, float width, const char *text, u32 color, u32 alignment, bool bCalcHeightNoDraw, float scalingX = 1.0f, float scalingY = 1.0f);
35 
36  private:
37  int FindTextChar (const char *text, int start, int length, int ch);
38  void InternalPrint (float x, float y, float z, const char *text, u32 rgba, int count, float spacing, float scaleX, float scaleY);
39 
40  float GetHorizontalAlign(const char *textUtf8, int length, u32 alignment, float scaleX) const;
41  float GetVerticalAlign(u32 alignment, float scaleY) const;
42 
43  Eegeo::Text::IScreenTextRenderer& m_screenTextRenderer;
44  const FontInstance* m_pFont;
45 
46  std::vector<u32> m_unicodeCharactersScatch;
47  };
48 
49  inline void FontRenderer::PrintMultiLine(float x, float y, float z, const char* text, u32 rgba, u32 alignment, float screenHeight, float scalingX, float scalingY)
50  {
51  PrintMultiLineClipped(x, y, z, text, rgba, alignment, 0.0f, screenHeight, scalingX, scalingY);
52  }
53  }
54 
55 }