FontAsset* AssetManager::RequestFont(const std::string &filename, int size) { assert(filename.c_str()); FontAsset* asset = static_cast<FontAsset*>(GetAssetByFilename(filename)); if (!asset) { asset = new FontAsset(); bool result = false; switch (mMethod) { case AssetLoadingMethod::LoadFromFile: result = asset->Load(filename, size); break; case AssetLoadingMethod::LoadFromBinary: result = asset->Load(filename, size); break; } if (result) { StoreAsset(asset); } else { printIn("%s: Failed to load\n", asset->mName.c_str()); SAFE_DELETE(asset); } } if (asset) { asset->AddReference(); printIn("%s: RefCount (%d)\n", asset->mName.c_str(), asset->mRefCount); } return asset; }
FontAsset *Assets::RequestFont(const std::string &filename, int size) { FontAsset *asset = NULL; std::string name = filename; // GetContentPath() + filename; asset = (FontAsset *)GetAssetByFilename(name); if (!asset) { asset = new FontAsset(); if (asset->Load(name, size)) { StoreAsset(asset); std::cout << asset->m_filename << ": Load" << std::endl; } else { SDELETE(asset); } } if (asset) { asset->AddReference(); std::cout << asset->m_filename << ": RefCount (" << asset->m_iRefCount << ")" << std::endl; } return asset; }