Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/graphics/text_engine/resource_font.cc @ 10127

Last change on this file since 10127 was 9869, checked in by bensch, 18 years ago

orxonox/trunk: merged the new_class_id branche back to the trunk.
merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/new_class_id trunk -r9683:HEAD
no conflicts… puh..

File size: 1.6 KB
Line 
1
2#include "resource_font.h"
3#include "substring.h"
4#include "multi_type.h"
5#include "debug.h"
6
7
8ResourceFont::ResourceFont(const std::string& fontName, unsigned int renderSize, const Resources::KeepLevel& keepLevel)
9  : Font(), Resource(&ResourceFont::type)
10{
11  assert(!fontName.empty());
12  Resources::StorePointer* ptr = this->acquireResource(fontName + ',' + MultiType((int)renderSize).getString());
13
14  if (ptr)
15  {
16    PRINTF(5)("FOUND FONT: %s\n", fontName.c_str());
17    this->Font::acquireData(static_cast<ResourceFont::FontResourcePointer*>(ptr)->ptr());
18  }
19  else
20  {
21    PRINTF(5)("NOT FOUND FONT: %s\n", fontName.c_str());
22    std::string fileName = this->Resource::locateFile(fontName);
23
24    this->Font::loadFontFromTTF(fileName, renderSize);
25    this->Resource::addResource(new ResourceFont::FontResourcePointer(fontName + ',' + MultiType((int)renderSize).getString(), keepLevel, this->Font::dataPointer()));
26  }
27}
28
29ResourceFont ResourceFont::createFromString(const std::string& loadString, const Resources::KeepLevel& keepLevel)
30{
31  SubString loadValues(loadString, ',');
32  std::string fontName;
33  unsigned int renderSize = 20;
34  if (loadValues.size() > 0)
35    fontName = loadValues[0];
36  if (loadValues.size() > 1)
37    renderSize = (unsigned int)MultiType(loadValues[2]).getInt();
38
39  return ResourceFont(fontName, renderSize, keepLevel);
40}
41
42
43
44Resources::tType<ResourceFont> ResourceFont::type("Font");
45
46
47
48
49
50ResourceFont::FontResourcePointer::FontResourcePointer(const std::string& loadString, const Resources::KeepLevel& keepLevel, const FontData::Pointer& data)
51    : Resources::StorePointer(loadString, keepLevel) , pointer(data)
52{}
53
54
Note: See TracBrowser for help on using the repository browser.