JNGL
Easy to use cross-platform 2D game library
Loading...
Searching...
No Matches
text.hpp
Go to the documentation of this file.
1// Copyright 2012-2024 Jan Niklas Hasse <jhasse@bixense.com>
2// For conditions of distribution and use, see copyright notice in LICENSE.txt
4
5#pragma once
6
7#include "Drawable.hpp"
8#include "Mat3.hpp"
9
10#include <memory>
11#include <string>
12#include <vector>
13
14namespace jngl {
15
17enum class Alignment : uint8_t { LEFT, RIGHT, CENTER };
18
19class Font;
20class FontImpl;
21
23class Text : public Drawable {
24public:
26 explicit Text(const std::string& text = "");
27
29 void setText(const std::string&);
30
32 void setFont(Font&);
33
36
38 void step() override;
39
41 void draw() const override;
42 void draw(Mat3 modelview) const;
43
44private:
45 class Line;
48 Alignment align = Alignment::LEFT;
49};
50
51} // namespace jngl
Contains jngl::Drawable class.
Contains jngl::Mat3 class.
Base class for drawable objects with a position and a rectangle size.
Definition Drawable.hpp:12
Font loaded from a TTF or OTF file.
Definition font.hpp:20
3x3 matrix
Definition Mat3.hpp:18
Rectangle shaped text block.
Definition text.hpp:23
void draw() const override
Simply draws the Text object.
Text(const std::string &text="")
Constructor, text may contain \n newlines.
void setAlign(Alignment)
Alignment of this text block.
void setText(const std::string &)
The text to display (may contain \n newlines)
void step() override
Does nothing.
void setFont(Font &)
Font family.
JNGL's main namespace.
Alignment
How multiple lines should be aligned in a text block.
Definition text.hpp:17
jngl::Mat3 modelview()
Returns a copy of the global ModelView matrix.