mirror of
https://github.com/love2d/love.git
synced 2026-08-22 05:25:11 +02:00
Fail gracefully on a utf-8 decoding error (bug #244)
This commit is contained in:
@@ -149,6 +149,8 @@ namespace opengl
|
|||||||
glTranslatef(ceil(x), ceil(y), 0.0f);
|
glTranslatef(ceil(x), ceil(y), 0.0f);
|
||||||
glRotatef(LOVE_TODEG(angle), 0, 0, 1.0f);
|
glRotatef(LOVE_TODEG(angle), 0, 0, 1.0f);
|
||||||
glScalef(sx, sy, 1.0f);
|
glScalef(sx, sy, 1.0f);
|
||||||
|
try
|
||||||
|
{
|
||||||
utf8::iterator<std::string::iterator> i (text.begin(), text.begin(), text.end());
|
utf8::iterator<std::string::iterator> i (text.begin(), text.begin(), text.end());
|
||||||
utf8::iterator<std::string::iterator> end (text.end(), text.begin(), text.end());
|
utf8::iterator<std::string::iterator> end (text.end(), text.begin(), text.end());
|
||||||
while (i != end) {
|
while (i != end) {
|
||||||
@@ -168,6 +170,12 @@ namespace opengl
|
|||||||
glTranslatef(static_cast<GLfloat>(glyph->spacing), 0, 0);
|
glTranslatef(static_cast<GLfloat>(glyph->spacing), 0, 0);
|
||||||
dx += glyph->spacing;
|
dx += glyph->spacing;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch (utf8::invalid_utf8 e)
|
||||||
|
{
|
||||||
|
glPopMatrix();
|
||||||
|
throw love::Exception(e.what());
|
||||||
|
}
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -759,7 +759,14 @@ namespace opengl
|
|||||||
float angle = (float)luaL_optnumber(L, 4, 0.0f);
|
float angle = (float)luaL_optnumber(L, 4, 0.0f);
|
||||||
float sx = (float)luaL_optnumber(L, 5, 1.0f);
|
float sx = (float)luaL_optnumber(L, 5, 1.0f);
|
||||||
float sy = (float)luaL_optnumber(L, 6, sx);
|
float sy = (float)luaL_optnumber(L, 6, sx);
|
||||||
|
try
|
||||||
|
{
|
||||||
instance->print(str, x, y, angle, sx, sy);
|
instance->print(str, x, y, angle, sx, sy);
|
||||||
|
}
|
||||||
|
catch (love::Exception e)
|
||||||
|
{
|
||||||
|
return luaL_error(L, "Decoding error: %s", e.what());
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -779,7 +786,14 @@ namespace opengl
|
|||||||
return luaL_error(L, "Incorrect alignment: %s", str);
|
return luaL_error(L, "Incorrect alignment: %s", str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
instance->printf(str, x, y, wrap, align);
|
instance->printf(str, x, y, wrap, align);
|
||||||
|
}
|
||||||
|
catch (love::Exception e)
|
||||||
|
{
|
||||||
|
return luaL_error(L, "Decoding error: %s", e.what());
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user