mirror of
https://github.com/glest/glest-source.git
synced 2025-08-18 22:21:18 +02:00
- added a few new chinese fonts and changed default to a new font
- fixed location of player title in menus - added better ftgl error checking
This commit is contained in:
@@ -82,7 +82,9 @@ TextFTGL::TextFTGL(FontTextHandlerType type) : Text(type) {
|
||||
|
||||
ftFont->FaceSize(24,TextFTGL::faceResolution);
|
||||
if(ftFont->Error()) {
|
||||
throw runtime_error("FTGL: error setting face size");
|
||||
char szBuf[1024]="";
|
||||
sprintf(szBuf,"FTGL: error setting face size, #%d",ftFont->Error());
|
||||
throw runtime_error(szBuf);
|
||||
}
|
||||
//ftFont->UseDisplayList(false);
|
||||
//ftFont->CharMap(ft_encoding_gb2312);
|
||||
@@ -92,7 +94,9 @@ TextFTGL::TextFTGL(FontTextHandlerType type) : Text(type) {
|
||||
}
|
||||
|
||||
if(ftFont->Error()) {
|
||||
throw runtime_error("FTGL: error setting encoding");
|
||||
char szBuf[1024]="";
|
||||
sprintf(szBuf,"FTGL: error setting encoding, #%d",ftFont->Error());
|
||||
throw runtime_error(szBuf);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,7 +157,9 @@ void TextFTGL::init(string fontName, int fontSize) {
|
||||
}
|
||||
|
||||
if(ftFont->Error()) {
|
||||
throw runtime_error("FTGL: error setting face size");
|
||||
char szBuf[1024]="";
|
||||
sprintf(szBuf,"FTGL: error setting face size, #%d",ftFont->Error());
|
||||
throw runtime_error(szBuf);
|
||||
}
|
||||
|
||||
//ftFont->UseDisplayList(false);
|
||||
@@ -163,21 +169,32 @@ void TextFTGL::init(string fontName, int fontSize) {
|
||||
throw runtime_error("FTGL: error setting encoding");
|
||||
}
|
||||
if(ftFont->Error()) {
|
||||
throw runtime_error("FTGL: error setting encoding");
|
||||
char szBuf[1024]="";
|
||||
sprintf(szBuf,"FTGL: error setting encoding, #%d",ftFont->Error());
|
||||
throw runtime_error(szBuf);
|
||||
}
|
||||
|
||||
// Create a string containing common characters
|
||||
// and preload the chars without rendering them.
|
||||
string preloadText = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890-=!@#$%^&*()_+:\"{}[]/?.,<>\\';";
|
||||
ftFont->Advance(preloadText.c_str());
|
||||
|
||||
if(ftFont->Error()) {
|
||||
char szBuf[1024]="";
|
||||
sprintf(szBuf,"FTGL: error advancing(a), #%d",ftFont->Error());
|
||||
throw runtime_error(szBuf);
|
||||
}
|
||||
}
|
||||
|
||||
void TextFTGL::SetFaceSize(int value) {
|
||||
ftFont->FaceSize(value,TextFTGL::faceResolution);
|
||||
if(ftFont->Error()) {
|
||||
throw runtime_error("FTGL: error setting face size");
|
||||
char szBuf[1024]="";
|
||||
sprintf(szBuf,"FTGL: error setting face size, #%d",ftFont->Error());
|
||||
throw runtime_error(szBuf);
|
||||
}
|
||||
}
|
||||
|
||||
int TextFTGL::GetFaceSize() {
|
||||
return ftFont->FaceSize();
|
||||
}
|
||||
@@ -192,13 +209,21 @@ void TextFTGL::Render(const char* str, const int len) {
|
||||
ftFont->Render(str, len);
|
||||
|
||||
if(ftFont->Error()) {
|
||||
throw runtime_error("FTGL: error trying to render");
|
||||
char szBuf[1024]="";
|
||||
sprintf(szBuf,"FTGL: error trying to render, #%d",ftFont->Error());
|
||||
throw runtime_error(szBuf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float TextFTGL::Advance(const char* str, const int len) {
|
||||
return ftFont->Advance(str, len);
|
||||
float result = ftFont->Advance(str, len);
|
||||
if(ftFont->Error()) {
|
||||
char szBuf[1024]="";
|
||||
sprintf(szBuf,"FTGL: error trying to advance(b), #%d",ftFont->Error());
|
||||
throw runtime_error(szBuf);
|
||||
}
|
||||
return result;
|
||||
|
||||
//FTBBox box = ftFont->BBox(str);
|
||||
//float urx = box.Upper().X();
|
||||
@@ -242,6 +267,12 @@ float TextFTGL::LineHeight(const char* str, const int len) {
|
||||
}
|
||||
//printf("ftFont->BBox(''yW'')%f\n",result);
|
||||
}
|
||||
if(ftFont->Error()) {
|
||||
char szBuf[1024]="";
|
||||
sprintf(szBuf,"FTGL: error trying to get lineheight, #%d",ftFont->Error());
|
||||
throw runtime_error(szBuf);
|
||||
}
|
||||
|
||||
return result;
|
||||
// printf("For str [%s] LineHeight = %f, result = %f\n",str, ftFont->LineHeight(),result);
|
||||
// return result;
|
||||
@@ -281,6 +312,12 @@ float TextFTGL::LineHeight(const wchar_t* str, const int len) {
|
||||
}
|
||||
//printf("ftFont->BBox(''yW'')%f\n",result);
|
||||
}
|
||||
if(ftFont->Error()) {
|
||||
char szBuf[1024]="";
|
||||
sprintf(szBuf,"FTGL: error trying to get lineheight, #%d",ftFont->Error());
|
||||
throw runtime_error(szBuf);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -291,11 +328,24 @@ void TextFTGL::Render(const wchar_t* str, const int len) {
|
||||
*/
|
||||
if(len != 0) {
|
||||
ftFont->Render(str, len);
|
||||
|
||||
if(ftFont->Error()) {
|
||||
char szBuf[1024]="";
|
||||
sprintf(szBuf,"FTGL: error trying to render, #%d",ftFont->Error());
|
||||
throw runtime_error(szBuf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float TextFTGL::Advance(const wchar_t* str, const int len) {
|
||||
return ftFont->Advance(str, len);
|
||||
float result = ftFont->Advance(str, len);
|
||||
if(ftFont->Error()) {
|
||||
char szBuf[1024]="";
|
||||
sprintf(szBuf,"FTGL: error trying to advance(c), #%d",ftFont->Error());
|
||||
throw runtime_error(szBuf);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
const char* TextFTGL::findFont(const char *firstFontToTry) {
|
||||
|
Reference in New Issue
Block a user