- bugfix to fallback to a default configured font if the specified font in the ini property fails to load. The default font is 'fixed' but can be overriden in the ini using:
DefaultFont=yourfonttype
This commit is contained in:
parent
3963b99e37
commit
a84f0d1b6d
|
@ -33,6 +33,7 @@
|
||||||
#include "checksum.h"
|
#include "checksum.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include "sound_renderer.h"
|
#include "sound_renderer.h"
|
||||||
|
#include "font_gl.h"
|
||||||
#include "leak_dumper.h"
|
#include "leak_dumper.h"
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
|
@ -44,6 +45,7 @@ using namespace std;
|
||||||
using namespace Shared::Platform;
|
using namespace Shared::Platform;
|
||||||
using namespace Shared::Util;
|
using namespace Shared::Util;
|
||||||
using namespace Shared::Graphics;
|
using namespace Shared::Graphics;
|
||||||
|
using namespace Shared::Graphics::Gl;
|
||||||
|
|
||||||
namespace Glest{ namespace Game{
|
namespace Glest{ namespace Game{
|
||||||
|
|
||||||
|
@ -574,6 +576,7 @@ int glestMain(int argc, char** argv){
|
||||||
try{
|
try{
|
||||||
std::auto_ptr<FileCRCPreCacheThread> preCacheThread;
|
std::auto_ptr<FileCRCPreCacheThread> preCacheThread;
|
||||||
Config &config = Config::getInstance();
|
Config &config = Config::getInstance();
|
||||||
|
FontGl::setDefault_fontType(config.getString("DefaultFont",FontGl::getDefault_fontType().c_str()));
|
||||||
|
|
||||||
//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__);
|
||||||
|
|
||||||
|
|
|
@ -14,20 +14,27 @@
|
||||||
|
|
||||||
#include "font.h"
|
#include "font.h"
|
||||||
#include "opengl.h"
|
#include "opengl.h"
|
||||||
|
#include <string>
|
||||||
#include "leak_dumper.h"
|
#include "leak_dumper.h"
|
||||||
|
|
||||||
namespace Shared{ namespace Graphics{ namespace Gl{
|
using namespace std;
|
||||||
|
|
||||||
|
namespace Shared { namespace Graphics { namespace Gl {
|
||||||
|
|
||||||
// =====================================================
|
// =====================================================
|
||||||
// class FontGl
|
// class FontGl
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
|
||||||
class FontGl{
|
class FontGl {
|
||||||
protected:
|
protected:
|
||||||
GLuint handle;
|
GLuint handle;
|
||||||
|
static string default_fonttype;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GLuint getHandle() const {return handle;}
|
GLuint getHandle() const {return handle;}
|
||||||
|
|
||||||
|
static string getDefault_fontType() { return default_fonttype; }
|
||||||
|
static void setDefault_fontType(string value) { default_fonttype = value; }
|
||||||
};
|
};
|
||||||
|
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
|
|
@ -23,6 +23,8 @@ using namespace Platform;
|
||||||
// class Font2DGl
|
// class Font2DGl
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
|
||||||
|
string FontGl::default_fonttype = "fixed";
|
||||||
|
|
||||||
void Font2DGl::init(){
|
void Font2DGl::init(){
|
||||||
assertGl();
|
assertGl();
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
|
|
||||||
#include <GL/glx.h>
|
#include <GL/glx.h>
|
||||||
|
|
||||||
#include "opengl.h"
|
#include "opengl.h"
|
||||||
|
@ -21,15 +20,13 @@
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
//#include <SDL_image.h>
|
#include "font_gl.h"
|
||||||
#include "leak_dumper.h"
|
#include "leak_dumper.h"
|
||||||
|
|
||||||
using namespace Shared::Graphics::Gl;
|
using namespace Shared::Graphics::Gl;
|
||||||
using namespace Shared::Util;
|
using namespace Shared::Util;
|
||||||
|
|
||||||
namespace Shared{ namespace Platform{
|
namespace Shared { namespace Platform {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ======================================
|
// ======================================
|
||||||
// Global Fcs
|
// Global Fcs
|
||||||
|
@ -42,8 +39,16 @@ void createGlFontBitmaps(uint32 &base, const string &type, int size, int width,
|
||||||
throw std::runtime_error("Couldn't create font: display is 0");
|
throw std::runtime_error("Couldn't create font: display is 0");
|
||||||
}
|
}
|
||||||
XFontStruct* fontInfo = XLoadQueryFont(display, type.c_str());
|
XFontStruct* fontInfo = XLoadQueryFont(display, type.c_str());
|
||||||
if(!fontInfo) {
|
if(fontInfo == NULL) {
|
||||||
throw std::runtime_error("Font not found.");
|
string default_font = FontGl::getDefault_fontType();
|
||||||
|
|
||||||
|
//throw std::runtime_error("Font not found: [" + type + "]");
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugError,"Font not found [%s] trying to fallback to [%s]\n",type.c_str(),default_font.c_str());
|
||||||
|
|
||||||
|
fontInfo = XLoadQueryFont(display, default_font.c_str());
|
||||||
|
if(fontInfo == NULL) {
|
||||||
|
throw std::runtime_error("Font not found: [" + type + "]");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// we need the height of 'a' which sould ~ be half ascent+descent
|
// we need the height of 'a' which sould ~ be half ascent+descent
|
||||||
|
@ -53,7 +58,8 @@ void createGlFontBitmaps(uint32 &base, const string &type, int size, int width,
|
||||||
if(i < fontInfo->min_char_or_byte2 ||
|
if(i < fontInfo->min_char_or_byte2 ||
|
||||||
i > fontInfo->max_char_or_byte2) {
|
i > fontInfo->max_char_or_byte2) {
|
||||||
metrics.setWidth(i, static_cast<float>(6));
|
metrics.setWidth(i, static_cast<float>(6));
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
int p = i - fontInfo->min_char_or_byte2;
|
int p = i - fontInfo->min_char_or_byte2;
|
||||||
metrics.setWidth(i, static_cast<float> (
|
metrics.setWidth(i, static_cast<float> (
|
||||||
fontInfo->per_char[p].width));
|
fontInfo->per_char[p].width));
|
||||||
|
|
Loading…
Reference in New Issue
Block a user