From e3a3b974dac08778cdc4a953190244ac214afe2d Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Sat, 3 Apr 2010 02:23:46 +0000 Subject: [PATCH] Added more debug output and protection for X11 font processing --- .../sources/platform/sdl/gl_wrap.cpp | 51 +++++++++++++------ 1 file changed, 36 insertions(+), 15 deletions(-) diff --git a/source/shared_lib/sources/platform/sdl/gl_wrap.cpp b/source/shared_lib/sources/platform/sdl/gl_wrap.cpp index 54b6eee4e..4fa8e3a0a 100644 --- a/source/shared_lib/sources/platform/sdl/gl_wrap.cpp +++ b/source/shared_lib/sources/platform/sdl/gl_wrap.cpp @@ -100,23 +100,32 @@ void createGlFontBitmaps(uint32 &base, const string &type, int size, int width, //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); // we need the height of 'a' which sould ~ be half ascent+descent - metrics.setHeight(static_cast - (fontInfo->ascent + fontInfo->descent) / 2); + float height = (static_cast(fontInfo->ascent + fontInfo->descent) / 2); + if(height <= 0) { + height = static_cast(6); + } + metrics.setHeight(height); + + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] height = %f\n",__FILE__,__FUNCTION__,__LINE__,height); //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); for(unsigned int i = 0; i < static_cast (charCount); ++i) { - //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); - if(i < fontInfo->min_char_or_byte2 || - i > fontInfo->max_char_or_byte2) { - //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); - metrics.setWidth(i, static_cast(6)); + if(i < fontInfo->min_char_or_byte2 || i > fontInfo->max_char_or_byte2) { + + float width = static_cast(6); + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] setting size = %f\n",__FILE__,__FUNCTION__,__LINE__,width); + + metrics.setWidth(i, width); } else { - //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); + int p = i - fontInfo->min_char_or_byte2; - //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] p = %d fontInfo->per_char = %p\n",__FILE__,__FUNCTION__,__LINE__,p,fontInfo->per_char); + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] p = %d fontInfo->per_char = %p\n",__FILE__,__FUNCTION__,__LINE__,p,fontInfo->per_char); + if(fontInfo->per_char == NULL) { SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] type = [%s] p = %d fontInfo->per_char = %p\n",__FILE__,__FUNCTION__,__LINE__,type.c_str(),p,fontInfo->per_char); @@ -126,29 +135,41 @@ void createGlFontBitmaps(uint32 &base, const string &type, int size, int width, //int spanLength = (charWidth + 7) / 8; if(charinfo != NULL) { + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] type = [%s] charinfo->width = %d\n",__FILE__,__FUNCTION__,__LINE__,type.c_str(),charinfo->width); metrics.setWidth(i, static_cast (charinfo->width)); } else { + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] type = [%s] using size 6\n",__FILE__,__FUNCTION__,__LINE__,type.c_str()); + metrics.setWidth(i, static_cast(6)); } } else { - metrics.setWidth(i, static_cast ( - fontInfo->per_char[p].rbearing - - fontInfo->per_char[p].lbearing)); + float width = static_cast (fontInfo->per_char[p].rbearing - fontInfo->per_char[p].lbearing); + if(width <= 0) { + width = static_cast(6); + } + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] type = [%s] using size = %f\n",__FILE__,__FUNCTION__,__LINE__,type.c_str(),width); + metrics.setWidth(i, width); } } //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); } - //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); + glXUseXFont(fontInfo->fid, 0, charCount, base); - //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); + + GLenum glerror = ::glGetError(); + + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] glerror = %d\n",__FILE__,__FUNCTION__,__LINE__,glerror); + XFreeFont(display, fontInfo); - //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); #else // we badly need a solution portable to more than just glx //NOIMPL;