forked from EasyRPG/Player
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtext.h
130 lines (119 loc) · 4.51 KB
/
text.h
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/*
* This file is part of EasyRPG Player.
*
* EasyRPG Player is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* EasyRPG Player is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with EasyRPG Player. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef EP_TEXT_H
#define EP_TEXT_H
#include "point.h"
#include "system.h"
#include "memory_management.h"
#include "rect.h"
#include "color.h"
#include "string_view.h"
#include <string>
class Font;
class Bitmap;
namespace Text {
/** TextDraw alignment options. */
enum Alignment {
/** Align text to the left. */
AlignLeft,
/** Align text to the center. */
AlignCenter,
/** Align text to the right. */
AlignRight
};
/**
* Draws the text onto dest bitmap with given parameters.
*
* @param dest the bitmap to render to.
* @param x X offset to render text.
* @param y Y offset to render text.
* @param font the font used to render.
* @param system the system graphic to use to render.
* @param color which color from the system graphic to use.
* @param text the utf8 / exfont text to render.
* @param align the text alignment to use
*
* @return Where to draw the next glyph when continuing drawing. See Font::GlyphRet.advance
*/
Point Draw(Bitmap& dest, int x, int y, const Font& font, const Bitmap& system, int color, StringView text, Text::Alignment align = Text::AlignLeft);
/**
* Draws the text onto dest bitmap with given parameters. Does not draw a shadow.
*
* @param dest the bitmap to render to.
* @param x X offset to render text.
* @param y Y offset to render text.
* @param font the font used to render.
* @param color which color to use.
* @param text the utf8 / exfont text to render.
*
* @return Where to draw the next glyph when continuing drawing. See Font::GlyphRet.advance
*/
Point Draw(Bitmap& dest, int x, int y, const Font& font, Color color, StringView text);
/**
* Draws the character onto dest bitmap with given parameters.
*
* @param dest the bitmap to render to.
* @param x X offset to render text.
* @param y Y offset to render text.
* @param font the font used to render.
* @param system the system graphic to use to render.
* @param color which color from the system graphic to use.
* @param ch the character to render.
* @param is_exfont if true, treat ch as an exfont character. Otherwise, a utf32 character.
*
* @return Where to draw the next glyph when continuing drawing. See Font::GlyphRet.advance
*/
Point Draw(Bitmap& dest, int x, int y, const Font& font, const Bitmap& system, int color, char32_t glyph, bool is_exfont);
/**
* Draws the character onto dest bitmap with given parameters. Does not draw a shadow.
*
* @param dest the bitmap to render to.
* @param x X offset to render text.
* @param y Y offset to render text.
* @param font the font used to render.
* @param color which color to use.
* @param ch the character to render.
* @param is_exfont if true, treat ch as an exfont character. Otherwise, a utf32 character.
*
* @return Where to draw the next glyph when continuing drawing. See Font::GlyphRet.advance
*/
Point Draw(Bitmap& dest, int x, int y, const Font& font, Color color, char32_t glyph, bool is_exfont);
/**
* Determines the size of a bitmap required to render a string.
* The dimensions of the Rect describe a bounding box to fit the text.
* For continuous rendering use the "width" property.
*
* @param font the font used to render.
* @param text the string to measure.
*
* @return Rect describing the rendered string boundary
*/
Rect GetSize(const Font& font, StringView text);
/**
* Determines the size of a bitmap required to render a single character.
* The dimensions of the Rect describe a bounding box to fit the character.
* For continuous rendering use the "width" property.
*
* @param font the font used to render.
* @param glyph the character to mesaure.
* @param is_exfont if true, treat ch as an exfont character. Otherwise, a utf32 character.
*
* @return Rect describing the rendered string boundary
*/
Rect GetSize(const Font& font, char32_t glyph, bool is_exfont);
}
#endif