diff --git a/dev/src/draw.cpp b/dev/src/draw.cpp index 86660a5..28fe3b8 100644 --- a/dev/src/draw.cpp +++ b/dev/src/draw.cpp @@ -918,7 +918,7 @@ const GPUTask& olc::Draw::TexturedPolygon(const olc::Structure structure, const ))); } -const GPUTask& olc::Draw::String(const olc::vf2d& pos, const std::string& text, const olc::Pixel col, const olc::vf2d& scale, olc::Font& font) +const GPUTask& olc::Draw::String(const olc::vf2d& pos, std::string_view text, const olc::Pixel col, const olc::vf2d& scale, olc::Font& font) { PrepareTargetForHW(); @@ -949,7 +949,7 @@ const GPUTask& olc::Draw::String(const olc::vf2d& pos, const std::string& text, return Batch(task); } -const GPUTask& olc::Draw::StringProp(const olc::vf2d& pos, const std::string& text, const olc::Pixel col, const olc::vf2d& scale, olc::Font& font) +const GPUTask& olc::Draw::StringProp(const olc::vf2d& pos, std::string_view text, const olc::Pixel col, const olc::vf2d& scale, olc::Font& font) { PrepareTargetForHW(); @@ -979,7 +979,7 @@ const GPUTask& olc::Draw::StringProp(const olc::vf2d& pos, const std::string& te return Batch(task); } -olc::vf2d olc::Draw::GetTextSize(const std::string& text, const bool bProportional, const olc::vf2d& scale, olc::Font& font) +olc::vf2d olc::Draw::GetTextSize(std::string_view text, const bool bProportional, const olc::vf2d& scale, olc::Font& font) { olc::vf2d size = { 0, font.fLineHeight * scale.y }; olc::vf2d pos = { 0, font.fLineHeight * scale.y }; diff --git a/dev/src/draw.h b/dev/src/draw.h index e082107..8ac6fc3 100644 --- a/dev/src/draw.h +++ b/dev/src/draw.h @@ -778,7 +778,7 @@ namespace olc // Draws a string at specified location in monospace font const GPUTask& String( const olc::vf2d& pos, - const std::string& text, + std::string_view text, const olc::Pixel col = olc::Colour::WHITE, const olc::vf2d& scale = { 1.0f, 1.0f }, olc::Font& font = olc::fontClassicPGE); @@ -786,14 +786,14 @@ namespace olc // Draws a string at specified location in proportional font const GPUTask& StringProp( const olc::vf2d& pos, - const std::string& text, + std::string_view text, const olc::Pixel col = olc::Colour::WHITE, const olc::vf2d& scale = { 1.0f, 1.0f }, olc::Font& font = olc::fontClassicPGE); // Returns the bounding box size of a string in pixels olc::vf2d GetTextSize( - const std::string& text, + std::string_view text, const bool bProportional = false, const olc::vf2d& scale = { 1.0f, 1.0f }, olc::Font& font = olc::fontClassicPGE); diff --git a/olcPixelGameEngine3.h b/olcPixelGameEngine3.h index 3725ed0..8ddd763 100644 --- a/olcPixelGameEngine3.h +++ b/olcPixelGameEngine3.h @@ -3454,7 +3454,7 @@ namespace olc // Draws a string at specified location in monospace font const GPUTask& String( const olc::vf2d& pos, - const std::string& text, + std::string_view text, const olc::Pixel col = olc::Colour::WHITE, const olc::vf2d& scale = { 1.0f, 1.0f }, olc::Font& font = olc::fontClassicPGE); @@ -3462,14 +3462,14 @@ namespace olc // Draws a string at specified location in proportional font const GPUTask& StringProp( const olc::vf2d& pos, - const std::string& text, + std::string_view text, const olc::Pixel col = olc::Colour::WHITE, const olc::vf2d& scale = { 1.0f, 1.0f }, olc::Font& font = olc::fontClassicPGE); // Returns the bounding box size of a string in pixels olc::vf2d GetTextSize( - const std::string& text, + std::string_view text, const bool bProportional = false, const olc::vf2d& scale = { 1.0f, 1.0f }, olc::Font& font = olc::fontClassicPGE); @@ -18936,7 +18936,7 @@ const GPUTask& olc::Draw::TexturedPolygon(const olc::Structure structure, const ))); } -const GPUTask& olc::Draw::String(const olc::vf2d& pos, const std::string& text, const olc::Pixel col, const olc::vf2d& scale, olc::Font& font) +const GPUTask& olc::Draw::String(const olc::vf2d& pos, std::string_view text, const olc::Pixel col, const olc::vf2d& scale, olc::Font& font) { PrepareTargetForHW(); @@ -18967,7 +18967,7 @@ const GPUTask& olc::Draw::String(const olc::vf2d& pos, const std::string& text, return Batch(task); } -const GPUTask& olc::Draw::StringProp(const olc::vf2d& pos, const std::string& text, const olc::Pixel col, const olc::vf2d& scale, olc::Font& font) +const GPUTask& olc::Draw::StringProp(const olc::vf2d& pos, std::string_view text, const olc::Pixel col, const olc::vf2d& scale, olc::Font& font) { PrepareTargetForHW(); @@ -18997,7 +18997,7 @@ const GPUTask& olc::Draw::StringProp(const olc::vf2d& pos, const std::string& te return Batch(task); } -olc::vf2d olc::Draw::GetTextSize(const std::string& text, const bool bProportional, const olc::vf2d& scale, olc::Font& font) +olc::vf2d olc::Draw::GetTextSize(std::string_view text, const bool bProportional, const olc::vf2d& scale, olc::Font& font) { olc::vf2d size = { 0, font.fLineHeight * scale.y }; olc::vf2d pos = { 0, font.fLineHeight * scale.y };