mirror of
https://github.com/glest/glest-source.git
synced 2025-08-30 11:19:48 +02:00
- pre-calc font height for ftgl and optionally allow for language specific characters to be used
This commit is contained in:
@@ -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;
|
||||
|
Reference in New Issue
Block a user