Example #1
0
void FontManager::loadAll(std::string directory)
{
  if (directory.size() == 0)
    return;

  OSFile file;

  OSDir dir(directory.c_str());

  while (dir.getNextFile(file, true)) {
    const char *ext = file.getExtension();

    if (ext) {
      if (strcasecmp(ext, "fmt") == 0) {
	TextureFont *pFont = new TextureFont;
	if (pFont) {
	  if (pFont->load(file)) {
	    std::string	str = pFont->getFaceName();
	    GetTypeFaceName((char*)str.c_str());

	    FontFaceMap::iterator faceItr = faceNames.find(str);
	    
	    int faceID = 0;
	    if (faceItr == faceNames.end()) {
	      // its new
	      FontSizeMap faceList;
	      fontFaces.push_back(faceList);
	      faceID = (int)fontFaces.size() - 1;
	      faceNames[str] = faceID;
	    } else {
	      faceID = faceItr->second;
	    }

	    fontFaces[faceID][pFont->getSize()] = pFont;
	  } else {
	    DEBUG4("Font Texture load failed: %s\n", file.getOSName());
	    delete(pFont);
	  }
	}
      }
    }
  }
}