mirror of
https://github.com/glest/glest-source.git
synced 2025-08-29 10:49:48 +02:00
Fix issue #116 - when fonts deleted and reloaded signal back immediately to all registered controls to refresh their font
This commit is contained in:
@@ -22,7 +22,7 @@ using std::string;
|
||||
//class Text;
|
||||
|
||||
namespace Shared { namespace Graphics {
|
||||
|
||||
|
||||
// =====================================================
|
||||
// class FontMetrics
|
||||
// =====================================================
|
||||
@@ -90,6 +90,7 @@ protected:
|
||||
FontMetrics metrics;
|
||||
|
||||
Text *textHandler;
|
||||
string fontUniqueId;
|
||||
|
||||
public:
|
||||
//constructor & destructor
|
||||
@@ -97,6 +98,9 @@ public:
|
||||
virtual ~Font();
|
||||
virtual void init()=0;
|
||||
virtual void end()=0;
|
||||
|
||||
void setFontUniqueId(string id) { fontUniqueId = id; }
|
||||
string getFontUniqueId() { return fontUniqueId; }
|
||||
|
||||
//get
|
||||
int getWidth() const;
|
||||
@@ -147,6 +151,12 @@ Font3D *ConvertFont2DTo3D(Font2D *font);
|
||||
|
||||
const char* findFont(const char *firstFontToTry=NULL,const char *firstFontFamilyToTry=NULL);
|
||||
|
||||
class FontChangedCallbackInterface {
|
||||
public:
|
||||
virtual void FontChangedCallback(std::string fontUniqueId, Font *font) = 0;
|
||||
virtual ~FontChangedCallbackInterface() {};
|
||||
};
|
||||
|
||||
}}//end namespace
|
||||
|
||||
#endif
|
||||
|
@@ -99,6 +99,7 @@ void Font::resetToDefaults() {
|
||||
|
||||
FontMetrics::FontMetrics(Text *textHandler) {
|
||||
this->textHandler = textHandler;
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugError, "In [%s::%s Line: %d] this->textHandler = [%p] Owner = [%p]\n", __FILE__, __FUNCTION__, __LINE__, this->textHandler,this);
|
||||
this->widths = new float[Font::charCount];
|
||||
this->height = 0;
|
||||
|
||||
@@ -114,6 +115,7 @@ FontMetrics::~FontMetrics() {
|
||||
|
||||
void FontMetrics::setTextHandler(Text *textHandler) {
|
||||
this->textHandler = textHandler;
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugError, "In [%s::%s Line: %d] this->textHandler = [%p] Owner = [%p]\n", __FILE__, __FUNCTION__, __LINE__, this->textHandler, this);
|
||||
}
|
||||
|
||||
Text * FontMetrics::getTextHandler() {
|
||||
@@ -214,7 +216,8 @@ Font::Font(FontTextHandlerType type) {
|
||||
this->type = fontTypeName;
|
||||
width = 400;
|
||||
size = 10;
|
||||
textHandler = NULL;
|
||||
this->textHandler = NULL;
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugError, "In [%s::%s Line: %d] this->textHandler = [%p] Owner = [%p]\n", __FILE__, __FUNCTION__, __LINE__, this->textHandler, this);
|
||||
|
||||
#if defined(USE_FTGL)
|
||||
|
||||
@@ -225,8 +228,9 @@ Font::Font(FontTextHandlerType type) {
|
||||
TextFTGL::faceResolution = Font::faceResolution;
|
||||
TextFTGL::langHeightText = Font::langHeightText;
|
||||
|
||||
textHandler = NULL;
|
||||
textHandler = new TextFTGL(type);
|
||||
this->textHandler = NULL;
|
||||
this->textHandler = new TextFTGL(type);
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugError, "In [%s::%s Line: %d] this->textHandler = [%p] Owner = [%p]\n", __FILE__, __FUNCTION__, __LINE__, this->textHandler, this);
|
||||
|
||||
TextFTGL::faceResolution = Font::faceResolution;
|
||||
TextFTGL::langHeightText = Font::langHeightText;
|
||||
@@ -237,6 +241,7 @@ Font::Font(FontTextHandlerType type) {
|
||||
catch(exception &ex) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
|
||||
textHandler = NULL;
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugError, "In [%s::%s Line: %d] this->textHandler = [%p] Owner = [%p]\n", __FILE__, __FUNCTION__, __LINE__, this->textHandler, this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -244,10 +249,12 @@ Font::Font(FontTextHandlerType type) {
|
||||
}
|
||||
|
||||
Font::~Font() {
|
||||
if(textHandler) {
|
||||
delete textHandler;
|
||||
if(this->textHandler) {
|
||||
delete this->textHandler;
|
||||
}
|
||||
textHandler = NULL;
|
||||
this->textHandler = NULL;
|
||||
metrics.setTextHandler(this->textHandler);
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugError, "In [%s::%s Line: %d] this->textHandler = [%p] Owner = [%p]\n", __FILE__, __FUNCTION__, __LINE__, this->textHandler, this);
|
||||
}
|
||||
|
||||
string Font::getType() const {
|
||||
@@ -264,6 +271,7 @@ void Font::setType(string typeX11, string typeGeneric, string typeGenericFamily)
|
||||
catch(exception &ex) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
|
||||
textHandler = NULL;
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugError, "In [%s::%s Line: %d] this->textHandler = [%p] Owner = [%p]\n", __FILE__, __FUNCTION__, __LINE__, this->textHandler, this);
|
||||
}
|
||||
}
|
||||
if(textHandler == NULL) {
|
||||
|
Reference in New Issue
Block a user