home *** CD-ROM | disk | FTP | other *** search
- #include "FontHandler.h"
-
- #include "Tokenizer.h"
- #include "log.h"
-
- // init of static members
- std::vector<texFontRefCounterPair_t> FontHandler::fonts;
-
- texFont_t* FontHandler::getFont(const char* filename){
-
- std::vector<texFontRefCounterPair_t>::iterator i;
- for(i=fonts.begin();i<fonts.end();i++){
- if(i->first->filename!=NULL && streq(filename, i->first->filename)){
- i->second++;
- return i->first;
- }
- }
-
- texFont_t* f=::loadFont(filename);
- if(f==NULL)
- return NULL;
-
- texFontRefCounterPair_t p(f, 1);
- fonts.push_back(p);
-
- return f;
- }
-
- int FontHandler::getNumFonts(){
- return fonts.size();
- }
-
- void FontHandler::releaseFont(texFont_t* font){
- if(font==NULL)
- return;
-
- std::vector<texFontRefCounterPair_t>::iterator i;
- for(i=fonts.begin();i<fonts.end();i++){
- if(i->first==font){
- i->second--;
- if(i->second==0){
- // log("FontHandler::releaseFont(): Font '%s' not referenced any more (I'll delete it).\n", i->first->filename);
- freeFont(i->first);
- fonts.erase(i);
- }
- }
- }
- }
-
-