mirror of
https://github.com/glest/glest-source.git
synced 2025-08-18 06:01:17 +02:00
- pre-calc font height for ftgl and optionally allow for language specific characters to be used
This commit is contained in:
@@ -2562,6 +2562,7 @@ int glestMain(int argc, char** argv) {
|
|||||||
Font::baseSize = config.getInt("FONT_BASE_SIZE",intToStr(Font::baseSize).c_str());
|
Font::baseSize = config.getInt("FONT_BASE_SIZE",intToStr(Font::baseSize).c_str());
|
||||||
Font::scaleFontValue = config.getFloat("FONT_SCALE_SIZE",floatToStr(Font::scaleFontValue).c_str());
|
Font::scaleFontValue = config.getFloat("FONT_SCALE_SIZE",floatToStr(Font::scaleFontValue).c_str());
|
||||||
Font::scaleFontValueCenterHFactor = config.getFloat("FONT_SCALE_CENTERH_FACTOR",floatToStr(Font::scaleFontValueCenterHFactor).c_str());
|
Font::scaleFontValueCenterHFactor = config.getFloat("FONT_SCALE_CENTERH_FACTOR",floatToStr(Font::scaleFontValueCenterHFactor).c_str());
|
||||||
|
Font::langHeightText = config.getString("FONT_HEIGHT_TEXT",Font::langHeightText.c_str());
|
||||||
|
|
||||||
// Example values:
|
// Example values:
|
||||||
// DEFAULT_CHARSET (English) = 1
|
// DEFAULT_CHARSET (English) = 1
|
||||||
@@ -2664,6 +2665,10 @@ int glestMain(int argc, char** argv) {
|
|||||||
Font::scaleFontValueCenterHFactor = strToFloat(lang.get("FONT_SCALE_CENTERH_FACTOR"));
|
Font::scaleFontValueCenterHFactor = strToFloat(lang.get("FONT_SCALE_CENTERH_FACTOR"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( lang.hasString("FONT_HEIGHT_TEXT")) {
|
||||||
|
Font::langHeightText = config.getString("FONT_HEIGHT_TEXT",Font::langHeightText.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
if( lang.hasString("FONT_CHARCOUNT")) {
|
if( lang.hasString("FONT_CHARCOUNT")) {
|
||||||
// 256 for English
|
// 256 for English
|
||||||
// 30000 for Chinese
|
// 30000 for Chinese
|
||||||
@@ -2716,6 +2721,10 @@ int glestMain(int argc, char** argv) {
|
|||||||
Font::scaleFontValueCenterHFactor = strToFloat(lang.get("FONT_SCALE_CENTERH_FACTOR_WINDOWS"));
|
Font::scaleFontValueCenterHFactor = strToFloat(lang.get("FONT_SCALE_CENTERH_FACTOR_WINDOWS"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( lang.hasString("FONT_HEIGHT_TEXT_WINDOWS")) {
|
||||||
|
Font::langHeightText = config.getString("FONT_HEIGHT_TEXT_WINDOWS",Font::langHeightText.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
if( lang.hasString("FONT_CHARCOUNT_WINDOWS")) {
|
if( lang.hasString("FONT_CHARCOUNT_WINDOWS")) {
|
||||||
// 256 for English
|
// 256 for English
|
||||||
// 30000 for Chinese
|
// 30000 for Chinese
|
||||||
|
@@ -69,6 +69,7 @@ public:
|
|||||||
static float scaleFontValueCenterHFactor;
|
static float scaleFontValueCenterHFactor;
|
||||||
static int baseSize;
|
static int baseSize;
|
||||||
static int faceResolution;
|
static int faceResolution;
|
||||||
|
static string langHeightText;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum Width {
|
enum Width {
|
||||||
|
@@ -28,6 +28,7 @@ class TextFTGL : public Text
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
static string langHeightText;
|
||||||
static int faceResolution;
|
static int faceResolution;
|
||||||
|
|
||||||
TextFTGL(FontTextHandlerType type);
|
TextFTGL(FontTextHandlerType type);
|
||||||
|
@@ -47,7 +47,18 @@ float Font::scaleFontValueCenterHFactor = 3.0;
|
|||||||
//float Font::scaleFontValueCenterHFactor = 4.0;
|
//float Font::scaleFontValueCenterHFactor = 4.0;
|
||||||
|
|
||||||
int Font::baseSize = 0;
|
int Font::baseSize = 0;
|
||||||
|
|
||||||
|
#ifdef USE_FTGL
|
||||||
|
|
||||||
|
int Font::faceResolution = TextFTGL::faceResolution;
|
||||||
|
string Font::langHeightText = TextFTGL::langHeightText;
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
int Font::faceResolution = 72;
|
int Font::faceResolution = 72;
|
||||||
|
string Font::langHeightText = "yW";
|
||||||
|
|
||||||
|
#endif
|
||||||
//
|
//
|
||||||
|
|
||||||
// =====================================================
|
// =====================================================
|
||||||
@@ -126,7 +137,9 @@ Font::Font(FontTextHandlerType type) {
|
|||||||
try {
|
try {
|
||||||
textHandler = NULL;
|
textHandler = NULL;
|
||||||
textHandler = new TextFTGL(type);
|
textHandler = new TextFTGL(type);
|
||||||
TextFTGL::faceResolution = faceResolution;
|
TextFTGL::faceResolution = Font::faceResolution;
|
||||||
|
TextFTGL::langHeightText = Font::langHeightText;
|
||||||
|
|
||||||
metrics.setTextHandler(this->textHandler);
|
metrics.setTextHandler(this->textHandler);
|
||||||
}
|
}
|
||||||
catch(exception &ex) {
|
catch(exception &ex) {
|
||||||
|
@@ -32,7 +32,8 @@ using namespace Shared::PlatformCommon;
|
|||||||
namespace Shared { namespace Graphics { namespace Gl {
|
namespace Shared { namespace Graphics { namespace Gl {
|
||||||
|
|
||||||
|
|
||||||
int TextFTGL::faceResolution = 72;
|
string TextFTGL::langHeightText = "yW";
|
||||||
|
int TextFTGL::faceResolution = 72;
|
||||||
|
|
||||||
//====================================================================
|
//====================================================================
|
||||||
TextFTGL::TextFTGL(FontTextHandlerType type) : Text(type) {
|
TextFTGL::TextFTGL(FontTextHandlerType type) : Text(type) {
|
||||||
@@ -232,9 +233,12 @@ float TextFTGL::LineHeight(const char* str, const int len) {
|
|||||||
//return ftFont->Ascender() + ftFont->Descender()*-1 - ftFont->LineHeight();
|
//return ftFont->Ascender() + ftFont->Descender()*-1 - ftFont->LineHeight();
|
||||||
//return ftFont->LineHeight();
|
//return ftFont->LineHeight();
|
||||||
|
|
||||||
FTBBox box = ftFont->BBox("yW");
|
static float result = -1000;
|
||||||
float result = box.Upper().Y()- box.Lower().Y();
|
if(result == -1000) {
|
||||||
//printf("ftFont->BBox(''yW'')%f\n",result);
|
FTBBox box = ftFont->BBox(TextFTGL::langHeightText.c_str());
|
||||||
|
result = box.Upper().Y()- box.Lower().Y();
|
||||||
|
//printf("ftFont->BBox(''yW'')%f\n",result);
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
// printf("For str [%s] LineHeight = %f, result = %f\n",str, ftFont->LineHeight(),result);
|
// printf("For str [%s] LineHeight = %f, result = %f\n",str, ftFont->LineHeight(),result);
|
||||||
// return result;
|
// return result;
|
||||||
|
Reference in New Issue
Block a user