added a fallback to fixed font on X11 in case of missing fonts

This commit is contained in:
Mark Vejvoda
2010-04-02 00:31:39 +00:00
parent 2391d025ac
commit d4e645424a

View File

@@ -91,7 +91,10 @@ void createGlFontBitmaps(uint32 &base, const string &type, int size, int width,
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] trying to load font %s\n",__FILE__,__FUNCTION__,__LINE__,type.c_str()); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] trying to load font %s\n",__FILE__,__FUNCTION__,__LINE__,type.c_str());
XFontStruct* fontInfo = XLoadQueryFont(display, type.c_str()); XFontStruct* fontInfo = XLoadQueryFont(display, type.c_str());
if(!fontInfo) { if(!fontInfo) {
throw std::runtime_error("Font not found."); fontInfo = XLoadQueryFont(display, "fixed");
if(!fontInfo) {
throw std::runtime_error("Font not found: " + type);
}
} }
//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__);
@@ -117,8 +120,8 @@ void createGlFontBitmaps(uint32 &base, const string &type, int size, int width,
if(fontInfo->per_char == NULL) { if(fontInfo->per_char == NULL) {
XCharStruct *charinfo = &(fontInfo->min_bounds); XCharStruct *charinfo = &(fontInfo->min_bounds);
int charWidth = charinfo->rbearing - charinfo->lbearing; int charWidth = charinfo->rbearing - charinfo->lbearing;
int charHeight = charinfo->ascent + charinfo->descent; //int charHeight = charinfo->ascent + charinfo->descent;
int spanLength = (charWidth + 7) / 8; //int spanLength = (charWidth + 7) / 8;
metrics.setWidth(i, static_cast<float> (charWidth)); metrics.setWidth(i, static_cast<float> (charWidth));
} }