- attempt to fix 'blurry fonts'

This commit is contained in:
Mark Vejvoda
2011-06-28 06:18:24 +00:00
parent f5b15bd402
commit ebd5bca7fe
6 changed files with 29 additions and 5 deletions

View File

@@ -334,7 +334,10 @@ int CoreData::computeFontSize(int size) {
rs = size * screenH / 1024; rs = size * screenH / 1024;
} }
else { else {
rs = ((float)size * 0.80); if(Renderer::renderText3DEnabled) {
//rs = ((float)size * 0.85);
//rs = 24;
}
//int screenH = config.getInt("ScreenHeight"); //int screenH = config.getInt("ScreenHeight");
//rs = size * screenH / 1024; //rs = size * screenH / 1024;

View File

@@ -1440,13 +1440,13 @@ void Renderer::renderText(const string &text, Font2D *font, float alpha, int x,
} }
Vec2f Renderer::getCentered3DPos(const string &text, Font3D *font, Vec2f &pos, int w, int h) { Vec2f Renderer::getCentered3DPos(const string &text, Font3D *font, Vec2f &pos, int w, int h) {
float lineWidth = font->getTextHandler()->Advance(text.c_str()); float lineWidth = (font->getTextHandler()->Advance(text.c_str()) * Font::scaleFontValue);
if(lineWidth < w) { if(lineWidth < w) {
pos.x += ((w / 2.f) - (lineWidth / 2.f)); pos.x += ((w / 2.f) - (lineWidth / 2.f));
} }
//h /= 2.f; //h /= 2.f;
float lineHeight = font->getTextHandler()->LineHeight(text.c_str()); float lineHeight = (font->getTextHandler()->LineHeight(text.c_str()) * Font::scaleFontValue);
if(lineHeight < h) { if(lineHeight < h) {
//pos.y += ((float)h / 2.f); //pos.y += ((float)h / 2.f);
//pos.y -= ((float(h) / 2.f) - (lineHeight / 2.f)); //pos.y -= ((float(h) / 2.f) - (lineHeight / 2.f));

View File

@@ -65,6 +65,7 @@ public:
static bool fontIsMultibyte; static bool fontIsMultibyte;
static bool forceLegacyFonts; static bool forceLegacyFonts;
static bool fontIsRightToLeft; static bool fontIsRightToLeft;
static float scaleFontValue;
public: public:
enum Width { enum Width {

View File

@@ -38,6 +38,7 @@ bool Font::fontIsMultibyte = false;
bool Font::forceLegacyFonts = false; bool Font::forceLegacyFonts = false;
float FontMetrics::DEFAULT_Y_OFFSET_FACTOR = 8.0f; float FontMetrics::DEFAULT_Y_OFFSET_FACTOR = 8.0f;
bool Font::fontIsRightToLeft = false; bool Font::fontIsRightToLeft = false;
float Font::scaleFontValue = 0.65;
// //
// ===================================================== // =====================================================

View File

@@ -121,6 +121,11 @@ void TextFTGL::init(string fontName, int fontSize) {
} }
else if(type == ftht_3D) { else if(type == ftht_3D) {
ftFont = new FTGLTextureFont(fontFile); ftFont = new FTGLTextureFont(fontFile);
//ftFont = new FTBufferFont(fontFile);
//ftFont = new FTGLExtrdFont(fontFile);
//ftFont = new FTGLPolygonFont("/usr/share/fonts/truetype/arphic/uming.ttc");
//printf("3D font [%s]\n",fontFile); //printf("3D font [%s]\n",fontFile);
} }
else { else {

View File

@@ -435,7 +435,7 @@ void TextRenderer3DGl::internalRender(const string &text, float x, float y, boo
const unsigned char *utext= NULL; const unsigned char *utext= NULL;
//assertGl(); //assertGl();
glMatrixMode(GL_MODELVIEW); //glMatrixMode(GL_TEXTURE);
//assertGl(); //assertGl();
@@ -518,18 +518,28 @@ void TextRenderer3DGl::internalRender(const string &text, float x, float y, boo
//assertGl(); //assertGl();
float scaleX = Font::scaleFontValue;
float scaleY = Font::scaleFontValue;
float scaleZ = 1.0;
//int scaleWidthX = (font->getTextHandler()->Advance(renderText.c_str()) * scaleX) / 2.0;
//glTranslatef(translatePos.x + scaleWidthX, translatePos.y, translatePos.z);
glTranslatef(translatePos.x, translatePos.y, translatePos.z); glTranslatef(translatePos.x, translatePos.y, translatePos.z);
//assertGl(); //assertGl();
//glScalef(scaleX, scaleY, scaleZ); //glScalef(scaleX, scaleY, scaleZ);
//glTranslatef(0.45, 0.45, 1.0);
//assertGl(); //assertGl();
// font->getTextHandler()->Render(text.c_str()); // font->getTextHandler()->Render(text.c_str());
// specialFTGLErrorCheckWorkaround(text); // specialFTGLErrorCheckWorkaround(text);
if(font->getTextHandler() != NULL) { if(font->getTextHandler() != NULL) {
glScalef(scaleX, scaleY, scaleZ);
if(text.find("\n") == renderText.npos && renderText.find("\t") == renderText.npos) { if(text.find("\n") == renderText.npos && renderText.find("\t") == renderText.npos) {
//assertGl(); //assertGl();
font->getTextHandler()->Render(renderText.c_str()); font->getTextHandler()->Render(renderText.c_str());
@@ -577,7 +587,7 @@ void TextRenderer3DGl::internalRender(const string &text, float x, float y, boo
{ {
line++; line++;
//assertGl(); //assertGl();
float yLineValue = font->getTextHandler()->LineHeight(parts[i].c_str()); float yLineValue = (font->getTextHandler()->LineHeight(parts[i].c_str()) * Font::scaleFontValue);
//assertGl(); //assertGl();
translatePos= Vec3f(translatePos.x, translatePos.y - yLineValue, translatePos.z); translatePos= Vec3f(translatePos.x, translatePos.y - yLineValue, translatePos.z);
needsRecursiveRender = true; needsRecursiveRender = true;
@@ -589,6 +599,7 @@ void TextRenderer3DGl::internalRender(const string &text, float x, float y, boo
glPushMatrix(); glPushMatrix();
glLoadIdentity(); glLoadIdentity();
glTranslatef(translatePos.x, translatePos.y, translatePos.z); glTranslatef(translatePos.x, translatePos.y, translatePos.z);
glScalef(scaleX, scaleY, scaleZ);
font->getTextHandler()->Render(parts[i].c_str()); font->getTextHandler()->Render(parts[i].c_str());
specialFTGLErrorCheckWorkaround(parts[i]); specialFTGLErrorCheckWorkaround(parts[i]);
glPopMatrix(); glPopMatrix();
@@ -646,6 +657,9 @@ void TextRenderer3DGl::internalRender(const string &text, float x, float y, boo
glPopAttrib(); glPopAttrib();
} }
//assertGl();
//glDisable(GL_TEXTURE_2D);
assertGl(); assertGl();
} }