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