mirror of
https://github.com/glest/glest-source.git
synced 2025-08-18 22:21:18 +02:00
- fixed newline font calc for non english languages
This commit is contained in:
@@ -186,7 +186,8 @@ float TextFreetypeGL::Advance(const wchar_t* str, const int len) {
|
|||||||
|
|
||||||
for(unsigned int i = 0; i < wcslen(str); ++i) {
|
for(unsigned int i = 0; i < wcslen(str); ++i) {
|
||||||
TextureGlyph *glyph = texture_font_get_glyph( font, str[i] );
|
TextureGlyph *glyph = texture_font_get_glyph( font, str[i] );
|
||||||
result += glyph->width;
|
//result += glyph->width;
|
||||||
|
result += glyph->advance_x;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -196,17 +197,37 @@ float TextFreetypeGL::Advance(const char* str, const int len) {
|
|||||||
|
|
||||||
for(unsigned int i = 0; i < strlen(str); ++i) {
|
for(unsigned int i = 0; i < strlen(str); ++i) {
|
||||||
TextureGlyph *glyph = texture_font_get_glyph( font, str[i] );
|
TextureGlyph *glyph = texture_font_get_glyph( font, str[i] );
|
||||||
result += glyph->width;
|
//result += glyph->width;
|
||||||
|
result += glyph->advance_x;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
float TextFreetypeGL::LineHeight(const char* str, const int len) {
|
float TextFreetypeGL::LineHeight(const char* str, const int len) {
|
||||||
float result = 0;
|
float result = 0;
|
||||||
if(strlen(str) > 0) {
|
|
||||||
TextureGlyph *glyph = texture_font_get_glyph( font, str[0] );
|
// for multibyte - we can't rely on sizeof(T) == character
|
||||||
|
FreetypeGLUnicodeStringItr<unsigned char> ustr((const unsigned char *)str);
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
if((len < 0 && *ustr) || (len >= 0 && i < len)) {
|
||||||
|
unsigned int prevChar = (i > 0 ? *ustr-1 : 0);
|
||||||
|
unsigned int thisChar = *ustr++;
|
||||||
|
unsigned int nextChar = *ustr;
|
||||||
|
|
||||||
|
TextureGlyph *glyph = texture_font_get_glyph( font, thisChar );
|
||||||
result = (float)glyph->height;
|
result = (float)glyph->height;
|
||||||
|
|
||||||
|
//printf("#1 LineHeight [%s] result = %f\n",str,result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if(str[0] == '\n') {
|
||||||
|
// TextureGlyph *glyph2 = texture_font_get_glyph( font, str[0] );
|
||||||
|
// float result2 = (float)glyph2->height;
|
||||||
|
//
|
||||||
|
// printf("#2 LineHeight [%s] result = %f result2 = %f\n",str,result,result2);
|
||||||
|
// }
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -215,6 +236,7 @@ float TextFreetypeGL::LineHeight(const wchar_t* str, const int len) {
|
|||||||
if(wcslen(str) > 0) {
|
if(wcslen(str) > 0) {
|
||||||
TextureGlyph *glyph = texture_font_get_glyph( font, str[0] );
|
TextureGlyph *glyph = texture_font_get_glyph( font, str[0] );
|
||||||
result = (float)glyph->height;
|
result = (float)glyph->height;
|
||||||
|
//result = (float)glyph->advance_y;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@@ -557,7 +557,7 @@ void TextRenderer3DGl::internalRender(const string &text, float x, float y, boo
|
|||||||
float scaleZ = 1.0;
|
float scaleZ = 1.0;
|
||||||
|
|
||||||
glScalef(scaleX, scaleY, scaleZ);
|
glScalef(scaleX, scaleY, scaleZ);
|
||||||
if(text.find("\n") == renderText.npos && renderText.find("\t") == renderText.npos) {
|
if(renderText.find("\n") == renderText.npos && renderText.find("\t") == renderText.npos) {
|
||||||
//assertGl();
|
//assertGl();
|
||||||
font->getTextHandler()->Render(renderText.c_str());
|
font->getTextHandler()->Render(renderText.c_str());
|
||||||
specialFTGLErrorCheckWorkaround(renderText);
|
specialFTGLErrorCheckWorkaround(renderText);
|
||||||
@@ -604,8 +604,13 @@ void TextRenderer3DGl::internalRender(const string &text, float x, float y, boo
|
|||||||
{
|
{
|
||||||
line++;
|
line++;
|
||||||
//assertGl();
|
//assertGl();
|
||||||
float yLineValue = (font->getTextHandler()->LineHeight(parts[i].c_str()) * Font::scaleFontValue);
|
//float yLineValue = (font->getTextHandler()->LineHeight(parts[i].c_str()) * Font::scaleFontValue);
|
||||||
|
//float yLineValue = (font->getTextHandler()->LineHeight("W") * Font::scaleFontValue);
|
||||||
|
float yLineValue = font->getTextHandler()->LineHeight("W");
|
||||||
//assertGl();
|
//assertGl();
|
||||||
|
|
||||||
|
//printf("Trying to render newline [%s] i = %d yLineValue = %f font->getTextHandler()->LineHeight(parts[i].c_str()) = %f\n",renderText.c_str(),i,yLineValue,font->getTextHandler()->LineHeight(parts[i].c_str()));
|
||||||
|
|
||||||
translatePos= Vec3f(translatePos.x, translatePos.y - yLineValue, translatePos.z);
|
translatePos= Vec3f(translatePos.x, translatePos.y - yLineValue, translatePos.z);
|
||||||
needsRecursiveRender = true;
|
needsRecursiveRender = true;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user