mirror of
https://github.com/love2d/love.git
synced 2026-08-17 19:23:38 +02:00
Added vrld's text-rotation-fixing patch (finally fixes #56)
This commit is contained in:
@@ -1451,7 +1451,14 @@
|
|||||||
isa = PBXProject;
|
isa = PBXProject;
|
||||||
buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "love" */;
|
buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "love" */;
|
||||||
compatibilityVersion = "Xcode 3.1";
|
compatibilityVersion = "Xcode 3.1";
|
||||||
|
developmentRegion = English;
|
||||||
hasScannedForEncodings = 1;
|
hasScannedForEncodings = 1;
|
||||||
|
knownRegions = (
|
||||||
|
English,
|
||||||
|
Japanese,
|
||||||
|
French,
|
||||||
|
German,
|
||||||
|
);
|
||||||
mainGroup = 29B97314FDCFA39411CA2CEA /* love */;
|
mainGroup = 29B97314FDCFA39411CA2CEA /* love */;
|
||||||
projectDirPath = "";
|
projectDirPath = "";
|
||||||
projectRoot = "";
|
projectRoot = "";
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ namespace opengl
|
|||||||
|
|
||||||
void Font::print(std::string text, float x, float y, float angle, float sx, float sy) const
|
void Font::print(std::string text, float x, float y, float angle, float sx, float sy) const
|
||||||
{
|
{
|
||||||
|
float dx = 0.0f; // spacing counter for newline handling
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
|
|
||||||
glTranslatef(ceil(x), ceil(y), 0.0f);
|
glTranslatef(ceil(x), ceil(y), 0.0f);
|
||||||
@@ -74,12 +75,18 @@ namespace opengl
|
|||||||
glScalef(sx, sy, 1.0f);
|
glScalef(sx, sy, 1.0f);
|
||||||
for (unsigned int i = 0; i < text.size(); i++) {
|
for (unsigned int i = 0; i < text.size(); i++) {
|
||||||
unsigned char g = (unsigned char)text[i];
|
unsigned char g = (unsigned char)text[i];
|
||||||
|
if (g == '\n') { // wrap newline, but do not print it
|
||||||
|
glTranslatef(-dx, round(getHeight()), 0);
|
||||||
|
dx = 0.0f;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (!glyphs[g]) g = 32; // space
|
if (!glyphs[g]) g = 32; // space
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glTranslatef(0, round(getHeight()), 0);
|
glTranslatef(0, round(getHeight()), 0);
|
||||||
glyphs[g]->draw(0, 0, 0, 1, 1, 0, 0);
|
glyphs[g]->draw(0, 0, 0, 1, 1, 0, 0);
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
glTranslatef(spacing[g], 0, 0);
|
glTranslatef(spacing[g], 0, 0);
|
||||||
|
dx += spacing[g];
|
||||||
}
|
}
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -700,97 +700,23 @@ namespace opengl
|
|||||||
return (int)max;
|
return (int)max;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Graphics::print( const char * str, float x, float y )
|
void Graphics::print( const char * str, float x, float y)
|
||||||
{
|
{
|
||||||
if(currentFont != 0)
|
if(currentFont != 0)
|
||||||
{
|
{
|
||||||
std::string text(str);
|
std::string text(str);
|
||||||
|
currentFont->print(text, x, y);
|
||||||
if(text.find("\n") == std::string::npos)
|
|
||||||
currentFont->print(text, x, y);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
int lines = 0;
|
|
||||||
text = "";
|
|
||||||
|
|
||||||
for(unsigned int i = 0; i < strlen(str); i++)
|
|
||||||
{
|
|
||||||
if(str[i] == '\n')
|
|
||||||
{
|
|
||||||
currentFont->print(text, x, y + (lines * currentFont->getHeight() * currentFont->getLineHeight()));
|
|
||||||
text = "";
|
|
||||||
lines++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
text += str[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
if(text != "") // Print the last text (if applicable).
|
|
||||||
currentFont->print(text, x, y + (lines * currentFont->getHeight() * currentFont->getLineHeight()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Graphics::print( const char * str, float x, float y , float angle)
|
void Graphics::print( const char * str, float x, float y, float angle)
|
||||||
{
|
{
|
||||||
if(currentFont != 0)
|
print(str, x, y, angle, 1, 1);
|
||||||
{
|
|
||||||
std::string text(str);
|
|
||||||
|
|
||||||
if(text.find("\n") == std::string::npos)
|
|
||||||
currentFont->print(text, x, y, angle, 1, 1);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
int lines = 0;
|
|
||||||
text = "";
|
|
||||||
|
|
||||||
for(unsigned int i = 0; i < strlen(str); i++)
|
|
||||||
{
|
|
||||||
if(str[i] == '\n')
|
|
||||||
{
|
|
||||||
currentFont->print(text, x, y + (lines * currentFont->getHeight() * currentFont->getLineHeight()), angle, 1, 1);
|
|
||||||
text = "";
|
|
||||||
lines++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
text += str[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
if(text != "") // Print the last text (if applicable).
|
|
||||||
currentFont->print(text, x, y + (lines * currentFont->getHeight() * currentFont->getLineHeight()), angle, 1, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Graphics::print( const char * str, float x, float y , float angle, float s)
|
void Graphics::print( const char * str, float x, float y, float angle, float s)
|
||||||
{
|
{
|
||||||
if(currentFont != 0)
|
print(str, x, y, angle, s, s);
|
||||||
{
|
|
||||||
std::string text(str);
|
|
||||||
|
|
||||||
if(text.find("\n") == std::string::npos)
|
|
||||||
currentFont->print(text, x, y, angle, s, s);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
int lines = 0;
|
|
||||||
text = "";
|
|
||||||
|
|
||||||
for(unsigned int i = 0; i < strlen(str); i++)
|
|
||||||
{
|
|
||||||
if(str[i] == '\n')
|
|
||||||
{
|
|
||||||
currentFont->print(text, x, y + (lines * currentFont->getHeight() * currentFont->getLineHeight() * s), angle, s, s);
|
|
||||||
text = "";
|
|
||||||
lines++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
text += str[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
if(text != "") // Print the last text (if applicable).
|
|
||||||
currentFont->print(text, x, y + (lines * currentFont->getHeight() * currentFont->getLineHeight() * s), angle, s, s);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Graphics::print( const char * str, float x, float y , float angle, float sx, float sy)
|
void Graphics::print( const char * str, float x, float y , float angle, float sx, float sy)
|
||||||
@@ -798,29 +724,7 @@ namespace opengl
|
|||||||
if(currentFont != 0)
|
if(currentFont != 0)
|
||||||
{
|
{
|
||||||
std::string text(str);
|
std::string text(str);
|
||||||
|
currentFont->print(text, x, y, angle, sx, sy);
|
||||||
if(text.find("\n") == std::string::npos)
|
|
||||||
currentFont->print(text, x, y, angle, sx, sy);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
int lines = 0;
|
|
||||||
text = "";
|
|
||||||
|
|
||||||
for(unsigned int i = 0; i < strlen(str); i++)
|
|
||||||
{
|
|
||||||
if(str[i] == '\n')
|
|
||||||
{
|
|
||||||
currentFont->print(text, x, y + (lines * currentFont->getHeight() * currentFont->getLineHeight() * sy), angle, sx, sy);
|
|
||||||
text = "";
|
|
||||||
lines++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
text += str[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
if(text != "") // Print the last text (if applicable).
|
|
||||||
currentFont->print(text, x, y + (lines * currentFont->getHeight() * currentFont->getLineHeight() * sy), angle, sx, sy);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user