mirror of
https://github.com/glest/glest-source.git
synced 2025-02-24 19:52:25 +01:00
- attempt to fix 'blurry fonts'
This commit is contained in:
parent
f5b15bd402
commit
ebd5bca7fe
@ -334,7 +334,10 @@ int CoreData::computeFontSize(int size) {
|
||||
rs = size * screenH / 1024;
|
||||
}
|
||||
else {
|
||||
rs = ((float)size * 0.80);
|
||||
if(Renderer::renderText3DEnabled) {
|
||||
//rs = ((float)size * 0.85);
|
||||
//rs = 24;
|
||||
}
|
||||
//int screenH = config.getInt("ScreenHeight");
|
||||
//rs = size * screenH / 1024;
|
||||
|
||||
|
@ -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) {
|
||||
float lineWidth = font->getTextHandler()->Advance(text.c_str());
|
||||
float lineWidth = (font->getTextHandler()->Advance(text.c_str()) * Font::scaleFontValue);
|
||||
if(lineWidth < w) {
|
||||
pos.x += ((w / 2.f) - (lineWidth / 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) {
|
||||
//pos.y += ((float)h / 2.f);
|
||||
//pos.y -= ((float(h) / 2.f) - (lineHeight / 2.f));
|
||||
|
@ -65,6 +65,7 @@ public:
|
||||
static bool fontIsMultibyte;
|
||||
static bool forceLegacyFonts;
|
||||
static bool fontIsRightToLeft;
|
||||
static float scaleFontValue;
|
||||
|
||||
public:
|
||||
enum Width {
|
||||
|
@ -38,6 +38,7 @@ bool Font::fontIsMultibyte = false;
|
||||
bool Font::forceLegacyFonts = false;
|
||||
float FontMetrics::DEFAULT_Y_OFFSET_FACTOR = 8.0f;
|
||||
bool Font::fontIsRightToLeft = false;
|
||||
float Font::scaleFontValue = 0.65;
|
||||
//
|
||||
|
||||
// =====================================================
|
||||
|
@ -121,6 +121,11 @@ void TextFTGL::init(string fontName, int fontSize) {
|
||||
}
|
||||
else if(type == ftht_3D) {
|
||||
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);
|
||||
}
|
||||
else {
|
||||
|
@ -435,7 +435,7 @@ void TextRenderer3DGl::internalRender(const string &text, float x, float y, boo
|
||||
const unsigned char *utext= NULL;
|
||||
//assertGl();
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
//glMatrixMode(GL_TEXTURE);
|
||||
|
||||
//assertGl();
|
||||
|
||||
@ -518,18 +518,28 @@ void TextRenderer3DGl::internalRender(const string &text, float x, float y, boo
|
||||
|
||||
//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);
|
||||
|
||||
//assertGl();
|
||||
|
||||
//glScalef(scaleX, scaleY, scaleZ);
|
||||
|
||||
|
||||
//glTranslatef(0.45, 0.45, 1.0);
|
||||
|
||||
//assertGl();
|
||||
|
||||
// font->getTextHandler()->Render(text.c_str());
|
||||
// specialFTGLErrorCheckWorkaround(text);
|
||||
|
||||
if(font->getTextHandler() != NULL) {
|
||||
glScalef(scaleX, scaleY, scaleZ);
|
||||
if(text.find("\n") == renderText.npos && renderText.find("\t") == renderText.npos) {
|
||||
//assertGl();
|
||||
font->getTextHandler()->Render(renderText.c_str());
|
||||
@ -577,7 +587,7 @@ void TextRenderer3DGl::internalRender(const string &text, float x, float y, boo
|
||||
{
|
||||
line++;
|
||||
//assertGl();
|
||||
float yLineValue = font->getTextHandler()->LineHeight(parts[i].c_str());
|
||||
float yLineValue = (font->getTextHandler()->LineHeight(parts[i].c_str()) * Font::scaleFontValue);
|
||||
//assertGl();
|
||||
translatePos= Vec3f(translatePos.x, translatePos.y - yLineValue, translatePos.z);
|
||||
needsRecursiveRender = true;
|
||||
@ -589,6 +599,7 @@ void TextRenderer3DGl::internalRender(const string &text, float x, float y, boo
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
glTranslatef(translatePos.x, translatePos.y, translatePos.z);
|
||||
glScalef(scaleX, scaleY, scaleZ);
|
||||
font->getTextHandler()->Render(parts[i].c_str());
|
||||
specialFTGLErrorCheckWorkaround(parts[i]);
|
||||
glPopMatrix();
|
||||
@ -646,6 +657,9 @@ void TextRenderer3DGl::internalRender(const string &text, float x, float y, boo
|
||||
glPopAttrib();
|
||||
}
|
||||
|
||||
//assertGl();
|
||||
//glDisable(GL_TEXTURE_2D);
|
||||
|
||||
assertGl();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user