- pre-calc font height for ftgl and optionally allow for language specific characters to be used
This commit is contained in:
parent
a1ab98d4b9
commit
cb98df354d
|
@ -2562,6 +2562,7 @@ int glestMain(int argc, char** argv) {
|
|||
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::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:
|
||||
// DEFAULT_CHARSET (English) = 1
|
||||
|
@ -2664,6 +2665,10 @@ int glestMain(int argc, char** argv) {
|
|||
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")) {
|
||||
// 256 for English
|
||||
// 30000 for Chinese
|
||||
|
@ -2716,6 +2721,10 @@ int glestMain(int argc, char** argv) {
|
|||
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")) {
|
||||
// 256 for English
|
||||
// 30000 for Chinese
|
||||
|
|
|
@ -69,6 +69,7 @@ public:
|
|||
static float scaleFontValueCenterHFactor;
|
||||
static int baseSize;
|
||||
static int faceResolution;
|
||||
static string langHeightText;
|
||||
|
||||
public:
|
||||
enum Width {
|
||||
|
|
|
@ -28,6 +28,7 @@ class TextFTGL : public Text
|
|||
{
|
||||
public:
|
||||
|
||||
static string langHeightText;
|
||||
static int faceResolution;
|
||||
|
||||
TextFTGL(FontTextHandlerType type);
|
||||
|
|
|
@ -47,7 +47,18 @@ float Font::scaleFontValueCenterHFactor = 3.0;
|
|||
//float Font::scaleFontValueCenterHFactor = 4.0;
|
||||
|
||||
int Font::baseSize = 0;
|
||||
|
||||
#ifdef USE_FTGL
|
||||
|
||||
int Font::faceResolution = TextFTGL::faceResolution;
|
||||
string Font::langHeightText = TextFTGL::langHeightText;
|
||||
|
||||
#else
|
||||
|
||||
int Font::faceResolution = 72;
|
||||
string Font::langHeightText = "yW";
|
||||
|
||||
#endif
|
||||
//
|
||||
|
||||
// =====================================================
|
||||
|
@ -126,7 +137,9 @@ Font::Font(FontTextHandlerType type) {
|
|||
try {
|
||||
textHandler = NULL;
|
||||
textHandler = new TextFTGL(type);
|
||||
TextFTGL::faceResolution = faceResolution;
|
||||
TextFTGL::faceResolution = Font::faceResolution;
|
||||
TextFTGL::langHeightText = Font::langHeightText;
|
||||
|
||||
metrics.setTextHandler(this->textHandler);
|
||||
}
|
||||
catch(exception &ex) {
|
||||
|
|
|
@ -32,7 +32,8 @@ using namespace Shared::PlatformCommon;
|
|||
namespace Shared { namespace Graphics { namespace Gl {
|
||||
|
||||
|
||||
int TextFTGL::faceResolution = 72;
|
||||
string TextFTGL::langHeightText = "yW";
|
||||
int TextFTGL::faceResolution = 72;
|
||||
|
||||
//====================================================================
|
||||
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->LineHeight();
|
||||
|
||||
FTBBox box = ftFont->BBox("yW");
|
||||
float result = box.Upper().Y()- box.Lower().Y();
|
||||
//printf("ftFont->BBox(''yW'')%f\n",result);
|
||||
static float result = -1000;
|
||||
if(result == -1000) {
|
||||
FTBBox box = ftFont->BBox(TextFTGL::langHeightText.c_str());
|
||||
result = box.Upper().Y()- box.Lower().Y();
|
||||
//printf("ftFont->BBox(''yW'')%f\n",result);
|
||||
}
|
||||
return result;
|
||||
// printf("For str [%s] LineHeight = %f, result = %f\n",str, ftFont->LineHeight(),result);
|
||||
// return result;
|
||||
|
|
Loading…
Reference in New Issue