16 #include "utils/ColorUtils.h" 24 typedef uint32_t character_t;
25 typedef std::vector<character_t> vecText;
48 constexpr
int FONT_STYLE_NORMAL = 0;
49 constexpr
int FONT_STYLE_BOLD = (1 << 0);
50 constexpr
int FONT_STYLE_ITALICS = (1 << 1);
51 constexpr
int FONT_STYLE_LIGHT = (1 << 2);
52 constexpr
int FONT_STYLE_UPPERCASE = (1 << 3);
53 constexpr
int FONT_STYLE_LOWERCASE = (1 << 4);
54 constexpr
int FONT_STYLE_CAPITALIZE = (1 << 5);
55 constexpr
int FONT_STYLE_MASK = 0xFF;
56 constexpr
int FONT_STYLES_COUNT = 7;
63 int speed = defaultSpeed,
64 const std::string& scrollSuffix =
" | ");
66 void SetSpeed(
int speed) { m_pixelSpeed = speed * 0.001f; }
69 m_waitTime = m_initialWait;
73 m_pixelPos = -m_initialPos;
75 m_averageFrameTime = 1000.f / fabs((
float)defaultSpeed);
82 float GetPixelsPerFrame();
86 unsigned int m_waitTime;
87 unsigned int m_initialWait;
90 mutable float m_textWidth;
91 mutable float m_totalWidth;
92 mutable bool m_widthValid;
94 unsigned int m_loopCount;
96 static const int defaultSpeed = 60;
99 float m_averageFrameTime;
100 uint32_t m_lastFrameTime;
110 CGUIFont(
const std::string& strFontName,
112 UTILS::COLOR::Color textColor,
113 UTILS::COLOR::Color shadowColor,
119 std::string& GetFontName();
121 void DrawText(
float x,
123 UTILS::COLOR::Color color,
124 UTILS::COLOR::Color shadowColor,
129 std::vector<UTILS::COLOR::Color> colors;
130 colors.push_back(color);
131 DrawText(x, y, colors, shadowColor, text, alignment, maxPixelWidth);
134 void DrawText(
float x,
136 const std::vector<UTILS::COLOR::Color>& colors,
137 UTILS::COLOR::Color shadowColor,
140 float maxPixelWidth);
142 void DrawScrollingText(
float x,
144 const std::vector<UTILS::COLOR::Color>& colors,
145 UTILS::COLOR::Color shadowColor,
151 bool UpdateScrollInfo(
const vecText& text,
CScrollInfo& scrollInfo);
153 float GetTextWidth(
const vecText& text);
154 float GetCharWidth(character_t ch);
155 float GetTextHeight(
int numLines)
const;
156 float GetTextBaseLine()
const;
157 float GetLineHeight()
const;
160 float GetScaleFactor()
const;
165 uint32_t GetStyle()
const {
return m_style; }
172 std::string m_strFontName;
174 UTILS::COLOR::Color m_shadowColor;
175 UTILS::COLOR::Color m_textColor;
181 bool ClippedRegionIsEmpty(
182 CGraphicContext& context,
float x,
float y,
float width, uint32_t alignment)
const;
constexpr int XBFONT_LEFT
Align X left.
Definition: GUIFont.h:38
constexpr int XBFONT_CENTER_Y
Align Y center.
Definition: GUIFont.h:41
Definition: GUIFontTTF.h:76
constexpr int XBFONT_TRUNCATED
Truncated text.
Definition: GUIFont.h:42
Definition: LibInputPointer.h:13
constexpr int XBFONT_CENTER_X
Align X center.
Definition: GUIFont.h:40
Definition: GUIFont.h:107
constexpr int XBFONT_RIGHT
Align X right.
Definition: GUIFont.h:39
Definition: GraphicContext.h:60
constexpr int XBFONT_JUSTIFIED
Justify text.
Definition: GUIFont.h:43