- added some more error checks in ftgl wrapper class

This commit is contained in:
Mark Vejvoda
2011-06-10 22:17:15 +00:00
parent cd05b22c50
commit 90fcb0abe7

View File

@@ -76,11 +76,21 @@ TextFTGL::TextFTGL(FontTextHandlerType type) : Text(type) {
} }
free((void*)fontFile); free((void*)fontFile);
fontFile = NULL; fontFile = NULL;
ftFont->FaceSize(24); ftFont->FaceSize(24);
if(ftFont->Error()) {
throw runtime_error("FTGL: error setting face size");
}
//ftFont->UseDisplayList(false); //ftFont->UseDisplayList(false);
//ftFont->CharMap(ft_encoding_gb2312); //ftFont->CharMap(ft_encoding_gb2312);
//ftFont->CharMap(ft_encoding_big5); //ftFont->CharMap(ft_encoding_big5);
ftFont->CharMap(ft_encoding_unicode); if(ftFont->CharMap(ft_encoding_unicode) == false) {
throw runtime_error("FTGL: error setting encoding");
}
if(ftFont->Error()) {
throw runtime_error("FTGL: error setting encoding");
}
} }
TextFTGL::~TextFTGL() { TextFTGL::~TextFTGL() {
@@ -133,14 +143,27 @@ void TextFTGL::init(string fontName, int fontSize) {
else { else {
ftFont->FaceSize(24); ftFont->FaceSize(24);
} }
if(ftFont->Error()) {
throw runtime_error("FTGL: error setting face size");
}
//ftFont->UseDisplayList(false); //ftFont->UseDisplayList(false);
//ftFont->CharMap(ft_encoding_gb2312); //ftFont->CharMap(ft_encoding_gb2312);
//ftFont->CharMap(ft_encoding_big5); //ftFont->CharMap(ft_encoding_big5);
ftFont->CharMap(ft_encoding_unicode); if(ftFont->CharMap(ft_encoding_unicode) == false) {
throw runtime_error("FTGL: error setting encoding");
}
if(ftFont->Error()) {
throw runtime_error("FTGL: error setting encoding");
}
} }
void TextFTGL::SetFaceSize(int value) { void TextFTGL::SetFaceSize(int value) {
ftFont->FaceSize(value); ftFont->FaceSize(value);
if(ftFont->Error()) {
throw runtime_error("FTGL: error setting face size");
}
} }
int TextFTGL::GetFaceSize() { int TextFTGL::GetFaceSize() {
return ftFont->FaceSize(); return ftFont->FaceSize();
@@ -153,6 +176,10 @@ void TextFTGL::Render(const char* str, const int len) {
*/ */
if(len != 0) { if(len != 0) {
ftFont->Render(str, len); ftFont->Render(str, len);
if(ftFont->Error()) {
throw runtime_error("FTGL: error trying to render");
}
} }
} }