Merge branch 'master' of github.com:mapnik/mapnik into render-time-variables

This commit is contained in:
Dane Springmeyer 2014-05-13 20:51:57 -07:00
commit 96f89e34b3
3 changed files with 29 additions and 5 deletions

View file

@ -193,7 +193,7 @@ def shortest_name(libs):
def rm_path(item,set,_env): def rm_path(item,set,_env):
for i in _env[set]: for i in _env[set]:
if item in i: if i.startswith(item):
_env[set].remove(i) _env[set].remove(i)
def sort_paths(items,priority): def sort_paths(items,priority):

View file

@ -44,6 +44,7 @@
#include <vector> #include <vector>
struct FT_LibraryRec_; struct FT_LibraryRec_;
struct FT_MemoryRec_;
namespace mapnik namespace mapnik
{ {
@ -79,6 +80,7 @@ public:
freetype_engine(); freetype_engine();
private: private:
FT_LibraryRec_ * library_; FT_LibraryRec_ * library_;
std::unique_ptr<FT_MemoryRec_> memory_;
#ifdef MAPNIK_THREADSAFE #ifdef MAPNIK_THREADSAFE
static std::mutex mutex_; static std::mutex mutex_;
#endif #endif

View file

@ -34,6 +34,7 @@
// stl // stl
#include <algorithm> #include <algorithm>
#include <stdexcept> #include <stdexcept>
#include <cstdlib>
// freetype2 // freetype2
extern "C" extern "C"
@ -41,25 +42,46 @@ extern "C"
#include <ft2build.h> #include <ft2build.h>
#include FT_FREETYPE_H #include FT_FREETYPE_H
#include FT_STROKER_H #include FT_STROKER_H
#include FT_MODULE_H
}
void* _Alloc_Func(FT_Memory memory, long size)
{
return std::malloc(size);
}
void _Free_Func(FT_Memory memory, void *block)
{
std::free(block);
}
void* _Realloc_Func(FT_Memory memory, long cur_size, long new_size, void* block)
{
return std::realloc(block, new_size);
} }
namespace mapnik namespace mapnik
{ {
freetype_engine::freetype_engine() : freetype_engine::freetype_engine() :
library_(nullptr) library_(nullptr),
memory_(new FT_MemoryRec_)
{ {
FT_Error error = FT_Init_FreeType( &library_ ); memory_->alloc = _Alloc_Func;
memory_->free = _Free_Func;
memory_->realloc = _Realloc_Func;
FT_Error error = FT_New_Library( &*memory_, &library_ );
if (error) if (error)
{ {
throw std::runtime_error("can not load FreeType2 library"); throw std::runtime_error("can not load FreeType2 library");
} }
FT_Add_Default_Modules(library_);
} }
freetype_engine::~freetype_engine() freetype_engine::~freetype_engine()
{ {
FT_Done_FreeType(library_); FT_Done_Library(library_);
} }
bool freetype_engine::is_font_file(std::string const& file_name) bool freetype_engine::is_font_file(std::string const& file_name)