diff --git a/include/glez/draw.hpp b/include/glez/draw.hpp index 435843d..32272a3 100644 --- a/include/glez/draw.hpp +++ b/include/glez/draw.hpp @@ -22,8 +22,8 @@ void rect_textured(float x, float y, float w, float h, rgba color, float angle); void circle(float x, float y, float radius, rgba color, float thickness, int steps); -void string(float x, float y, const std::string& string, font& font, rgba color, +void string(float x, float y, const std::string& string, const font& font, rgba color, float* width, float* height); -void outlined_string(float x, float y, const std::string& string, font& font, +void outlined_string(float x, float y, const std::string& string, const font& font, rgba color, rgba outline, float* width, float* height); } // namespace glez::draw diff --git a/include/glez/font.hpp b/include/glez/font.hpp index c9b1a89..700bf7e 100644 --- a/include/glez/font.hpp +++ b/include/glez/font.hpp @@ -22,8 +22,8 @@ public: glez::font& operator=(glez::font&&); // void stringSize(std::string_view string, float* width, float* height); - void stringSize(const std::string& string, float* width, float* height); - inline bool isLoaded() { return this->m_font != nullptr && this->atlas != nullptr; }; + void stringSize(const std::string& string, float* width, float* height) const; + inline bool isLoaded() const { return this->m_font != nullptr && this->atlas != nullptr; }; public: texture_font_t* m_font = nullptr; diff --git a/src/draw.cpp b/src/draw.cpp index 79ddb70..699cfa4 100644 --- a/src/draw.cpp +++ b/src/draw.cpp @@ -21,7 +21,7 @@ static GLuint triangle[3] = { 0, 1, 2 }; } // namespace indices void internal_draw_string(float x, float y, const std::string& string, - glez::font& font, glez::rgba color, float* width, float* height) { + const glez::font& font, glez::rgba color, float* width, float* height) { assert(font.isLoaded()); auto* fnt = font.m_font; float pen_x = x; @@ -202,14 +202,14 @@ void circle(float x, float y, float radius, rgba color, float thickness, } } -void string(float x, float y, const std::string& string, font& font, rgba color, float* width, float* height) { +void string(float x, float y, const std::string& string, const font& font, rgba color, float* width, float* height) { auto fnt = font.m_font; fnt->rendermode = RENDER_NORMAL; fnt->outline_thickness = 0.0f; internal_draw_string(x, y, string, font, color, width, height); } -void outlined_string(float x, float y, const std::string& string, font& font, rgba color, rgba outline, float* width, float* height) { +void outlined_string(float x, float y, const std::string& string, const font& font, rgba color, rgba outline, float* width, float* height) { auto fnt = font.m_font; fnt->rendermode = RENDER_OUTLINE_POSITIVE; fnt->outline_thickness = 1.0f; diff --git a/src/font.cpp b/src/font.cpp index fe8cf62..824b46d 100644 --- a/src/font.cpp +++ b/src/font.cpp @@ -36,7 +36,7 @@ glez::font& font::operator=(glez::font&& var) { var.atlas = nullptr; return *this; } -void font::stringSize(const std::string& string, float* width, float* height) { +void font::stringSize(const std::string& string, float* width, float* height) const { assert(this->isLoaded()); float penX = 0;