]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/resources.cpp
Fix automatic font creation
[libs/gltk.git] / source / resources.cpp
index 650140ba4552f59b066f00cc5677b5d34dfd9734..f146bbc9a281b6f19423005dd6d45a3b5d5550ed 100644 (file)
@@ -34,7 +34,9 @@ const GL::Font &Resources::get_default_font() const
 GL::Font *Resources::create_font(const string &name)
 {
        RefPtr<GL::Font> fnt=new GL::Font;
-       DataFile::load(*fnt, (path/(name+".font")).str());
+       DataFile::load<GL::Font, Resources &>(*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<GL::Font>(name);
+}
+
 void Resources::Loader::font(const string &name)
 {
        RefPtr<GL::Font> fnt=new GL::Font;