aboutsummaryrefslogtreecommitdiff
path: root/src/libjin/graphics/fonts/font.h
blob: b206a2dd228df9508fe252f1457435b93bbf1f1f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#ifndef __JE_FONT_H__
#define __JE_FONT_H__

#include <vector>

#include "../renderable.h"

#include "text.h"

namespace JinEngine
{
	namespace Graphics
	{
		namespace Fonts
		{

			struct Page;

			//
			// Font 
			//   |- TTF
			//   |- TextureFont
			//

			///
			/// Base Font class.
			///
			class Font : public Object, public Renderable
			{
			public:
				/// 
				/// Font constructor.
				/// 
				Font(unsigned fontsize)
					: mFontSize(fontsize)
				{
					++gl.getStats().fonts;
				}

				/// 
				/// Font destructor.
				/// 
				virtual ~Font() 
				{
					--gl.getStats().fonts;
				};

				/// 
				/// Create page with given text.
				/// 
				/// @param text Text to be typesetted.
				/// @param lineheight Line height of text. 
				/// @param spacing Spacing between characters. 0 by default.
				/// @return Page if created successfully, otherwise return null.
				/// 
				virtual Page* typeset(const Text& text, int lineheight, int spacing = 0) = 0;

				/// 
				/// Create page with given unicode codepoints.
				/// 
				/// @param content Unicode codepoints to be typesetted.
				/// @param lineheight Line height of text. 
				/// @param spacing Spacing between characters. 0 by default.
				/// @return Page if created successfully, otherwise return null.
				/// 
				virtual Page* typeset(const Content& content, int lineheight, int spacing = 0) = 0;

				/// 
				/// Render page to given position.
				/// 
				/// @param page Page to be rendered.
				/// @param x X value of the position. 
				/// @param y Y value of the position.
				/// 
				virtual void render(const Page* page, int x, int y) = 0;

				/// 
				/// Render unicode codepoints to given position.
				/// 
				/// @param content Unicode codepoints to be typesetted.
				/// @param x X value of the position.
				/// @param y Y value of the position. 
				/// @param lineheight Line height of the content. 
				/// @param spacing Spacing between characters.
				/// 
				virtual void render(const Content& content, int x, int y, int lineheight, int spacing = 0) = 0;

				/// 
				/// Render text to given position.
				/// 
				/// @param text Text to be rendered. 
				/// @param x X value of the position. 
				/// @param y Y value of the position.
				/// @param lineheight Line height of the text. 
				/// @param spacing Spacing between characters.
				///
				virtual void render(const Text& text, int x, int y, int lineheight, int spacing = 0) = 0;

				/// 
				/// Get font size.
				/// 
				/// @return Font size.
				/// 
				inline unsigned getFontSize() { return mFontSize; };

			protected:

				unsigned mFontSize;

			};

		} // namespace Fonts
	} // namespace Graphics
} // namespace JinEngine

#endif // __JE_FONT_H__