Handle exceptions in reading fonts.

This commit is contained in:
vng 2013-05-22 18:59:08 +03:00 committed by Alex Zolotarev
parent dcecb55149
commit fcf747109b
4 changed files with 24 additions and 16 deletions

View file

@ -70,10 +70,10 @@ namespace graphics
{
}
void GlyphCache::addFont(const char *fileName)
{
m_impl->addFont(fileName);
}
//void GlyphCache::addFont(const char *fileName)
//{
// m_impl->addFont(fileName);
//}
void GlyphCache::addFonts(vector<string> const & fontNames)
{

View file

@ -87,7 +87,7 @@ namespace graphics
GlyphCache(Params const & params);
void reset();
void addFont(char const * fileName);
//void addFont(char const * fileName);
void addFonts(vector<string> const & fontNames);
pair<Font*, int> getCharIDX(GlyphKey const & key);

View file

@ -190,7 +190,16 @@ namespace graphics
return;
for (size_t i = 0; i < fontNames.size(); ++i)
addFont(fontNames[i].c_str());
{
try
{
addFont(fontNames[i].c_str());
}
catch (RootException const & ex)
{
LOG(LERROR, ("Can't load font", fontNames[i], ex.Msg()));
}
}
/*
LOG(LINFO, ("----------------------------"));

View file

@ -60,19 +60,18 @@ void Platform::GetFontNames(FilesList & res) const
{
GetSystemFontNames(res);
string const resourcesPaths[] = { WritableDir(), ResourcesDir() };
string const paths[] = { WritableDir(), ResourcesDir() };
FilesList resourcesFonts;
for (size_t i = 0; i < ARRAY_SIZE(resourcesPaths); ++i)
FilesList fonts;
for (size_t i = 0; i < ARRAY_SIZE(paths); ++i)
{
LOG(LDEBUG, ("Searching for fonts in", resourcesPaths[i]));
GetFilesByExt(resourcesPaths[i], ".ttf", resourcesFonts);
};
LOG(LDEBUG, ("Searching for fonts in", paths[i]));
GetFilesByExt(paths[i], ".ttf", fonts);
}
sort(resourcesFonts.begin(), resourcesFonts.end());
resourcesFonts.erase(unique(resourcesFonts.begin(), resourcesFonts.end()), resourcesFonts.end());
res.insert(res.end(), resourcesFonts.begin(), resourcesFonts.end());
sort(fonts.begin(), fonts.end());
fonts.erase(unique(fonts.begin(), fonts.end()), fonts.end());
res.insert(res.end(), fonts.begin(), fonts.end());
LOG(LINFO, ("Available font files:", (res)));
}