aboutsummaryrefslogtreecommitdiff
path: root/src/graphics/Text.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/graphics/Text.cpp')
-rw-r--r--src/graphics/Text.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/graphics/Text.cpp b/src/graphics/Text.cpp
index b3a32da..49829e6 100644
--- a/src/graphics/Text.cpp
+++ b/src/graphics/Text.cpp
@@ -7,19 +7,19 @@ extern "C" {
namespace mgl {
Text::Text() : font(nullptr) {
- mgl_text_init(&text, nullptr, nullptr, 0, nullptr);
+ mgl_text_init(&text, nullptr, nullptr, 0);
}
Text::Text(std::string str, Font &font) : Text(std::move(str), vec2f(0.0f, 0.0f), font) {}
Text::Text(std::string str, vec2f position, Font &font) : font(&font), str(std::move(str)) {
- mgl_text_init(&text, font.internal_font(), this->str.c_str(), this->str.size(), nullptr);
+ mgl_text_init(&text, font.internal_font(), this->str.c_str(), this->str.size());
mgl_text_set_position(&text, { position.x, position.y });
}
Text::Text(const Text &other) {
font = other.font;
- mgl_text_init(&text, font ? font->internal_font() : nullptr, other.str.c_str(), other.str.size(), nullptr);
+ mgl_text_init(&text, font ? font->internal_font() : nullptr, other.str.c_str(), other.str.size());
mgl_text_set_position(&text, { other.text.position.x, other.text.position.y });
}
@@ -39,9 +39,10 @@ namespace mgl {
return { text.position.x, text.position.y };
}
- // TODO: Implement
- FloatRect Text::get_local_bounds() {
- return FloatRect();
+ FloatRect Text::get_bounds() const {
+ mgl_vec2f bounds = mgl_text_get_bounds(&text);
+ FloatRect rect(get_position(), { bounds.x, bounds.y });
+ return rect;
}
void Text::set_string(std::string str) {