Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8753 in orxonox.OLD for branches


Ignore:
Timestamp:
Jun 23, 2006, 6:38:05 PM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: non-compiling new Version of the Data-Font

Location:
branches/fontdata/src/lib/graphics/text_engine
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/fontdata/src/lib/graphics/text_engine/font.cc

    r8751 r8753  
    2727
    2828#include "debug.h"
    29 #include "stdlibincl.h"
    3029#include "compiler.h"
    31 using namespace std;
     30
    3231
    3332/**
     
    3736 */
    3837Font::Font(const std::string& fontFile, unsigned int renderSize)
    39   : data(new FontData())
     38  : data(Font::defaultFontData)
    4039{
    4140  this->init();
     
    5453 */
    5554Font::Font(const std::string& imageFile)
    56   : data(new FontData())
     55  : data(Font::defaultFontData)
    5756{
    5857  this->init();
     58
    5959  this->setName(imageFile);
    6060  //  this->setSize(fontSize);
     
    7878 */
    7979Font::Font(char** xpmArray)
    80   : data(new FontData())
     80  : data(Font::defaultFontData)
    8181{
    8282  this->init();
     
    111111{
    112112  this->setClassID(CL_FONT, "Font");
    113 }
     113  if (Font::defaultFontData.get() == NULL)
     114    Font::defaultFontData = initDefaultFont();
     115}
     116
     117FontDataPointer Font::defaultFontData = FontDataPointer(NULL); //initDefaultFont();
    114118
    115119
     
    121125bool Font::loadFontFromTTF(const std::string& fontFile)
    122126{
    123   // checking for existent Font.
    124   if (this->data->fontTTF != NULL)
    125   {
    126     TTF_CloseFont(this->data->fontTTF);
    127     this->data->fontTTF = NULL;
    128   }
    129 
     127  this->data = FontDataPointer (new FontData());
    130128
    131129  this->setName(fontFile);
     
    223221  //    PRINTF(2)("Font was not initialized, please do so before setting the Font-Style.\n");
    224222}
    225 
    226 Font* Font::defaultFont = NULL;
    227223
    228224/**
     
    288284 * @brief initializes the default font
    289285 */
    290 void Font::initDefaultFont()
    291 {
    292   if (Font::defaultFont == NULL)
    293     Font::defaultFont = new Font(font_xpm);
    294 }
    295 
    296 /**
    297  * @brief deletes the default font
    298  */
    299 void Font::removeDefaultFont()
    300 {
    301   if (Font::defaultFont != NULL)
    302     delete Font::defaultFont;
    303   Font::defaultFont = NULL;
    304 }
    305 
     286FontDataPointer Font::initDefaultFont()
     287{
     288  return Font(font_xpm).data;
     289}
    306290
    307291/**
     
    569553 * @brief a simple function to get some interesting information about this class
    570554 */
    571 void Font::debug()
     555void Font::debug() const
    572556{
    573557  // print the loaded font's style
  • branches/fontdata/src/lib/graphics/text_engine/font.h

    r8751 r8753  
    4343
    4444  /** @returns the default Font */
    45   inline static Font* getDefaultFont() { if (Font::defaultFont == NULL) initDefaultFont(); return Font::defaultFont; };
     45  //inline static Font* getDefaultFont() { if (Font::defaultFont == NULL) initDefaultFont(); return Font::defaultFont; };
     46
     47
    4648
    4749  void createAsciiImage(const std::string& fileName, unsigned int size) const;
    48   static void initDefaultFont();
    49   static void removeDefaultFont();
    5050
    51 
     51  void debug() const ;
    5252private:
    5353  void init();
     
    5656  bool createFastTexture();
    5757
     58
    5859  void initGlyphs(Uint16 from, Uint16 count);
    5960  int findOptimalFastTextureSize();
    6061
    61   void debug();
     62
     63  static FontDataPointer initDefaultFont();
    6264
    6365private:
    64   static Font*  defaultFont;         //!< a default font, that is used, if other fonts were unable to be loaded.
     66  static FontDataPointer    defaultFontData;     //!< a default font, that is used, if other fonts were unable to be loaded.
    6567
    66   fontDataPointer data;
     68  FontDataPointer           data;                //!< A Data-Pointer to a Font.
    6769};
    6870
  • branches/fontdata/src/lib/graphics/text_engine/font_data.h

    r8751 r8753  
    7272};
    7373
    74 typedef CountPointer<FontData> fontDataPointer;
     74typedef CountPointer<FontData> FontDataPointer;
    7575
    7676#endif /* _FONT_DATA_H */
  • branches/fontdata/src/lib/graphics/text_engine/text.cc

    r8619 r8753  
    5656Text::~Text()
    5757{
    58   if (this->_font != NULL && this->_font != Font::getDefaultFont())
    59     ResourceManager::getInstance()->unload(this->_font);
     58/*  if (this->_font != NULL && this->_font != Font::getDefaultFont())
     59    ResourceManager::getInstance()->unload(this->_font);*/
    6060}
    6161
     
    175175{
    176176  Font* newFont = NULL;
    177   Font* oldFont = this->_font;
     177//  Font* oldFont = this->_font;
    178178
    179179  // load a new Font
     
    183183    if (newFont == NULL)
    184184    {
    185       newFont = Font::getDefaultFont();
     185      //      newFont = Font::getDefaultFont();
    186186      PRINTF(2)("Font %s could not be loaded, probably file not found\n", fontFile.c_str());
    187187    }
    188188  }
    189   if (newFont == NULL)
    190     newFont = Font::getDefaultFont();
     189//  if (newFont == NULL)
     190//    newFont = Font::getDefaultFont();
    191191  assert(newFont != NULL);
    192192
    193193  // unloading the Font if we alrady have one loaded.
    194194  this->_font = newFont;
    195   if (oldFont != NULL && oldFont != Font::getDefaultFont())
    196     ResourceManager::getInstance()->unload(oldFont);
     195//   if (oldFont != NULL && oldFont != Font::getDefaultFont())
     196//     ResourceManager::getInstance()->unload(oldFont);
    197197
    198198  this->setupTextWidth();
  • branches/fontdata/src/lib/graphics/text_engine/text_engine.cc

    r7428 r8753  
    7676    {
    7777      Font* font = dynamic_cast<Font*>(fontList->back());
    78       if (likely(font != Font::getDefaultFont()))
    79         ResourceManager::getInstance()->unload(font, RP_GAME);
     78      //if (likely(font != Font::getDefaultFont()))
     79      //        ResourceManager::getInstance()->unload(font, RP_GAME);
    8080    }
    8181  }
     
    108108  if (TTF_WasInit())
    109109    {
    110       Font::removeDefaultFont();
     110//      Font::removeDefaultFont();
    111111      TTF_Quit();
    112112    }
Note: See TracChangeset for help on using the changeset viewer.