- 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:
Mark Vejvoda 2011-10-03 04:49:52 +00:00
parent 7eb68c4023
commit ebc130f526
3 changed files with 60 additions and 10 deletions

View File

@ -330,7 +330,7 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM
labelPlayerStatus[i].init(10, setupPos-30-i*rowHeight, 60);
labelPlayers[i].registerGraphicComponent(containerName,"labelPlayers" + intToStr(i));
labelPlayers[i].init(xoffset+0, setupPos-30-i*rowHeight);
labelPlayers[i].init(xoffset-20, setupPos-30-i*rowHeight);
labelPlayers[i].setEditable(false);
labelPlayerNames[i].registerGraphicComponent(containerName,"labelPlayerNames" + intToStr(i));

View File

@ -427,7 +427,7 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu,
labelPlayerStatus[i].init(10, setupPos-30-i*rowHeight, 60);
labelPlayers[i].registerGraphicComponent(containerName,"labelPlayers" + intToStr(i));
labelPlayers[i].init(xoffset+0, setupPos-30-i*rowHeight);
labelPlayers[i].init(xoffset-20, setupPos-30-i*rowHeight);
labelPlayerNames[i].registerGraphicComponent(containerName,"labelPlayerNames" + intToStr(i));
labelPlayerNames[i].init(xoffset+50,setupPos-30-i*rowHeight);

View File

@ -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) {