aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/api/Text.h
diff options
context:
space:
mode:
authorWBoerenkamps <wrj.boerenkamps@student.avans.nl>2024-12-12 20:45:49 +0100
committerWBoerenkamps <wrj.boerenkamps@student.avans.nl>2024-12-12 20:45:49 +0100
commit431d7cceb25db86f31a8c89440f3cdd2c7bf061f (patch)
treeeb32cf71b0f3fe369cd4509c54b8df960e2765e4 /src/crepe/api/Text.h
parente75e355c3a59d53a1d64fd8fae3331b2234083e2 (diff)
load font almost working
Diffstat (limited to 'src/crepe/api/Text.h')
-rw-r--r--src/crepe/api/Text.h49
1 files changed, 32 insertions, 17 deletions
diff --git a/src/crepe/api/Text.h b/src/crepe/api/Text.h
index d5f47fa..51bab98 100644
--- a/src/crepe/api/Text.h
+++ b/src/crepe/api/Text.h
@@ -9,27 +9,42 @@
#include "UIObject.h"
namespace crepe{
+
+/**
+ * \brief Text UIObject component for displaying text
+ *
+ * This class can be used to display text on screen. By setting the font_family to a font already stored on the current device it will automatically be loaded in.
+ */
class Text : public UIObject{
public:
- Text(game_object_id_t id,const vec2 & dimensions, const vec2 & offset, const Asset & font);
+ Text(game_object_id_t id,const vec2 & dimensions, const vec2 & offset,std::string text,std::string font_family);
+ //! Text data that does not have to be set in the constructor
+ struct Data {
+ //! Label text color.
+ Color text_color = Color::BLACK;
+ /**
+ * \brief fontsize for text rendering
+ *
+ * \note this is not the actual font size that is loaded in.
+ *
+ * Since SDL_TTF requires the font size when loading in the font it is not possible to switch the font size.
+ * The default font size that is loaded is set in the Config.
+ * Instead this value is used to upscale the font texture which can cause blurring or distorted text when upscaling or downscaling too much.
+ */
+ unsigned int font_size = 16;
+ //! Layer sorting level of the text
+ const int sorting_in_layer = 0;
+ //! Order within the sorting text
+ const int order_in_layer = 0;
+ };
+public:
+ //! font family name such as (Arial,Helvetica,Inter)
+ std::string font_family = "";
//! Label text.
- std::string text;
- //! Label text color.
- Color text_color = Color::BLACK;
- /**
- * \brief fontsize for text rendering
- *
- * \note this is not the actual font size that is loaded in.
- *
- * Since SDL_TTF requires the font size when loading in the font it is not possible to switch the font size.
- * The default font size that is loaded is set in the Config.
- * Instead this value is used to upscale the font texture which can cause blurring or distorted text when upscaling or downscaling too much.
- */
- unsigned int font_size = 16;
- //! Font asset
- const Asset source;
-private:
+ std::string text = "";
+ // Data instance for data not gotten from constructor
+ Data data;
};
} // namespace crepe