Visual Computing Library
Loading...
Searching...
No Matches
text_metrics.h
1/*
2* Copyright 2013 Jeremie Roy. All rights reserved.
3* License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE
4*/
5
6#ifndef VCL_BGFX_TEXT_FONT_TEXT_METRICS_H
7#define VCL_BGFX_TEXT_FONT_TEXT_METRICS_H
8
9#include "font_manager.h"
10
11namespace bgfx {
12
13class TextMetrics
14{
15public:
16 TextMetrics(FontManager* _fontManager);
17
19 void appendText(FontHandle _fontHandle, const char* _string);
20
22 void appendText(FontHandle _fontHandle, const wchar_t* _string);
23
25 float getWidth() const { return m_width; }
26
28 float getHeight() const { return m_height; }
29
31 void clearText();
32
33private:
34 FontManager* m_fontManager;
35 float m_width;
36 float m_height;
37 float m_x;
38 float m_lineHeight;
39 float m_lineGap;
40};
41
43class TextLineMetrics
44{
45public:
46 TextLineMetrics(const FontInfo& _fontInfo);
47
49 float getLineHeight() const { return m_lineHeight; }
50
52 uint32_t getLineCount(const bx::StringView& _string) const;
53
55 void getSubText(const bx::StringView& _str, uint32_t _firstLine, uint32_t _lastLine, const char*& _begin, const char*& _end);
56
57private:
58 float m_lineHeight;
59};
60
61} // namespace bgfx
62
63#endif // VCL_BGFX_TEXT_FONT_TEXT_METRICS_H