From: Mikko Rasa Date: Tue, 16 Oct 2007 17:28:56 +0000 (+0000) Subject: Fix automatic font creation X-Git-Tag: 0.9~30 X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=4d1dbf9ab44b915c4f35855cb70742e8fc834d12;p=libs%2Fgltk.git Fix automatic font creation Add a default_font keyword --- diff --git a/source/resources.cpp b/source/resources.cpp index 650140b..f146bbc 100644 --- a/source/resources.cpp +++ b/source/resources.cpp @@ -34,7 +34,9 @@ const GL::Font &Resources::get_default_font() const GL::Font *Resources::create_font(const string &name) { RefPtr fnt=new GL::Font; - DataFile::load(*fnt, (path/(name+".font")).str()); + DataFile::load(*fnt, (path/(name+".font")).str(), *this); + if(!default_font) + default_font=fnt.get(); return fnt.release(); } @@ -51,9 +53,15 @@ Resources::Loader::Loader(Resources &r): Collection::Loader(r), res(r) { + add("default_font", &Loader::default_font); add("font", &Loader::font); } +void Resources::Loader::default_font(const string &name) +{ + res.default_font=&res.get(name); +} + void Resources::Loader::font(const string &name) { RefPtr fnt=new GL::Font; diff --git a/source/resources.h b/source/resources.h index cf8116d..3d39393 100644 --- a/source/resources.h +++ b/source/resources.h @@ -26,6 +26,7 @@ public: public: Loader(Resources &); private: + void default_font(const std::string &); void font(const std::string &); };