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-2020 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
9#include <memory>
10#include <string>
11#include <vector>
12
13namespace jngl {
14
16enum class Alignment { LEFT, RIGHT, CENTER };
17
18class Font;
19class FontImpl;
20class Line;
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
43private:
46 Alignment align = Alignment::LEFT;
47};
48
49} // namespace jngl
Contains jngl::Drawable 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:19
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.
Definition: Achievement.hpp:10
Alignment
How multiple lines should be aligned in a text block.
Definition: text.hpp:16