diff --git a/include/Color.hpp b/include/Color.hpp index edf6b200..fdb25f7a 100644 --- a/include/Color.hpp +++ b/include/Color.hpp @@ -159,15 +159,35 @@ class Color : public ::Color { ::DrawLineStrip(points, numPoints, *this); } + void DrawText(const char* text, int posX = 0, int posY = 0, int fontSize = 10.0f) const { + ::DrawText(text, posX, posY, fontSize, *this); + } + void DrawText(const std::string& text, int posX = 0, int posY = 0, int fontSize = 10.0f) const { ::DrawText(text.c_str(), posX, posY, fontSize, *this); } + void DrawText(const ::Font& font, const char* text, ::Vector2 position, + float fontSize, float spacing) const { + ::DrawTextEx(font, text, position, fontSize, spacing, *this); + } + void DrawText(const ::Font& font, const std::string& text, ::Vector2 position, float fontSize, float spacing) const { ::DrawTextEx(font, text.c_str(), position, fontSize, spacing, *this); } + void DrawText( + const ::Font& font, + const char* text, + ::Vector2 position, + ::Vector2 origin, + float rotation, + float fontSize, + float spacing) const { + ::DrawTextPro(font, text, position, origin, rotation, fontSize, spacing, *this); + } + void DrawText( const ::Font& font, const std::string& text, diff --git a/include/Font.hpp b/include/Font.hpp index 7ac33dd0..60c119b0 100644 --- a/include/Font.hpp +++ b/include/Font.hpp @@ -210,6 +210,14 @@ class Font : public ::Font { return ::IsFontReady(*this); } + /** + * Draw text using font and additional parameters. + */ + void DrawText(const char* text, ::Vector2 position, float fontSize, + float spacing, ::Color tint = WHITE) const { + ::DrawTextEx(*this, text, position, fontSize, spacing, tint); + } + /** * Draw text using font and additional parameters. */ @@ -218,6 +226,16 @@ class Font : public ::Font { ::DrawTextEx(*this, text.c_str(), position, fontSize, spacing, tint); } + /** + * Draw text using font and additional parameters. + */ + void DrawText(const char* text, int posX, int posY, float fontSize, + float spacing, ::Color tint = WHITE) const { + ::DrawTextEx(*this, text, + { static_cast(posX), static_cast(posY) }, + fontSize, spacing, tint); + } + /** * Draw text using font and additional parameters. */ @@ -228,6 +246,20 @@ class Font : public ::Font { fontSize, spacing, tint); } + void DrawText( + const char* text, + ::Vector2 position, + ::Vector2 origin, + float rotation, + float fontSize, + float spacing, + ::Color tint = WHITE) const { + ::DrawTextPro(*this, text, + position, origin, + rotation, fontSize, + spacing, tint); + } + void DrawText( const std::string& text, ::Vector2 position, @@ -265,6 +297,13 @@ class Font : public ::Font { spacing, tint); } + /** + * Measure string size for Font + */ + Vector2 MeasureText(const char* text, float fontSize, float spacing) const { + return ::MeasureTextEx(*this, text, fontSize, spacing); + } + /** * Measure string size for Font */ @@ -279,6 +318,14 @@ class Font : public ::Font { return ::GetGlyphIndex(*this, character); } + /** + * Create an image from text (custom sprite font) + */ + ::Image ImageText(const char* text, float fontSize, + float spacing, ::Color tint) const { + return ::ImageTextEx(*this, text, fontSize, spacing, tint); + } + /** * Create an image from text (custom sprite font) */ diff --git a/include/Functions.hpp b/include/Functions.hpp index ddae8a50..ae67c7f5 100644 --- a/include/Functions.hpp +++ b/include/Functions.hpp @@ -240,18 +240,41 @@ namespace raylib { /** * Draw text (using default font) */ - [[maybe_unused]] RLCPPAPI inline void DrawText(const std::string& text, int posX, int posY, int fontSize, ::Color color) { +[[maybe_unused]] RLCPPAPI inline void DrawText(const char* text, int posX, int posY, int fontSize, ::Color color) { + ::DrawText(text, posX, posY, fontSize, color); +} + +/** + * Draw text (using default font) + */ +[[maybe_unused]] RLCPPAPI inline void DrawText(const std::string& text, int posX, int posY, int fontSize, ::Color color) { ::DrawText(text.c_str(), posX, posY, fontSize, color); } /** * Draw text using font and additional parameters */ - [[maybe_unused]] RLCPPAPI inline void DrawTextEx(const Font& font, const std::string& text, Vector2 position, +[[maybe_unused]] RLCPPAPI inline void DrawTextEx(const Font& font, char* text, Vector2 position, + float fontSize, float spacing, ::Color tint) { + ::DrawTextEx(font, text, position, fontSize, spacing, tint); +} + +/** + * Draw text using font and additional parameters + */ +[[maybe_unused]] RLCPPAPI inline void DrawTextEx(const Font& font, const std::string& text, Vector2 position, float fontSize, float spacing, ::Color tint) { ::DrawTextEx(font, text.c_str(), position, fontSize, spacing, tint); } +/** + * Draw text using Font and pro parameters (rotation) + */ +[[maybe_unused]] RLCPPAPI inline void DrawTextPro(const Font& font, const char* text, Vector2 position, + Vector2 origin, float rotation, float fontSize, float spacing, ::Color tint) { + ::DrawTextPro(font, text, position, origin, rotation, fontSize, spacing, tint); +} + /** * Draw text using Font and pro parameters (rotation) */ @@ -277,10 +300,24 @@ namespace raylib { /** * Measure string width for default font */ - [[maybe_unused]] RLCPPAPI inline int MeasureText(const std::string& text, int fontSize) { +[[maybe_unused]] RLCPPAPI inline int MeasureText(const char* text, int fontSize) { + return ::MeasureText(text, fontSize); +} + +/** + * Measure string width for default font + */ +[[maybe_unused]] RLCPPAPI inline int MeasureText(const std::string& text, int fontSize) { return ::MeasureText(text.c_str(), fontSize); } +/** + * Check if two text string are equal + */ +[[maybe_unused]] RLCPPAPI inline bool TextIsEqual(const char* text1, const char* text2) { + return ::TextIsEqual(text1, text2); +} + /** * Check if two text string are equal */ @@ -288,6 +325,13 @@ namespace raylib { return ::TextIsEqual(text1.c_str(), text2.c_str()); } +/** + * Check if two text string are equal + */ +[[maybe_unused]] RLCPPAPI inline unsigned int TextLength(const char* text) { + return ::TextLength(text); +} + /** * Check if two text string are equal */ diff --git a/include/Image.hpp b/include/Image.hpp index a000c730..00a4c8e6 100644 --- a/include/Image.hpp +++ b/include/Image.hpp @@ -645,6 +645,16 @@ class Image : public ::Image { ::ImageDraw(this, src, srcRec, dstRec, tint); } + void DrawText(const char* text, ::Vector2 position, int fontSize, + ::Color color = {255, 255, 255, 255}) { + ::ImageDrawText(this, + text, + static_cast(position.x), + static_cast(position.y), + fontSize, + color); + } + void DrawText(const std::string& text, ::Vector2 position, int fontSize, ::Color color = {255, 255, 255, 255}) { ::ImageDrawText(this, @@ -660,11 +670,21 @@ class Image : public ::Image { ::ImageDrawText(this, text.c_str(), x, y, fontSize, color); } + void DrawText(const char* text, int x, int y, int fontSize, + ::Color color = {255, 255, 255, 255}) { + ::ImageDrawText(this, text, x, y, fontSize, color); + } + void DrawText(const ::Font& font, const std::string& text, ::Vector2 position, float fontSize, float spacing, ::Color tint = {255, 255, 255, 255}) { ::ImageDrawTextEx(this, font, text.c_str(), position, fontSize, spacing, tint); } + void DrawText(const ::Font& font, const char* text, ::Vector2 position, + float fontSize, float spacing, ::Color tint = {255, 255, 255, 255}) { + ::ImageDrawTextEx(this, font, text, position, fontSize, spacing, tint); + } + /** * Load color data from image as a Color array (RGBA - 32bit) */