mirror of
https://github.com/glest/glest-source.git
synced 2025-02-25 12:12:25 +01:00
bugfixes for proper horizontal rendering of multibyte fonts
This commit is contained in:
parent
31fafe4528
commit
3ef4692b23
@ -168,6 +168,7 @@ Font::Font(FontTextHandlerType type) {
|
|||||||
if(Font::forceFTGLFonts == false) {
|
if(Font::forceFTGLFonts == false) {
|
||||||
textHandler = NULL;
|
textHandler = NULL;
|
||||||
textHandler = new TextFreetypeGL(type);
|
textHandler = new TextFreetypeGL(type);
|
||||||
|
//printf("TextFreetypeGL is ON\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
@ -178,6 +179,8 @@ Font::Font(FontTextHandlerType type) {
|
|||||||
|
|
||||||
textHandler = NULL;
|
textHandler = NULL;
|
||||||
textHandler = new TextFTGL(type);
|
textHandler = new TextFTGL(type);
|
||||||
|
//printf("TextFTGL is ON\n");
|
||||||
|
|
||||||
TextFTGL::faceResolution = Font::faceResolution;
|
TextFTGL::faceResolution = Font::faceResolution;
|
||||||
TextFTGL::langHeightText = Font::langHeightText;
|
TextFTGL::langHeightText = Font::langHeightText;
|
||||||
}
|
}
|
||||||
|
@ -228,6 +228,8 @@ int TextFTGL::GetFaceSize() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TextFTGL::Render(const char* str, const int len) {
|
void TextFTGL::Render(const char* str, const int len) {
|
||||||
|
//printf("Render TextFTGL\n");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
FTGL renders the whole string when len == 0
|
FTGL renders the whole string when len == 0
|
||||||
but we don't want any text rendered then.
|
but we don't want any text rendered then.
|
||||||
|
@ -93,6 +93,8 @@ void TextFreetypeGL::Render(const char* str, const int len) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//printf("Render TextFreetypeGL\n");
|
||||||
|
|
||||||
Pen pen ;
|
Pen pen ;
|
||||||
pen.x = 0; pen.y = 0;
|
pen.x = 0; pen.y = 0;
|
||||||
|
|
||||||
@ -196,11 +198,23 @@ float TextFreetypeGL::Advance(const wchar_t* str, const int len) {
|
|||||||
float TextFreetypeGL::Advance(const char* str, const int len) {
|
float TextFreetypeGL::Advance(const char* str, const int len) {
|
||||||
float result = 0;
|
float result = 0;
|
||||||
|
|
||||||
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;
|
||||||
|
// }
|
||||||
|
// for multibyte - we can't rely on sizeof(T) == character
|
||||||
|
FreetypeGLUnicodeStringItr<unsigned char> ustr((const unsigned char *)str);
|
||||||
|
|
||||||
|
for(int i = 0; (len < 0 && *ustr) || (len >= 0 && i < len); i++) {
|
||||||
|
unsigned int prevChar = (i > 0 ? *ustr-1 : 0);
|
||||||
|
unsigned int thisChar = *ustr++;
|
||||||
|
unsigned int nextChar = *ustr;
|
||||||
|
|
||||||
|
// Get glyph (build it if needed
|
||||||
|
TextureGlyph *glyph = texture_font_get_glyph( this->font, thisChar );
|
||||||
result += glyph->advance_x;
|
result += glyph->advance_x;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user