Skip to content

Commit 621eb03

Browse files
committed
text get size
1 parent 4cb8140 commit 621eb03

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

include/Util/Text.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class Text : public Core::Drawable {
1717
Text(const std::string &font, int size, const std::string &text);
1818

1919
void Draw(const Transform &transform, const float zIndex) override;
20-
glm::vec2 GetSize() override;
20+
glm::vec2 GetSize() override { return m_Size; };
2121

2222
private:
2323
void InitProgram();

src/Util/Text.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ Text::Text(const std::string &font, int size, const std::string &text) {
3939
m_Surface->format->BytesPerPixel,
4040
m_Surface->pitch / m_Surface->format->BytesPerPixel, m_Surface->h,
4141
m_Surface->pixels);
42-
m_Size = {m_Surface->w, m_Surface->h};
42+
m_Size = {m_Surface->pitch / m_Surface->format->BytesPerPixel,
43+
m_Surface->h};
4344
}
4445

4546
void Text::Draw(const Util::Transform &transform, const float zIndex) {
@@ -113,10 +114,6 @@ void Text::InitUniformBuffer(const Util::Transform &transform,
113114
s_UniformBuffer->SetData(0, data);
114115
}
115116

116-
glm::vec2 Text::GetSize() {
117-
return m_Size;
118-
}
119-
120117
std::unique_ptr<Core::Program> Text::s_Program = nullptr;
121118
std::unique_ptr<Core::VertexArray> Text::s_VertexArray = nullptr;
122119
std::unique_ptr<Core::UniformBuffer<Core::Matrices>> Text::s_UniformBuffer =

0 commit comments

Comments
 (0)