reverted to 2.27 original fontcoloring method
reverted to patched ftgl library. speed improvements were not really noticable.
This commit is contained in:
parent
447dd3c959
commit
ef736e8bcc
@ -28,12 +28,6 @@
|
||||
* ***** END GPL/BL DUAL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
* $Id$
|
||||
* Copyright (C) 2001 NaN Technologies B.V.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -107,7 +101,7 @@ FTF_TTFont::FTF_TTFont(void)
|
||||
char *bundlepath;
|
||||
#endif
|
||||
|
||||
fontB = fontW =NULL;
|
||||
font=NULL;
|
||||
font_size=FONT_SIZE_DEFAULT;
|
||||
strcpy(encoding_name, SYSTEM_ENCODING_DEFAULT);
|
||||
|
||||
@ -145,8 +139,7 @@ FTF_TTFont::FTF_TTFont(void)
|
||||
|
||||
FTF_TTFont::~FTF_TTFont(void)
|
||||
{
|
||||
if (fontB) delete fontB;
|
||||
if (fontW) delete fontW;
|
||||
if (font) delete font;
|
||||
}
|
||||
|
||||
|
||||
@ -155,26 +148,19 @@ int FTF_TTFont::SetFont(char* str, int size)
|
||||
int err = 0;
|
||||
bool success = 0;
|
||||
|
||||
if(fontB) delete fontB;
|
||||
if(fontW) delete fontW;
|
||||
delete font;
|
||||
|
||||
fontB = new FTGLPixmapFont(str);
|
||||
fontW = new FTGLPixmapFont(str);
|
||||
err = fontB->Error();
|
||||
font = new FTGLPixmapFont(str);
|
||||
err = font->Error();
|
||||
|
||||
if(err) {
|
||||
// printf("Failed to open font %s\n", str);
|
||||
return 0;
|
||||
} else {
|
||||
success = fontB->FaceSize(size);
|
||||
if(!success) return 0;
|
||||
success = fontW->FaceSize(size);
|
||||
success = font->FaceSize(size);
|
||||
if(!success) return 0;
|
||||
|
||||
success = fontB->CharMap(ft_encoding_unicode);
|
||||
if(!success) return 0;
|
||||
|
||||
success = fontW->CharMap(ft_encoding_unicode);
|
||||
success = font->CharMap(ft_encoding_unicode);
|
||||
if(!success) return 0;
|
||||
|
||||
return 1;
|
||||
@ -220,8 +206,7 @@ void FTF_TTFont::SetEncoding(char* str)
|
||||
|
||||
void FTF_TTFont::SetSize(int size)
|
||||
{
|
||||
fontB->FaceSize(size);
|
||||
fontW->FaceSize(size);
|
||||
font->FaceSize(size);
|
||||
font_size = size;
|
||||
}
|
||||
|
||||
@ -232,12 +217,12 @@ int FTF_TTFont::GetSize(void)
|
||||
|
||||
int FTF_TTFont::Ascender(void)
|
||||
{
|
||||
return fontB->Ascender();
|
||||
return font->Ascender();
|
||||
}
|
||||
|
||||
int FTF_TTFont::Descender(void)
|
||||
{
|
||||
return fontB->Descender();
|
||||
return font->Descender();
|
||||
}
|
||||
|
||||
|
||||
@ -258,14 +243,20 @@ float FTF_TTFont::DrawString(char* str, unsigned int flag, int select)
|
||||
len=utf8towchar(wstr,str);
|
||||
|
||||
if(!select) {
|
||||
glColor4f(0.0, 0.0, 0.0, 1.0);
|
||||
fontB->Render(wstr);
|
||||
return fontB->Advance(wstr);
|
||||
} else {
|
||||
glColor4f(1.0, 1.0, 1.0, 1.0);
|
||||
fontW->Render(wstr);
|
||||
return fontW->Advance(wstr);
|
||||
glPixelTransferf(GL_RED_SCALE, 0.0);
|
||||
glPixelTransferf(GL_GREEN_SCALE, 0.0);
|
||||
glPixelTransferf(GL_BLUE_SCALE, 0.0);
|
||||
}
|
||||
|
||||
font->Render(wstr);
|
||||
|
||||
if(!select) {
|
||||
glPixelTransferf(GL_RED_SCALE, 1.0);
|
||||
glPixelTransferf(GL_GREEN_SCALE, 1.0);
|
||||
glPixelTransferf(GL_BLUE_SCALE, 1.0);
|
||||
}
|
||||
|
||||
return font->Advance(wstr);
|
||||
}
|
||||
|
||||
|
||||
@ -279,19 +270,17 @@ float FTF_TTFont::DrawStringRGB(char* str, unsigned int flag, float r, float g,
|
||||
else
|
||||
len=utf8towchar(wstr,str);
|
||||
|
||||
glColor4f(1.0, 1.0, 1.0, 1.0);
|
||||
|
||||
glPixelTransferf(GL_RED_SCALE, r);
|
||||
glPixelTransferf(GL_GREEN_SCALE, g);
|
||||
glPixelTransferf(GL_BLUE_SCALE, b);
|
||||
|
||||
fontW->Render(wstr);
|
||||
font->Render(wstr);
|
||||
|
||||
glPixelTransferf(GL_RED_SCALE, 1.0);
|
||||
glPixelTransferf(GL_GREEN_SCALE, 1.0);
|
||||
glPixelTransferf(GL_BLUE_SCALE, 1.0);
|
||||
|
||||
return fontW->Advance(wstr);
|
||||
return font->Advance(wstr);
|
||||
}
|
||||
|
||||
|
||||
@ -305,8 +294,7 @@ float FTF_TTFont::GetStringWidth(char* str, unsigned int flag)
|
||||
else
|
||||
len=utf8towchar(wstr,str);
|
||||
|
||||
glColor4f(0.0, 0.0, 0.0, 1.0);
|
||||
return fontB->Advance(wstr);
|
||||
return font->Advance(wstr);
|
||||
}
|
||||
|
||||
|
||||
@ -320,7 +308,5 @@ void FTF_TTFont::GetBoundingBox(char* str, float *llx, float *lly, float *llz, f
|
||||
else
|
||||
len=utf8towchar(wstr,str);
|
||||
|
||||
glColor4f(0.0, 0.0, 0.0, 1.0);
|
||||
fontB->BBox(wstr, *llx, *lly, *llz, *urx, *ury, *urz);
|
||||
font->BBox(wstr, *llx, *lly, *llz, *urx, *ury, *urz);
|
||||
}
|
||||
|
||||
|
@ -99,8 +99,7 @@ protected:
|
||||
int font_size;
|
||||
|
||||
/** FTGL's */
|
||||
FTFont* fontB;
|
||||
FTFont* fontW;
|
||||
FTFont* font;
|
||||
|
||||
/** from system encoding in .locale to UNICODE */
|
||||
// iconv_t cd;
|
||||
|
Loading…
Reference in New Issue
Block a user