mirror of
https://github.com/glest/glest-source.git
synced 2025-08-18 14:11:15 +02:00
- cleanup of font work:
- removed uneeded code - set default scale font value to 0.8 to fit nicely on screen - added two new optional settings for ini or lng files to control scale and y centering: FONT_SCALE_SIZE=0.8 FONT_SCALE_CENTERH_FACTOR=3.0
This commit is contained in:
@@ -36,12 +36,18 @@ int Font::charCount = 256;
|
||||
std::string Font::fontTypeName = "Times New Roman";
|
||||
bool Font::fontIsMultibyte = false;
|
||||
bool Font::forceLegacyFonts = false;
|
||||
float FontMetrics::DEFAULT_Y_OFFSET_FACTOR = 2.0f;
|
||||
bool Font::fontIsRightToLeft = false;
|
||||
float Font::scaleFontValue = 1.0;
|
||||
|
||||
// This value is used to scale the font text rendering
|
||||
// in 3D render mode
|
||||
float Font::scaleFontValue = 0.80;
|
||||
// This value is used for centering font text vertically (height)
|
||||
float Font::scaleFontValueCenterHFactor = 3.0;
|
||||
//float Font::scaleFontValue = 1.0;
|
||||
//float Font::scaleFontValueCenterHFactor = 4.0;
|
||||
|
||||
int Font::baseSize = 0;
|
||||
int Font::faceResolution = 72;
|
||||
//int Font::scaleFontYOffset = 0;
|
||||
//
|
||||
|
||||
// =====================================================
|
||||
@@ -52,7 +58,6 @@ FontMetrics::FontMetrics(Text *textHandler) {
|
||||
this->textHandler = textHandler;
|
||||
this->widths = new float[Font::charCount];
|
||||
this->height = 0;
|
||||
this->yOffsetFactor = FontMetrics::DEFAULT_Y_OFFSET_FACTOR;
|
||||
|
||||
for(int i=0; i < Font::charCount; ++i) {
|
||||
widths[i]= 0;
|
||||
@@ -64,14 +69,6 @@ FontMetrics::~FontMetrics() {
|
||||
widths = NULL;
|
||||
}
|
||||
|
||||
void FontMetrics::setYOffsetFactor(float yOffsetFactor) {
|
||||
this->yOffsetFactor = yOffsetFactor;
|
||||
}
|
||||
|
||||
float FontMetrics::getYOffsetFactor() const {
|
||||
return this->yOffsetFactor;
|
||||
}
|
||||
|
||||
void FontMetrics::setTextHandler(Text *textHandler) {
|
||||
this->textHandler = textHandler;
|
||||
}
|
||||
@@ -94,7 +91,6 @@ float FontMetrics::getTextWidth(const string &str) {
|
||||
//Treat 2 byte characters as spaces
|
||||
if(str[i] < 0) {
|
||||
width+= (widths[97]); // This is the letter a which is a normal wide character and good to use for spacing
|
||||
//i++;
|
||||
}
|
||||
else {
|
||||
width+= widths[str[i]];
|
||||
@@ -149,14 +145,6 @@ Font::~Font() {
|
||||
textHandler = NULL;
|
||||
}
|
||||
|
||||
void Font::setYOffsetFactor(float yOffsetFactor) {
|
||||
metrics.setYOffsetFactor(yOffsetFactor);
|
||||
}
|
||||
|
||||
float Font::getYOffsetFactor() const {
|
||||
return metrics.getYOffsetFactor();
|
||||
}
|
||||
|
||||
string Font::getType() const {
|
||||
return this->type;
|
||||
}
|
||||
|
@@ -88,7 +88,6 @@ Font3D * ConvertFont2DTo3D(Font2D *font) {
|
||||
Font3D *result = new Font3DGl();
|
||||
result->setSize(font->getSize());
|
||||
result->setType("",font->getType());
|
||||
result->setYOffsetFactor(font->getYOffsetFactor());
|
||||
result->setWidth(font->getWidth());
|
||||
result->init();
|
||||
return result;
|
||||
|
@@ -73,11 +73,11 @@ void TextRenderer2DGl::render(const string &text, float x, float y, bool centere
|
||||
|
||||
if(centered) {
|
||||
rasterPos.x= x - font->getTextHandler()->Advance(renderText.c_str()) / 2.f;
|
||||
rasterPos.y= y + font->getTextHandler()->LineHeight(renderText.c_str()) / font->getYOffsetFactor();
|
||||
rasterPos.y= y + font->getTextHandler()->LineHeight(renderText.c_str()) / 2;
|
||||
}
|
||||
else {
|
||||
rasterPos= Vec2f(static_cast<float>(x), static_cast<float>(y));
|
||||
rasterPos.y= y + (font->getTextHandler()->LineHeight(renderText.c_str()) / font->getYOffsetFactor());
|
||||
rasterPos.y= y + font->getTextHandler()->LineHeight(renderText.c_str());
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
Reference in New Issue
Block a user