+ fix memory font loading
This commit is contained in:
parent
5de4636be8
commit
37b74f1e15
1 changed files with 12 additions and 6 deletions
|
@ -231,19 +231,25 @@ face_ptr freetype_engine::create_face(std::string const& family_name)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// load font into memory
|
// load font into memory
|
||||||
|
#ifdef MAPNIK_THREADSAFE
|
||||||
|
mutex::scoped_lock lock(mutex_);
|
||||||
|
#endif
|
||||||
std::ifstream is(itr->second.second.c_str() , std::ios::binary);
|
std::ifstream is(itr->second.second.c_str() , std::ios::binary);
|
||||||
std::string buffer((std::istreambuf_iterator<char>(is)),
|
std::string buffer((std::istreambuf_iterator<char>(is)),
|
||||||
std::istreambuf_iterator<char>());
|
std::istreambuf_iterator<char>());
|
||||||
|
std::pair<std::map<std::string,std::string>::iterator,bool> result
|
||||||
|
= memory_fonts_.insert(std::make_pair(itr->second.second, buffer));
|
||||||
|
|
||||||
FT_Error error = FT_New_Memory_Face (library_,
|
FT_Error error = FT_New_Memory_Face (library_,
|
||||||
(FT_Byte const*) buffer.c_str(),
|
(FT_Byte const*) result.first->second.c_str(),
|
||||||
buffer.size(),
|
buffer.size(),
|
||||||
itr->second.first,
|
itr->second.first,
|
||||||
&face);
|
&face);
|
||||||
if (!error)
|
if (!error) return boost::make_shared<font_face>(face);
|
||||||
|
else
|
||||||
{
|
{
|
||||||
memory_fonts_.insert(std::make_pair(itr->second.second, buffer));
|
// we can't load font, erase it.
|
||||||
return boost::make_shared<font_face>(face);
|
memory_fonts_.erase(result.first);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue