#include "resource_font.h" #include "substring.h" #include "multi_type.h" #include "debug.h" ResourceFont::ResourceFont(const std::string& imageName, GLenum target) : NewResource(&ResourceFont::type) { Resources::StorePointer* ptr = this->acquireResource(imageName + ',' + "TEST"); if (ptr) { PRINTF(5)("FOUND FONT: %s\n", imageName.c_str()); this->acquireData(static_cast(ptr)->ptr()); } else { PRINTF(5)("NOT FOUND FONT: %s\n", imageName.c_str()); std::string fileName = this->NewResource::locateFile(imageName); this->Font::loadImage(fileName, target); this->NewResource::addResource(new ResourceFont::FontResourcePointer(imageName + ',' + "TEST", Resources::KeepLevel(0), this->Font::dataPointer())); } } ResourceFont ResourceFont::createFromString(const std::string& loadString) { SubString loadValues(loadString, ','); std::string imageName; GLenum target = GL_FONT_2D; if (loadValues.size() > 0) imageName = loadValues[0]; if (loadValues.size() > 1) target = (GLenum)MultiType(loadValues[2]).getInt(); return ResourceFont(imageName, target); } Resources::tType ResourceFont::type("Font"); ResourceFont::FontResourcePointer::FontResourcePointer(const std::string& loadString, const Resources::KeepLevel& keepLevel, const FontData::Pointer& data) : Resources::StorePointer(loadString, keepLevel) , pointer(data) {}