nngn
Loading...
Searching...
No Matches
text.h
Go to the documentation of this file.
1
#ifndef NNGN_TEXT_H
2
#define NNGN_TEXT_H
3
4
#include <string>
5
6
#include "math/vec2.h"
7
8
#include "
font.h
"
9
10
namespace
nngn
{
11
12
struct
Text
{
13
std::string
str
= {};
14
size_t
cur
= 0,
nlines
= 0;
15
float
spacing
= 0;
16
vec2
size
= {0, 0};
17
constexpr
Text
() =
default
;
18
Text
(
const
Font
&
f
, std::string_view
s
);
19
Text
(
const
Font
&
f
, std::string_view
s
,
size_t
cur
);
20
void
update_cur
(
const
Font
&
f
,
size_t
cur
);
21
void
update_size
(
const
Font
&
f
);
22
static
size_t
count_lines
(std::string_view
s
,
size_t
cur
);
23
static
float
max_width
(
24
const
Font::Characters
&
font
, std::string_view
s
,
size_t
cur
);
25
};
26
27
inline
Text::Text
(
const
Font
&
f
, std::string_view
s
)
28
:
Text
(
f
,
s
,
s
.size()) {}
29
inline
Text::Text
(
const
Font
&
f
, std::string_view
s
,
size_t
c
)
30
:
str
(
s
), spacing(static_cast<
float
>(
f
.size) / 4.0f)
31
{ this->
update_cur
(f,
c
); }
32
33
}
34
35
#endif
c
c
Definition:
gamma.lua:11
font
font
Definition:
repl.lua:1
float
precision highp float
Definition:
common.h:15
f
function f()) end
s
std::chrono::seconds s
Definition:
timing.cpp:6
nngn
Definition:
audio.cpp:7
nngn::str
std::string str(const static_vector< S > &v)
Definition:
static_vector_test.cpp:32
font.h
nngn::Font
Definition:
font.h:18
nngn::Font::Characters
std::array< Character, N > Characters
Definition:
font.h:25
nngn::Text
Definition:
text.h:12
nngn::Text::Text
constexpr Text()=default
nngn::Text::spacing
float spacing
Definition:
text.h:15
nngn::Text::nlines
size_t nlines
Definition:
text.h:14
nngn::Text::str
std::string str
Definition:
text.h:13
nngn::Text::size
vec2 size
Definition:
text.h:16
nngn::Text::count_lines
static size_t count_lines(std::string_view s, size_t cur)
nngn::Text::cur
size_t cur
Definition:
text.h:14
nngn::Text::update_size
void update_size(const Font &f)
Definition:
text.cpp:17
nngn::Text::max_width
static float max_width(const Font::Characters &font, std::string_view s, size_t cur)
nngn::Text::update_cur
void update_cur(const Font &f, size_t cur)
nngn::vec2_base< float >
master
src
font
text.h
Generated by
1.9.6