mirror of
https://github.com/love2d/love.git
synced 2026-08-16 08:11:02 +02:00
Fixed love.graphics.print[f] truncating strings with embedded zeros
This commit is contained in:
@@ -794,16 +794,13 @@ int Graphics::getMaxPointSize() const
|
||||
return (int)max;
|
||||
}
|
||||
|
||||
void Graphics::print(const char *str, float x, float y , float angle, float sx, float sy, float ox, float oy, float kx, float ky)
|
||||
void Graphics::print(const std::string &str, float x, float y , float angle, float sx, float sy, float ox, float oy, float kx, float ky)
|
||||
{
|
||||
if (currentFont != 0)
|
||||
{
|
||||
std::string text(str);
|
||||
currentFont->print(text, x, y, 0.0, angle, sx, sy, ox, oy, kx, ky);
|
||||
}
|
||||
currentFont->print(str, x, y, 0.0, angle, sx, sy, ox, oy, kx, ky);
|
||||
}
|
||||
|
||||
void Graphics::printf(const char *str, float x, float y, float wrap, AlignMode align, float angle, float sx, float sy, float ox, float oy, float kx, float ky)
|
||||
void Graphics::printf(const std::string &str, float x, float y, float wrap, AlignMode align, float angle, float sx, float sy, float ox, float oy, float kx, float ky)
|
||||
{
|
||||
if (currentFont == 0)
|
||||
return;
|
||||
@@ -811,8 +808,7 @@ void Graphics::printf(const char *str, float x, float y, float wrap, AlignMode a
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
string text(str);
|
||||
vector<string> lines_to_draw = currentFont->getWrap(text, wrap);
|
||||
vector<string> lines_to_draw = currentFont->getWrap(str, wrap);
|
||||
|
||||
glPushMatrix();
|
||||
|
||||
|
||||
@@ -386,7 +386,7 @@ public:
|
||||
* @param kx Shear along the x-axis.
|
||||
* @param ky Shear along the y-axis.
|
||||
**/
|
||||
void print(const char *str, float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky);
|
||||
void print(const std::string &str, float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky);
|
||||
|
||||
/**
|
||||
* Draw formatted text on screen at the specified coordinates.
|
||||
@@ -404,7 +404,7 @@ public:
|
||||
* @param kx Shear along the x-axis.
|
||||
* @param ky Shear along the y-axis.
|
||||
**/
|
||||
void printf(const char *str, float x, float y, float wrap, AlignMode align, float angle, float sx, float sy, float ox, float oy, float kx, float ky);
|
||||
void printf(const std::string &str, float x, float y, float wrap, AlignMode align, float angle, float sx, float sy, float ox, float oy, float kx, float ky);
|
||||
|
||||
/**
|
||||
* Draws a point at (x,y).
|
||||
|
||||
@@ -1161,7 +1161,7 @@ int w_drawg(lua_State *L)
|
||||
|
||||
int w_print(lua_State *L)
|
||||
{
|
||||
const char *str = luaL_checkstring(L, 1);
|
||||
std::string str = luax_checkstring(L, 1);
|
||||
float x = (float)luaL_checknumber(L, 2);
|
||||
float y = (float)luaL_checknumber(L, 3);
|
||||
float angle = (float)luaL_optnumber(L, 4, 0.0f);
|
||||
@@ -1184,7 +1184,7 @@ int w_print(lua_State *L)
|
||||
|
||||
int w_printf(lua_State *L)
|
||||
{
|
||||
const char *str = luaL_checkstring(L, 1);
|
||||
std::string str = luax_checkstring(L, 1);
|
||||
float x = (float)luaL_checknumber(L, 2);
|
||||
float y = (float)luaL_checknumber(L, 3);
|
||||
float wrap = (float)luaL_checknumber(L, 4);
|
||||
|
||||
Reference in New Issue
Block a user