MOS
text.hpp
1 #pragma once
2 
3 #include <map>
4 #include <memory>
5 #include <string>
6 
7 #include <mos/gfx/character.hpp>
8 #include <mos/gfx/font.hpp>
9 #include <mos/gfx/mesh.hpp>
10 #include <mos/gfx/model.hpp>
11 
12 namespace mos::gfx {
13 
15 class Text final {
16 public:
17  Text(const std::string &txt, Font font,
18  const glm::mat4 &transform = glm::mat4(1.0f), float spacing = 0.0f,
19  float opacity = 1.0f, float roughness = 1.0f, float metallic = 0.0f,
20  const glm::vec3 &emission = glm::vec3(0.0f));
21 
23  auto text(const std::string &text) -> void;
24 
26  auto text() const -> std::string;
27 
29  auto width() const -> float;
30 
32  auto height() const -> float;
33 
35  auto position(const glm::vec2 &position) -> void;
36 
38  auto position(const glm::vec3 &position) -> void;
39 
41  auto position() const -> glm::vec2;
42 
44  auto scale(float scale) -> void;
45 
47  auto transform(const glm::mat4 &transform) -> void;
48 
50  auto transform() const -> glm::mat4;
51 
53  auto model() const -> Model;
54 
56  auto opacity(float opacity) -> void;
57 
59  auto emission(const glm::vec3 &emission) -> void;
60 
62  auto font() const -> Font;
63 
64  float spacing;
65 
66  auto operator=(const std::string &input) -> Text &;
67 
68  auto operator+=(const std::string &input) -> Text &;
69 
70 private:
71  Model model_;
72  std::string text_;
73  Font font_;
74 };
75 } // namespace mos::gfx
auto height() const -> float
Approximate height.
auto emission(const glm::vec3 &emission) -> void
Set if the text is emissive.
auto transform() const -> glm::mat4
Get transform.
auto position() const -> glm::vec2
Get position.
auto scale(float scale) -> void
Set scale.
auto opacity(float opacity) -> void
Set opacity.
Text for rendering.
Definition: text.hpp:15
Definition: assets.hpp:17
auto text() const -> std::string
Get text.
auto font() const -> Font
Get the font.
Bitmap font.
Definition: font.hpp:10
auto width() const -> float
Approximate width.
auto model() const -> Model
Get model.
Collection of properties for a renderable object.
Definition: model.hpp:24